Skip to content

The agent that grows with you

review follow-up: trim overreaching comment sentence, pin durable-copy assertion

kshitijk4poor4a6b362178ab
diff --git a/agent/conversation_compression.py b/agent/conversation_compression.py
index 3d4b220d4db..90f3b5e879d 100644
--- a/agent/conversation_compression.py
+++ b/agent/conversation_compression.py
@@ -3471,8 +3471,7 @@ def compress_context(
# The durable copy was never cleared (that clear only rides
# the archive_and_compact / child-row commit that never
# ran), so restoring the snapshot re-aligns memory with
- # disk. When compress() aborted before its tail, snapshot
- # and current value are identical and this is a no-op.
+ # disk.
if "_proactive_prune_rearm_tokens" in _compressor_attempt_snapshot:
agent.context_compressor._proactive_prune_rearm_tokens = (
_compressor_attempt_snapshot[
diff --git a/tests/agent/test_would_grow_refusal_runway.py b/tests/agent/test_would_grow_refusal_runway.py
index 480577f42fd..58bdf9e0c83 100644
--- a/tests/agent/test_would_grow_refusal_runway.py
+++ b/tests/agent/test_would_grow_refusal_runway.py
@@ -57,6 +57,12 @@ def test_would_grow_refusal_restores_prune_runway(tmp_path: Path) -> None:
compressor = agent.context_compressor
armed_runway = 250_000
compressor._proactive_prune_rearm_tokens = armed_runway
+ # Arm the durable copy too, exactly as a committed prune would have
+ # (prune_tool_results_only persists it via archive_and_compact's
+ # model_config_patch) — the refusal must leave it untouched.
+ db.patch_session_model_config(
+ session_id, {"_proactive_prune_rearm_tokens": armed_runway}
+ )
messages = [{"role": "user", "content": f"m{i} " + "x" * 200} for i in range(10)]
@@ -78,5 +84,11 @@ def test_would_grow_refusal_restores_prune_runway(tmp_path: Path) -> None:
# The runway must survive the refusal — memory re-aligned with the
# (never-cleared) durable copy, keeping the #79640 throttle armed.
assert compressor._proactive_prune_rearm_tokens == armed_runway
+ assert (
+ db.get_session_model_config_value(
+ session_id, "_proactive_prune_rearm_tokens", 0
+ )
+ == armed_runway
+ )
# And the compression lock must not leak.
assert db.get_compression_lock_holder(session_id) is None