From 93a649245e13ab62fc548f57e75258ec3390121d Mon Sep 17 00:00:00 2001 From: Scott Severance Date: Tue, 27 Oct 2026 06:48:50 +0000 Subject: [PATCH 1/2] fix: validate 'done' field in non-streaming chat response --- agent/core/llm.py | 1 + 1 file changed, 1 insertion(+) diff --git a/agent/core/llm.py b/agent/core/llm.py index 92256e5..168e1d7 100644 --- a/agent/core/llm.py +++ b/agent/core/llm.py @@ -204,6 +204,7 @@ def chat( return self._stream_chat(data, timeout=timeout) result = self._request("/api/chat", data, timeout=timeout) + self._validate_response(result, ["done"]) self._validate_message_structure(result) return result From 9d78fa0483d8724ee2626aef345827f030ae74f7 Mon Sep 17 00:00:00 2001 From: "claude[bot]" <41898282+claude[bot]@users.noreply.github.com> Date: Tue, 27 Oct 2026 06:51:44 +0000 Subject: [PATCH 2/2] fix(review): update chat() test fixtures for 'done' field and add missing coverage Add "done": True to the _request fixtures in test_chat_accepts_tool_call_only_response and test_chat_rejects_non_dict_message so they reflect a well-formed response again now that chat() validates the 'done' field, and add test_chat_rejects_response_missing_done to cover the new validation itself. Co-Authored-By: Claude Sonnet 5 --- tests/test_llm.py | 12 ++++++++++-- 1 file changed, 10 insertions(+), 2 deletions(-) diff --git a/tests/test_llm.py b/tests/test_llm.py index 13fddb0..bfaf844 100644 --- a/tests/test_llm.py +++ b/tests/test_llm.py @@ -88,14 +88,22 @@ def test_chat_accepts_tool_call_only_response(self): "message": { "role": "assistant", "tool_calls": [{"function": {"name": "read_file", "arguments": {}}}], - } + }, + "done": True, } with patch.object(client, "_request", return_value=response): self.assertEqual(client.chat([{"role": "user", "content": "hi"}]), response) def test_chat_rejects_non_dict_message(self): client = make_client() - with patch.object(client, "_request", return_value={"message": None}): + with patch.object(client, "_request", return_value={"message": None, "done": True}): + with self.assertRaises(OllamaError): + client.chat([{"role": "user", "content": "hi"}]) + + def test_chat_rejects_response_missing_done(self): + client = make_client() + response = {"message": {"role": "assistant", "content": "hi"}} + with patch.object(client, "_request", return_value=response): with self.assertRaises(OllamaError): client.chat([{"role": "user", "content": "hi"}])