test: cover fallback dropped-turn handoff

This commit is contained in:
hinotoi-agent
2026-05-28 20:34:40 -07:00
committed by Teknium
parent 6dc068ef04
commit 042c1d6bb0
2 changed files with 65 additions and 8 deletions
+26
View File
@@ -881,6 +881,32 @@ class TestSummaryFailureTrackingForGatewayWarning:
assert "/repo/src/pkg/module.py" in fallback
assert "C:\\work\\pkg\\module.py" in fallback
assert "Traceback" in fallback
assert "## Last Dropped Turns" in fallback
assert "TOOL: Traceback in /repo/src/pkg/module.py: boom" in fallback
def test_summary_failure_fallback_preserves_last_dropped_turns_without_tail(self):
with patch("agent.context_compressor.get_model_context_length", return_value=100000):
c = ContextCompressor(model="test", quiet_mode=True, protect_first_n=1, protect_last_n=1)
msgs = [
{"role": "system", "content": "sys"},
{"role": "user", "content": "Investigate dropped-window request in /tmp/active.py"},
{"role": "assistant", "content": "I inspected /tmp/active.py and found the failing branch"},
{"role": "tool", "tool_call_id": "call-old", "content": "ValueError: boom in /tmp/active.py"},
{"role": "assistant", "content": "Next step is patching /tmp/active.py"},
{"role": "user", "content": "Confirm regression coverage for /tmp/active.py"},
{"role": "assistant", "content": "Regression note is ready"},
{"role": "user", "content": "protected tail request must not be copied from dropped window"},
]
with patch("agent.context_compressor.call_llm", side_effect=Exception("timeout")):
result = c.compress(msgs)
fallback = next(m["content"] for m in result if "Summary generation was unavailable" in m.get("content", ""))
assert "## Last Dropped Turns" in fallback
assert "ASSISTANT: I inspected /tmp/active.py and found the failing branch" in fallback
assert "TOOL: ValueError: boom in /tmp/active.py" in fallback
assert "protected tail request must not be copied" not in fallback
def test_summary_failure_fallback_is_bounded(self):
with patch("agent.context_compressor.get_model_context_length", return_value=100000):