From 1d689d559c6e1830dadbd5e2f7e2d22f49005b9d Mon Sep 17 00:00:00 2001 From: Yuan Li Date: Wed, 30 Sep 2026 02:16:24 +0800 Subject: [PATCH] fix(compression): preserve legacy clarify answers (cherry picked from commit 12c70e699a1d44b43db7642e2012273d84cf031f) --- agent/context_compressor.py | 12 ++++++++++-- 1 file changed, 10 insertions(+), 2 deletions(-) diff --git a/agent/context_compressor.py b/agent/context_compressor.py index 53bad5bd9f..39ecead083 100644 --- a/agent/context_compressor.py +++ b/agent/context_compressor.py @@ -1724,10 +1724,18 @@ def _sum_clarify(name, args, content, content_len, line_count): # Strictly below _PRUNE_MIN_CHARS so the summary survives later prune passes via the # min_prune_chars guard and skips the >=200-char dedup. max_summary_chars = _PRUNE_MIN_CHARS - 1 - responses = _json_dict(content).get("responses") + payload = _json_dict(content) + responses = payload.get("responses") + if not isinstance(responses, list) and "user_response" in payload: + # Clarify results written before per-response status was introduced used + # the response fields directly on the top-level object. + responses = [payload] answers: list = [] for entry in responses if isinstance(responses, list) else (): - if isinstance(entry, dict) and entry.get("status") == "answered": + if isinstance(entry, dict) and ( + entry.get("status") == "answered" + or ("status" not in entry and "user_response" in entry) + ): value = entry.get("user_response") answers.extend(value if isinstance(value, list) else [value]) answers = [answer for answer in answers if isinstance(answer, str) and answer]