The agent that grows with you
Python aiai-agentai-agentsanthropicchatgptclaudeclaude-codecodexhermeshermes-agentllmnous-researchopenai
test(compression): trim pending-round tests to two invariants
kshitijk4poor55f77c1bb13e
diff --git a/tests/agent/test_protected_tail_pressure.py b/tests/agent/test_protected_tail_pressure.pyindex 92e34b7543a..2daa7dc10ed 100644--- a/tests/agent/test_protected_tail_pressure.py+++ b/tests/agent/test_protected_tail_pressure.py@@ -20,7 +20,6 @@ import pytestfrom agent.context_compressor import (ContextCompressor,- _INFLIGHT_TASK_REPLAY_HEADER,_MAX_TAIL_MESSAGE_FLOOR,_PRESSURE_KEEP_RECENT_MESSAGES,_tool_content_has_images,@@ -318,44 +317,3 @@ def test_compaction_keeps_four_images_in_a_spared_pending_round(compressor_128k)results = {m["tool_call_id"]: m for m in out if m.get("role") == "tool"}assert [_tool_content_has_images(results[call_id]["content"]) for call_id in pending_ids] == [True] * 4assert not _tool_content_has_images(results["old"]["content"])---def _single_prompt_pending_image_round(*, oversized: bool = False) -> tuple[list[dict], list[str]]:- pending_ids = [f"new_{i}" for i in range(4)]- msgs = [- {"role": "system", "content": "You are Hermes."},- {"role": "user", "content": "Inspect the images and report."},- ]- for i in range(30):- msgs.extend(_unique_tool_pair(i, 12_000))- results = [_image_result(call_id) for call_id in pending_ids]- if oversized:- results[-1]["content"][0]["text"] = "X" * 120_000- msgs.extend([- {"role": "assistant", "content": None, "tool_calls": [_image_call(call_id) for call_id in pending_ids]},- *results,- ])- return msgs, pending_ids---def test_compaction_keeps_pending_images_before_replaying_the_head_task(compressor_128k):- compressor_128k.protect_first_n = 1- msgs, pending_ids = _single_prompt_pending_image_round()-- out = compressor_128k.compress(msgs, current_tokens=estimate_messages_tokens_rough(msgs))-- assert out[-1]["role"] == "user"- assert _INFLIGHT_TASK_REPLAY_HEADER in out[-1]["content"]- results = {m["tool_call_id"]: m for m in out if m.get("role") == "tool"}- assert [_tool_content_has_images(results[call_id]["content"]) for call_id in pending_ids] == [True] * 4---def test_compaction_retires_old_images_in_oversized_pending_round(compressor_128k):- compressor_128k.protect_first_n = 1- msgs, pending_ids = _single_prompt_pending_image_round(oversized=True)-- out = compressor_128k.compress(msgs, current_tokens=estimate_messages_tokens_rough(msgs))-- results = {m["tool_call_id"]: m for m in out if m.get("role") == "tool"}- assert all(call_id in results for call_id in pending_ids)- assert not any(_tool_content_has_images(results[call_id]["content"]) for call_id in pending_ids[:3])