Skip to content

The agent that grows with you

refactor(compression): guard only the snapshot callback

kshitijk4poor641a0720206f
diff --git a/agent/conversation_compression.py b/agent/conversation_compression.py
index 112f12a4456..a1b410ab735 100644
--- a/agent/conversation_compression.py
+++ b/agent/conversation_compression.py
@@ -4158,13 +4158,14 @@ def compress_context(
# fence. If no durable lock was acquired there is no hook to publish.
lease.finish_lock_setup()
try:
- if snapshot_is_current is not None and not snapshot_is_current():
- _emit_aborted_attempt_telemetry(agent, attempt.started_at, "snapshot_stale")
- lease.release()
- return messages, _existing_system_prompt(agent, system_message)
+ current = snapshot_is_current is None or snapshot_is_current()
except BaseException:
lease.release()
raise
+ if not current:
+ _emit_aborted_attempt_telemetry(agent, attempt.started_at, "snapshot_stale")
+ lease.release()
+ return messages, _existing_system_prompt(agent, system_message)
_adopted = _adopt_if_parent_rotated(agent, lease, messages, system_message)
if _adopted is not None:
return _adopted