From 9dbf63f5d44780e9d6aae2d5e9e1c616692aecaa Mon Sep 17 00:00:00 2001 From: Umut Polat <52835619+umut-polat@users.noreply.github.com> Date: Fri, 13 Mar 2026 05:57:52 +0300 Subject: [PATCH] fix: prevent LLM from using tags in summary responses (#1345) The SDK agent's conversation history is heavily biased toward output. By the time a summarize prompt arrives, the in-context conditioning can cause the LLM to respond with tags instead of the expected tags. parseSummary() then returns null and the summary is silently lost. Two changes: - Add explicit mode-switch instructions at the top of the summary prompt telling the LLM not to use tags and that only output will be accepted - Add a warning log in parseSummary() when tags are found in a response that has no block, making the issue visible in logs instead of silently discarding Fixes #1312 Signed-off-by: umut-polat <52835619+umut-polat@users.noreply.github.com> --- src/sdk/parser.ts | 5 +++++ src/sdk/prompts.ts | 6 +++++- 2 files changed, 10 insertions(+), 1 deletion(-) diff --git a/src/sdk/parser.ts b/src/sdk/parser.ts index d9028dab..bfe09dd4 100644 --- a/src/sdk/parser.ts +++ b/src/sdk/parser.ts @@ -120,6 +120,11 @@ export function parseSummary(text: string, sessionId?: number): ParsedSummary | const summaryMatch = summaryRegex.exec(text); if (!summaryMatch) { + // Log when the response contains instead of + // to help diagnose prompt conditioning issues (see #1312) + if (//.test(text)) { + logger.warn('PARSER', 'Summary response contained tags instead of — prompt conditioning may need strengthening', { sessionId }); + } return null; } diff --git a/src/sdk/prompts.ts b/src/sdk/prompts.ts index 1cdb4127..774b86c7 100644 --- a/src/sdk/prompts.ts +++ b/src/sdk/prompts.ts @@ -130,7 +130,11 @@ export function buildSummaryPrompt(session: SDKSession, mode: ModeConfig): strin return ''; })(); - return `${mode.prompts.header_summary_checkpoint} + return `--- MODE SWITCH: PROGRESS SUMMARY --- +Do NOT output tags. This is a summary request, not an observation request. +Your response MUST use tags ONLY. Any output will be discarded. + +${mode.prompts.header_summary_checkpoint} ${mode.prompts.summary_instruction} ${mode.prompts.summary_context_label}