Skip to content

The agent that grows with you

fix(compression): log one attempt record when an engine returns an empty transcript

mnajafian-nv7ae7fac09c03
diff --git a/agent/conversation_compression.py b/agent/conversation_compression.py
index 421b4907904..96683570994 100644
--- a/agent/conversation_compression.py
+++ b/agent/conversation_compression.py
@@ -3575,6 +3575,7 @@ def _candidate_rejected(
agent._emit_warning(
"⚠ Compression returned an empty transcript. No session split was performed; conversation continues unchanged."
)
+ _emit_aborted_attempt_telemetry(agent, attempt.started_at, "empty_transcript", attempt.seed)
return True
# A newer WORKING attempt supersedes us; discard the late candidate. No-op
diff --git a/tests/agent/test_compression_attempt_effect.py b/tests/agent/test_compression_attempt_effect.py
index 26f71c99065..d5d57674c16 100644
--- a/tests/agent/test_compression_attempt_effect.py
+++ b/tests/agent/test_compression_attempt_effect.py
@@ -378,3 +378,20 @@ def test_session_backed_commit_keeps_the_attempts_own_record(caplog, tmp_path, m
assert record["session_id"] == "db-session"
assert (record["trigger_source"], record["method"]) == ("pre_api", "llm_summary")
assert record["tokens_after"] is not None and record["middle_window_tokens"] is not None
+
+
+def test_engine_that_returns_an_empty_transcript_logs_one_aborted_record(caplog, shared_metric_rows):
+ """An engine that hands back no messages for a non-empty transcript is refused before any split, and the
+ attempt still logs its one record and counts once."""
+ agent = _Agent(_compressor())
+ messages = _messages()
+
+ with patch.object(agent.context_compressor, "compress", return_value=[]):
+ with caplog.at_level(logging.INFO, logger="agent.conversation_compression"):
+ compressed, _ = compress_context(agent, messages, "system prompt", approx_tokens=80_000, trigger="pre_api")
+
+ assert compressed == _messages()
+ [record] = _attempt_records(caplog)
+ assert (record["commit_status"], record["failure_class"]) == ("aborted", "empty_transcript")
+ assert (record["trigger_source"], record["method"]) == ("pre_api", "none")
+ assert [(row["outcome"], row["failure_class"]) for row in shared_metric_rows] == [("failed", "other")]
diff --git a/website/docs/developer-guide/context-compression-and-caching.md b/website/docs/developer-guide/context-compression-and-caching.md
index fe21c32a618..1ca45a7c2e5 100644
--- a/website/docs/developer-guide/context-compression-and-caching.md
+++ b/website/docs/developer-guide/context-compression-and-caching.md
@@ -246,7 +246,8 @@ text, the focus topic or error messages.
`blocked:ineffective`). Under the session lease, `session_ownership_lost`
(`skipped`) means another path already rotated the session, and
`session_ownership_unreadable` / `cooldown_state_unreadable` (`aborted`)
- mean that state could not be read.
+ mean that state could not be read. `empty_transcript` (`aborted`) means the
+ engine returned no messages, so nothing was committed.
- `attempt_id` names this attempt and `session_id` the session it started
in, even when the attempt then adopts a rotated child session or unwinds
after a newer attempt (a stall fallback) has begun. An attempt