The agent that grows with you
Python aiai-agentai-agentsanthropicchatgptclaudeclaude-codecodexhermeshermes-agentllmnous-researchopenai
fix(compression): match legacy clarify notices by producer shape
unsupportedpastelsddc55890f02f
diff --git a/agent/context_compressor.py b/agent/context_compressor.pyindex 554c5822069..3b29d3ca1c0 100644--- a/agent/context_compressor.py+++ b/agent/context_compressor.py@@ -1726,8 +1726,19 @@ _CLARIFY_NON_RESPONSE_PREFIXES = ("[user did not respond", # gateway clarify delivery timeout"[clarify prompt could not be delivered", # gateway UNDELIVERED*"[oneshot mode:", # hermes_cli/oneshot.py- "The user cancelled", # classic CLI Ctrl+C+ "[single-query mode: no user available", # hermes chat -q headless callback)+# Matched whole: as a prefix these would also swallow real answers that start the same way.+_CLARIFY_NON_RESPONSE_TEXTS = (+ "The user cancelled. Use your best judgement to proceed.", # classic CLI Ctrl+C+)+++def _is_clarify_non_response(item) -> bool:+ if not isinstance(item, str):+ return False+ text = item.strip()+ return text in _CLARIFY_NON_RESPONSE_TEXTS or text.startswith(_CLARIFY_NON_RESPONSE_PREFIXES)def _sum_clarify(name, args, content, content_len, line_count):@@ -1751,11 +1762,9 @@ def _sum_clarify(name, args, content, content_len, line_count):values = value if isinstance(value, list) else [value]# Pre-status sessions also stored timeout/delivery notices as user_response.# Only those legacy records need the old sentinel check; explicit status wins.- if "status" not in entry and any(- isinstance(item, str) and item.lstrip().startswith(_CLARIFY_NON_RESPONSE_PREFIXES)- for item in values- ):- continue+ # Drop just the notice items so other selections in the same entry survive.+ if "status" not in entry:+ values = [item for item in values if not _is_clarify_non_response(item)]answers.extend(values)answers = [answer for answer in answers if isinstance(answer, str) and answer]if not answers:diff --git a/tests/agent/test_context_compressor.py b/tests/agent/test_context_compressor.pyindex 908b200b712..ad371dd180b 100644--- a/tests/agent/test_context_compressor.py+++ b/tests/agent/test_context_compressor.py@@ -53,7 +53,8 @@ def compressor():class TestLegacyClarifyResults:@pytest.mark.parametrize("shape", ["single", "batch", "current"])@pytest.mark.parametrize("question_size", [300, 4500])- @pytest.mark.parametrize("answer", ["production, but only after 18:00 UTC", ["staging", "production"]])+ @pytest.mark.parametrize("answer", ["production, but only after 18:00 UTC", ["staging", "production"],+ "The user cancelled the production rollout; do not restart it."])def test_answers_reach_summary_after_repeated_pruning(self, monkeypatch, shape, question_size, answer):import agent.context_compressor as module@@ -100,12 +101,16 @@ class TestLegacyClarifyResults:"[clarify prompt could not be delivered]","[oneshot mode: no user available]","The user cancelled. Use your best judgement to proceed.",+ "[single-query mode: no user available to answer 'Deploy?'. "+ "Make the most reasonable assumption you can and continue.]",])def test_legacy_sentinels_are_not_answers_but_explicit_status_is_authoritative(self, sentinel):- for value in (sentinel, ["production", " " + sentinel]):+ for value, kept in ((sentinel, None), (["production", " " + sentinel], "production")):for payload in ({"user_response": value}, {"responses": [{"user_response": value}]}):content = json.dumps(payload)- assert not _sum_clarify("clarify", {}, content, len(content), 1).startswith("[clarify] user responded:")+ summary = _sum_clarify("clarify", {}, content, len(content), 1)+ assert sentinel.strip() not in summary+ assert summary == (f'[clarify] user responded: "{kept}"' if kept else "[clarify] asked user a question")for status in ("answered", "skipped", "unanswered"):content = json.dumps({"responses": [{"status": status, "user_response": sentinel}]})summary = _sum_clarify("clarify", {}, content, len(content), 1)