summaryrefslogtreecommitdiff
path: root/tests
diff options
context:
space:
mode:
authorCaptainJack2491 <jayrupnakawala@gmail.com>2026-03-25 18:24:11 +0000
committerCaptainJack2491 <jayrupnakawala@gmail.com>2026-03-25 18:24:11 +0000
commita532e7b1696ef7539a4616b9c26fbf950f3721a3 (patch)
tree5b547cdc7efc003ae3c84ecb5429c519eec109a3 /tests
parent36f6dc6dea2046ac7d4b942a44c26a85b9c466ee (diff)
fix: catch and recover from JSONDecodeError on malformed tool args
Diffstat (limited to 'tests')
-rw-r--r--tests/test_agent.py8
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."""