personal memory agent
1# SPDX-License-Identifier: AGPL-3.0-only
2# Copyright (c) 2026 sol pbc
3
4from __future__ import annotations
5
6import pytest
7
8from solstone.think.providers.shared import classify_canned_generate
9
10
11@pytest.mark.parametrize(
12 ("result", "expected"),
13 [
14 ({"text": "OK", "finish_reason": "max_tokens"}, "starved"),
15 ({"text": "OK", "finish_reason": "stop"}, "pass"),
16 ({"text": "OK"}, "pass"),
17 ({"text": "", "finish_reason": "stop"}, "invalid"),
18 ({"text": " ", "finish_reason": "stop"}, "invalid"),
19 ({"text": 123, "finish_reason": "stop"}, "invalid"),
20 (
21 {
22 "text": "",
23 "finish_reason": "stop",
24 "usage": {"reasoning_tokens": 4},
25 },
26 "starved",
27 ),
28 (
29 {
30 "text": "",
31 "finish_reason": "stop",
32 "thinking": [{"summary": "reasoned"}],
33 },
34 "starved",
35 ),
36 ({"text": "", "finish_reason": None}, "starved"),
37 ({"text": " "}, "starved"),
38 ({"text": "", "finish_reason": "unknown"}, "starved"),
39 ],
40)
41def test_classify_canned_generate_branches(result, expected):
42 assert classify_canned_generate(result) == expected