The agent that grows with you
Python aiai-agentai-agentsanthropicchatgptclaudeclaude-codecodexhermeshermes-agentllmnous-researchopenai
test(compaction): trim bench tests to the two invariants
kshitijk4poor5c9a76a9cdc4
diff --git a/tests/agent/test_context_compressor.py b/tests/agent/test_context_compressor.pyindex 74463168588..a4c8af39846 100644--- a/tests/agent/test_context_compressor.py+++ b/tests/agent/test_context_compressor.py@@ -3685,78 +3685,6 @@ class TestPreLlmFeasibilityCheck:mock_gen.assert_called_once()assert compressor._prellm_skip_count == 0- def test_fallback_streak_benches_summary_model_but_keeps_compacting(self, compressor):- """Two fallbacks in a row stop the summary calls (#63008), not the compaction itself:- the window is still dropped, and one probe per recovery window can heal the streak."""- compressor._fallback_compression_streak = 2- msgs = self._make_messages()-- with patch.object(compressor, "_generate_summary", return_value="LLM summary") as mock_gen:- benched = compressor.compress(msgs, force=False)- mock_gen.assert_not_called()- assert len(benched) < len(msgs)- assert compressor._last_feasibility_skip is True # recorded streak-neutral-- compressor._fallback_probe_at = time.time() - 1 # recovery window elapsed- compressor.compress(self._make_messages(), force=False)- mock_gen.assert_called_once()-- @staticmethod- def _record_boundary(compressor):- """Mirror the boundary wrapper's bookkeeping (agent/conversation_compression.py)."""- compressor.record_completed_compaction(- used_fallback=compressor._last_summary_fallback_used,- feasibility_skip=compressor._last_feasibility_skip,- )-- def test_fresh_compressor_with_a_streak_benches_and_arms_a_full_window(self, compressor):- """A compressor that comes up with a persisted streak (restart, session rotation) has no- probe clock: it benches the summary model and starts a full window, it does not probe at once."""- compressor._fallback_compression_streak = 2- assert compressor._fallback_probe_at == 0.0- before = time.monotonic()-- with patch.object(compressor, "_generate_summary", return_value="LLM summary") as mock_gen:- compressor.compress(self._make_messages(), force=False)-- mock_gen.assert_not_called()- assert compressor._fallback_probe_at >= before + compressor._ANTI_THRASH_RECOVERY_SECONDS-- def test_healthy_probe_resets_the_streak(self, compressor):- """A bench leaves the streak alone; the probe after the recovery window is a normal summary- attempt, so a healthy summary resets it."""- compressor._fallback_compression_streak = 2-- with patch.object(compressor, "_generate_summary", return_value="LLM summary") as mock_gen:- compressor.compress(self._make_messages(), force=False) # benched- self._record_boundary(compressor)- assert compressor._fallback_compression_streak == 2 # a bench is streak-neutral-- compressor._fallback_probe_at = time.time() - 1 # recovery window elapsed- compressor.compress(self._make_messages(), force=False) # probe- self._record_boundary(compressor)-- mock_gen.assert_called_once()- assert compressor._fallback_compression_streak == 0-- def test_failed_probe_benches_again_for_another_window(self, compressor):- """One probe per recovery window: a probe whose summary fails again counts as a fallback- and benches the summary model for another full window."""- compressor._fallback_compression_streak = 2- compressor._fallback_probe_at = time.time() - 1 # recovery window elapsed-- with patch.object(compressor, "_generate_summary", return_value=None) as mock_gen:- compressor.compress(self._make_messages(), force=False) # probe, summary fails- self._record_boundary(compressor)- assert mock_gen.call_count == 1- assert compressor._fallback_compression_streak == 3-- before = time.monotonic()- compressor.compress(self._make_messages(), force=False) # benched again-- assert mock_gen.call_count == 1- assert compressor._fallback_probe_at >= before + compressor._ANTI_THRASH_RECOVERY_SECONDS-def test_bench_probe_deadline_survives_a_compressor_rebuild(self, compressor, tmp_path):"""The gateway rebuilds the agent on cache eviction: a fresh compressor bound to the samesession must resume the persisted bench window, not restart it (else the probe starves)."""@@ -3781,16 +3709,6 @@ class TestPreLlmFeasibilityCheck:rebuilt.compress(self._make_messages(), force=False)mock_gen.assert_called_once()- def test_skip_count_resets_on_session_reset(self, compressor):- """_prellm_skip_count must reset alongside _ineffective_compression_count."""- compressor._prellm_skip_count = 5- compressor._ineffective_compression_count = 2-- compressor.bind_session_state() # a new session row-- assert compressor._prellm_skip_count == 0- assert compressor._ineffective_compression_count == 0-def test_skip_fires_on_fat_tail_small_middle(self, compressor):"""The target scenario from #60451: a tool-heavy transcript whoseprotected tail already holds most of the tokens, leaving a tiny