From 59acbb69e458410f3334204bf4f1c5dc57dad8b3 Mon Sep 17 00:00:00 2001 From: Hemdan47 Date: Fri, 3 Jul 2026 00:23:29 +0300 Subject: [PATCH 1/2] fix: extract text from structured LLM responses in run summary MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Reasoning models return content as a list of typed blocks (thinking, text) instead of a plain string. The summarize_run function used str(content) which serialized the entire list including thinking blocks as a Python repr string — the user saw raw JSON with the LLM's internal reasoning instead of the summary text. If content is a list, extract only items with type "text" and join them. If content is a string, return it as-is. --- src/agent/services/run_summary/run_summary.py | 12 +++++++++++- 1 file changed, 11 insertions(+), 1 deletion(-) diff --git a/src/agent/services/run_summary/run_summary.py b/src/agent/services/run_summary/run_summary.py index 82ac191..fb8b398 100644 --- a/src/agent/services/run_summary/run_summary.py +++ b/src/agent/services/run_summary/run_summary.py @@ -33,4 +33,14 @@ def summarize_run(updates: list[str], llm: BaseChatModel) -> str | None: return None content = response.content - return content if isinstance(content, str) else str(content) + if isinstance(content, str): + return content + if isinstance(content, list): + parts = [] + for item in content: + if isinstance(item, dict) and item.get("type") == "text": + parts.append(str(item.get("text", ""))) + elif isinstance(item, str): + parts.append(item) + return "\n".join(parts) if parts else None + return str(content) From 5b64cf66143f381aaa7f79095b0d91f9ce0c79b4 Mon Sep 17 00:00:00 2001 From: Hemdan47 Date: Fri, 3 Jul 2026 00:30:51 +0300 Subject: [PATCH 2/2] feat: emphasize analyzer and researcher verification when in doubt Add verification rules to both planner and generator prompts covering both local and external facts. If there is even 1% doubt about any local project fact, command, script, or configuration, set needs_analysis=True and ask the analyzer. If there is even 1% doubt about any external fact, version, syntax, or best practice, set needs_web_research=True and ask the researcher. Always verify rather than guess. --- src/agent/graph/prompts/generator.py | 7 ++++++- src/agent/graph/prompts/planner.py | 16 ++++++++++++---- 2 files changed, 18 insertions(+), 5 deletions(-) diff --git a/src/agent/graph/prompts/generator.py b/src/agent/graph/prompts/generator.py index 51fe1a3..ecce904 100644 --- a/src/agent/graph/prompts/generator.py +++ b/src/agent/graph/prompts/generator.py @@ -8,7 +8,12 @@ configuration, set needs_analysis=True and ask the analyzer. It is always \ better to ask than to invent a command that does not exist. If you need \ current/external info (latest action versions, provider docs, version-specific \ -syntax), set needs_web_research=True and ask the researcher. +syntax), set needs_web_research=True and ask the researcher. \ +VERIFICATION RULE: If you have even 1% doubt about any external fact, \ +version, syntax, or best practice, set needs_web_research=True and verify. \ +If you have even 1% doubt about any local project fact, command, script, \ +or configuration, set needs_analysis=True and ask the analyzer. \ +It is always better to verify than to guess. RULES: 1. Follow the pipeline plan exactly. diff --git a/src/agent/graph/prompts/planner.py b/src/agent/graph/prompts/planner.py index 42d49d1..4d51d8f 100644 --- a/src/agent/graph/prompts/planner.py +++ b/src/agent/graph/prompts/planner.py @@ -24,7 +24,10 @@ 2. ANALYZE FIRST — If the user did not provide an explicit command, or the explicit command has already been executed and recorded in analyzer results, but you still don't know the project's language, build system, \ test runner, deployment target, or available scripts, set needs_analysis=True \ and ask ONE specific, targeted question via analyzer_query. \ - NEVER GUESS. NEVER ASSUME. Always ask the analyzer. + NEVER GUESS. NEVER ASSUME. Always ask the analyzer. \ + VERIFICATION RULE: If you have even 1% doubt about any local project fact, \ + command, script, or configuration, set needs_analysis=True and verify. \ + It is always better to verify than to guess. 2.1 ANALYZER QUERY FORMAT (STRICT) - By default, analyzer_query must be a semantic question, NOT a shell command. - Only use an exact command in analyzer_query when the user explicitly requested that exact command. @@ -38,13 +41,16 @@ 2.2 RESEARCHER RESULTS - If RESEARCHER RESULTS are present in context, use \ them as authoritative external facts. Do not re-request the same info. -2.3 DIRECT WEB RESEARCH - If YOU know the plan depends on current/external \ +2.3 DIRECT WEB RESEARCH — If YOU know the plan depends on current/external \ info (e.g. you want to use the latest action version, or need current \ provider syntax), set needs_web_research=True and pass a precise \ researcher_query. Use the analyzer for LOCAL project facts and the \ researcher for CURRENT external facts. WHENEVER you have ANY doubt about \ an external fact or syntax, ALWAYS make the follow-up researcher_query. \ - NEVER guess. + NEVER guess. \ + VERIFICATION RULE: If you have even 1% doubt about any external fact, \ + version, syntax, or best practice, set needs_web_research=True and verify. \ + It is always better to verify than to guess. 3 ASK USER ONLY FOR PREFERENCES - If the blocker is a user preference/tradeoff \ (not discoverable from files), set needs_human_input=True and ask ONE clear \ @@ -62,7 +68,9 @@ available scripts, you MUST do so before planning any build/test/lint/deploy \ steps. If the project has no test script, do NOT add a test step. If there \ is no deploy script or deployment config, do NOT add a deploy step. \ - WHEN IN DOUBT, QUERY THE ANALYZER. + WHEN IN DOUBT, QUERY THE ANALYZER. If you have even 1% doubt about whether \ + a tool, command, or script exists in the project, set needs_analysis=True. \ + It is always better to verify than to assume. BAD: Planning "Run unit tests" without verifying a test script exists GOOD: Asking the analyzer "What scripts are in package.json?" first