From 87866fdbbe72b8de7acbf1e06cd687040ab211cd Mon Sep 17 00:00:00 2001 From: Saksham Singh <130738043+Saksham1105@users.noreply.github.com> Date: Sun, 25 Oct 2026 14:27:42 +0530 Subject: [PATCH 1/2] fix(compressor): handle empty LLM response content --- devagent/session/compressor.py | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/devagent/session/compressor.py b/devagent/session/compressor.py index 4fbd4b5..207f0a2 100644 --- a/devagent/session/compressor.py +++ b/devagent/session/compressor.py @@ -199,7 +199,7 @@ def compress_session( try: response = llm.complete_with_tools(messages, tools=[]) - summary = response.content.strip() + summary = (response.content or "").strip() except Exception as exc: summary = f"[Compression failed: {exc}]\n\n" + old_text[:2000] From bde341dc3e15d6660f821db65f42f9d8386d5971 Mon Sep 17 00:00:00 2001 From: Saksham Singh <130738043+Saksham1105@users.noreply.github.com> Date: Sun, 25 Oct 2026 14:27:45 +0530 Subject: [PATCH 2/2] test(compressor): cover None response content --- tests/test_phase8.py | 22 ++++++++++++++++++++++ 1 file changed, 22 insertions(+) diff --git a/tests/test_phase8.py b/tests/test_phase8.py index 2d630f0..7baa61c 100644 --- a/tests/test_phase8.py +++ b/tests/test_phase8.py @@ -232,6 +232,28 @@ def test_compress_session_summarises_old_events(tmp_path): llm.complete_with_tools.assert_called_once() + +def test_compress_session_falls_back_when_response_content_is_none(tmp_path): + """A provider returning no text should use the raw-event fallback.""" + db = tmp_path / "test.db" + from devagent.session import store + from devagent.session.compressor import compress_session + + store.init_schema(db_path=db) + sid = "sess-none-content" + store.create_session(sid, db_path=db) + _seed_events(sid, 8, db) + + llm = _make_mock_llm() + llm.complete_with_tools.return_value.content = None + + result = compress_session(sid, llm, keep_last_n=3, db_path=db) + + assert result is not None + assert "[Compression failed" not in result.summary + assert "[USER] Event 0:" in result.summary + assert store.get_compressed_summary(sid, db_path=db) == result.summary + def test_compress_session_marks_events_in_db(tmp_path): db = tmp_path / "test.db" from devagent.session import store