Skip to content

The agent that grows with you

fix(compaction): carry the bench probe deadline across rotating compaction

kshitijk4poor364319d9566d
diff --git a/agent/context_compressor.py b/agent/context_compressor.py
index 07c77f5f814..0b6426c2487 100644
--- a/agent/context_compressor.py
+++ b/agent/context_compressor.py
@@ -2445,6 +2445,7 @@ class ContextCompressor(SummaryDispatchMixin, PreLlmSkipMixin, MicroCompactionMi
previous_fallback_streak = self._fallback_compression_streak
previous_ineffective_count = self._ineffective_compression_count
previous_overload_aborts = self._consecutive_overload_aborts
+ previous_probe_at = self._fallback_probe_at
if boundary_reason == "compression" and old_session_id:
# Parent row carries the streak/strike state across the rotation.
def _parent(method: str, label: str, current: int) -> int:
@@ -2464,6 +2465,8 @@ class ContextCompressor(SummaryDispatchMixin, PreLlmSkipMixin, MicroCompactionMi
if boundary_reason == "compression":
# Rotation creates a fresh child row first; carry the streak until boundary bookkeeping persists it.
self._fallback_compression_streak = previous_fallback_streak
+ # The bench probe deadline lives in the model-config blob, which the child row lacks.
+ self._set_fallback_probe_at(previous_probe_at)
# No later bookkeeping writes the strike counter, so persist it onto the child row now (#54923).
if self._ineffective_compression_count != previous_ineffective_count:
self._ineffective_compression_count = previous_ineffective_count
diff --git a/tests/agent/test_context_compressor_bench_probe.py b/tests/agent/test_context_compressor_bench_probe.py
index f9227397e25..4523d41b45c 100644
--- a/tests/agent/test_context_compressor_bench_probe.py
+++ b/tests/agent/test_context_compressor_bench_probe.py
@@ -41,3 +41,14 @@ def test_bench_probe_deadline_survives_a_compressor_rebuild(tmp_path):
patch.object(rebuilt, "_generate_summary", return_value="LLM summary") as mock_gen:
rebuilt.compress(_messages(), force=False)
mock_gen.assert_called_once()
+
+ # Rotating compaction (in_place: false) binds a fresh child row: the deadline must follow it.
+ with patch("agent.context_compressor.time.time", return_value=2000.0), \
+ patch.object(rebuilt, "_generate_summary", return_value="LLM summary"):
+ rebuilt.compress(_messages(), force=False) # benched again, re-arms the window
+ db.create_session("s2", "cli", parent_session_id="s1")
+ rebuilt.on_session_start("s2", boundary_reason="compression", old_session_id="s1", session_db=db)
+ with patch("agent.context_compressor.time.time", return_value=2000.0 + window + 1), \
+ patch.object(rebuilt, "_generate_summary", return_value="LLM summary") as mock_gen:
+ rebuilt.compress(_messages(), force=False)
+ mock_gen.assert_called_once()