From 8fe8fe9920b304521e5468c294ef4e0f75928fc4 Mon Sep 17 00:00:00 2001 From: Mario Zechner Date: Mon, 29 Dec 2025 22:45:29 +0100 Subject: [PATCH] Add preamble to branch summary for context Prepends: 'The user explored a different conversation branch before returning here. Summary of that exploration:' This helps the LLM understand the summary is background context from a different path, not the current thread being continued. --- .../src/core/compaction/branch-summarization.ts | 8 ++++++++ 1 file changed, 8 insertions(+) diff --git a/packages/coding-agent/src/core/compaction/branch-summarization.ts b/packages/coding-agent/src/core/compaction/branch-summarization.ts index 608c968b..132fd2ec 100644 --- a/packages/coding-agent/src/core/compaction/branch-summarization.ts +++ b/packages/coding-agent/src/core/compaction/branch-summarization.ts @@ -265,6 +265,11 @@ export function prepareBranchEntries(entries: SessionEntry[], tokenBudget: numbe // Summary Generation // ============================================================================ +const BRANCH_SUMMARY_PREAMBLE = `The user explored a different conversation branch before returning here. +Summary of that exploration: + +`; + const BRANCH_SUMMARY_PROMPT = `Create a structured summary of this conversation branch for context when returning later. Use this EXACT format: @@ -348,6 +353,9 @@ export async function generateBranchSummary( .map((c) => c.text) .join("\n"); + // Prepend preamble to provide context about the branch summary + summary = BRANCH_SUMMARY_PREAMBLE + summary; + // Compute file lists const modified = new Set([...fileOps.edited, ...fileOps.written]); const readOnly = [...fileOps.read].filter((f) => !modified.has(f)).sort();