The agent that grows with you
Python aiai-agentai-agentsanthropicchatgptclaudeclaude-codecodexhermeshermes-agentllmnous-researchopenai
fix(compression): emit aborted telemetry on stale manual snapshot
kshitijk4poorc9d0d5fef83e
diff --git a/agent/conversation_compression.py b/agent/conversation_compression.pyindex 8f09386a5f4..112f12a4456 100644--- a/agent/conversation_compression.py+++ b/agent/conversation_compression.py@@ -4159,6 +4159,7 @@ def compress_context(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)except BaseException:diff --git a/tests/tui_gateway/test_manual_compress_history_fence.py b/tests/tui_gateway/test_manual_compress_history_fence.pyindex 11c3e406243..93dc1010296 100644--- a/tests/tui_gateway/test_manual_compress_history_fence.py+++ b/tests/tui_gateway/test_manual_compress_history_fence.py@@ -1,4 +1,5 @@"""Manual compression must not publish a snapshot invalidated before lease admission."""+import loggingimport threadingfrom unittest.mock import MagicMock@@ -10,7 +11,7 @@ import pytest("", False), ("", True), ("", "validation_error"), ("here 2", True),])def test_manual_compress_rejects_history_rewritten_before_admission(- tmp_path, monkeypatch, stale, in_place, compress_args,+ tmp_path, monkeypatch, caplog, stale, in_place, compress_args,):from hermes_state import SessionDBfrom run_agent import AIAgent@@ -71,9 +72,10 @@ def test_manual_compress_rejects_history_rewritten_before_admission(assert agent.session_id == parentassert db.get_messages_as_conversation(parent) == beforereturn- removed, _ = server._compress_session_history(- session, focus_topic=compress_args, before_messages=before, history_version=1,- )+ with caplog.at_level(logging.INFO, logger="agent.conversation_compression"):+ removed, _ = server._compress_session_history(+ session, focus_topic=compress_args, before_messages=before, history_version=1,+ )assert db.get_compression_lock_holder(parent) is Noneif stale is True:assert removed == 0@@ -83,6 +85,7 @@ def test_manual_compress_rejects_history_rewritten_before_admission(assert [m["content"] for m in db.get_messages_as_conversation(parent)] == ["edited question", "edited answer"]assert session["history"] == replacement+ assert '"failure_class":"snapshot_stale"' in caplog.textelse:assert removed > 0assert (agent.session_id == parent) is in_place