From ed3562bbbcd8a5323be96b81812291faae99e010 Mon Sep 17 00:00:00 2001 From: Teknium <127238744+teknium1@users.noreply.github.com> Date: Sun, 30 Aug 2026 18:25:29 -0700 Subject: [PATCH] test(compression): drop moot digest-loop tests; match stamped backoff errors MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit PR #98628 removed _build_chunk_digests, so the two lean chunk-digest cancellation tests reintroduced by the #97512 cherry-pick target a deleted mechanism — removed. The #96775 stall-interrupt assertions now match the stall_interrupted marker inside the strategy/kind-stamped durable error instead of assuming it is the prefix. --- .../test_compression_stall_interrupt_96775.py | 6 +-- tests/agent/test_context_compressor.py | 54 ------------------- 2 files changed, 3 insertions(+), 57 deletions(-) diff --git a/tests/agent/test_compression_stall_interrupt_96775.py b/tests/agent/test_compression_stall_interrupt_96775.py index 2f29535ae3..efbba7d853 100644 --- a/tests/agent/test_compression_stall_interrupt_96775.py +++ b/tests/agent/test_compression_stall_interrupt_96775.py @@ -171,7 +171,7 @@ class TestStallInterruptedBackoff: assert db.get_compression_lock_holder("STALL_AUX_CANCEL") is None state = db.get_compression_failure_cooldown("STALL_AUX_CANCEL") assert state is not None - assert str(state["error"]).startswith(STALL_INTERRUPTED_FAILURE_CLASS) + assert STALL_INTERRUPTED_FAILURE_CLASS in str(state["error"]) assert "msgs=20" in str(state["error"]) assert agent.context_compressor.should_compress(50_000) is False @@ -222,7 +222,7 @@ class TestStallInterruptedBackoff: assert live == original state = db.get_compression_failure_cooldown("STALL_FENCE_CANCEL") assert state is not None - assert str(state["error"]).startswith(STALL_INTERRUPTED_FAILURE_CLASS) + assert STALL_INTERRUPTED_FAILURE_CLASS in str(state["error"]) assert agent.context_compressor.should_compress(50_000) is False db.append_message("STALL_FENCE_CANCEL", "user", "next turn") @@ -339,7 +339,7 @@ class TestStallInterruptedBackoff: after = db.get_compression_failure_cooldown("MERGE_MAX_STALL") assert after is not None assert float(after["cooldown_until"]) >= prior_until - 1.0 - assert str(after["error"]).startswith(STALL_INTERRUPTED_FAILURE_CLASS) + assert STALL_INTERRUPTED_FAILURE_CLASS in str(after["error"]) def test_session_db_cooldown_write_does_not_shorten_longer_deadline( diff --git a/tests/agent/test_context_compressor.py b/tests/agent/test_context_compressor.py index 513819ef0c..ca99799361 100644 --- a/tests/agent/test_context_compressor.py +++ b/tests/agent/test_context_compressor.py @@ -26,60 +26,6 @@ class StubProviderError(Exception): self.response = response -def test_lean_chunk_digests_stop_after_host_cancellation(compressor, monkeypatch): - """A cancelled total-deadline candidate must not dispatch another digest.""" - import agent.context_compressor as context_compressor_module - - cancelled = False - calls = 0 - - def fake_call_llm(**_kwargs): - nonlocal cancelled, calls - calls += 1 - cancelled = True - return SimpleNamespace( - choices=[SimpleNamespace(message=SimpleNamespace(content="digest"))] - ) - - monkeypatch.setattr(context_compressor_module, "_LEAN_DIGEST_CHUNK_CHARS", 20) - monkeypatch.setattr(context_compressor_module, "_LEAN_DIGEST_MAX_CHUNKS", 8) - monkeypatch.setattr("agent.auxiliary_client.call_llm", fake_call_llm) - compressor._compression_cancelled_check = lambda: cancelled - - result = compressor._build_chunk_digests( - [{"role": "tool", "content": "x" * 200, "tool_call_id": "call-1"}] - ) - - assert calls == 1 - assert "Segment 2/" not in result - - -def test_lean_chunk_digests_do_not_start_after_deadline(compressor, monkeypatch): - """The shared compaction deadline is checked before the first digest.""" - import agent.context_compressor as context_compressor_module - from agent.conversation_compression import CompressionCommitFence - - calls = 0 - - def fake_call_llm(**_kwargs): - nonlocal calls - calls += 1 - raise AssertionError("digest request started after total deadline") - - fence = CompressionCommitFence(total_ceiling_seconds=1.0) - compressor._compression_cancelled_check = lambda: fence.is_cancelled - monkeypatch.setattr("agent.auxiliary_client.call_llm", fake_call_llm) - - with patch( - "agent.conversation_compression.time.monotonic", - return_value=time.monotonic() + 2.0, - ): - assert compressor._build_chunk_digests( - [{"role": "user", "content": "late digest"}] - ) == "" - assert calls == 0 - - @pytest.fixture() def compressor(): """Create a ContextCompressor with mocked dependencies."""