diff options
| author | CaptainJack2491 <jayrupnakawala@gmail.com> | 2026-03-25 18:24:11 +0000 |
|---|---|---|
| committer | CaptainJack2491 <jayrupnakawala@gmail.com> | 2026-03-25 18:24:11 +0000 |
| commit | a532e7b1696ef7539a4616b9c26fbf950f3721a3 (patch) | |
| tree | 5b547cdc7efc003ae3c84ecb5429c519eec109a3 /tests | |
| parent | 36f6dc6dea2046ac7d4b942a44c26a85b9c466ee (diff) | |
fix: catch and recover from JSONDecodeError on malformed tool args
Diffstat (limited to 'tests')
| -rw-r--r-- | tests/test_agent.py | 8 |
1 files changed, 4 insertions, 4 deletions
diff --git a/tests/test_agent.py b/tests/test_agent.py index c8164e6..e73b41e 100644 --- a/tests/test_agent.py +++ b/tests/test_agent.py @@ -173,10 +173,10 @@ class TestAgentRun: ) agent.client.chat.completions.create.side_effect = [tool_response, final_response] - # json.loads will raise — this should be caught or propagate clearly - # Current code does NOT catch this, so it should raise JSONDecodeError - with pytest.raises(json.JSONDecodeError): - agent.run("Do something") + # json.loads will fail, the agent will catch it, return an error to model, + # and on the next turn the model will return "Recovered". + result = agent.run("Do something") + assert result == "Recovered" def test_api_error_propagates(self, agent): """API errors should propagate, not be silently swallowed.""" |
