Skip to content

Commit 53bfbf7

Browse files
authored
fix(chatd): improve compaction prompt to preserve forward momentum (coder#22989)
## Problem The summarization prompt explicitly tells the model to **"Omit pleasantries and next-step suggestions"** and the summary prefix frames the compacted context as passive history: `Summary of earlier chat context:`. After compaction mid-task, the model reads a factual recap with no forward momentum, loses its direction, and either stops or asks the user what to do. ## Research I compared our compaction prompt against several other agents: | Agent | Key Pattern | |---|---| | **Codex** | Prompt says *"Include what remains to be done (clear next steps)"*. Prefix: *"Another language model started to solve this problem..."* | | **Mux** | Includes *"Current state of the work (what's done, what's in progress)"* + appends the user's follow-up intent | | **Continue** | *"Make sure it is clear what the current stream of work was at the very end prior to compaction so that you can continue exactly where you left off"* | | **Copilot Chat** | Dedicated sections for *Active Work State*, *Recent Operations*, *Pre-Summary State*, and a *Continuation Plan* with explicit next actions | **Every other major agent explicitly preserves forward intent and in-progress state.** Coder was the only one telling the model to omit next steps. ## Changes **Summary prompt:** - Removes `Omit next-step suggestions` - Adds structured `Include:` list with explicit items for in-progress work, remaining work, and the specific action being performed when compaction fired - Frames the operation as `context compaction` (matching Codex's framing) **Summary prefix:** - Old: `Summary of earlier chat context:` - New: `The following is a summary of the earlier conversation. The assistant was actively working when the context was compacted. Continue the work described below:` The prefix is the first thing the model reads post-compaction — framing it as an active handoff with an explicit "Continue" directive primes the model to resume work rather than wait.
1 parent c7abfc6 commit 53bfbf7

1 file changed

Lines changed: 20 additions & 7 deletions

File tree

coderd/chatd/chatloop/compaction.go

Lines changed: 20 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -17,13 +17,26 @@ const (
1717
minCompactionThresholdPercent = int32(0)
1818
maxCompactionThresholdPercent = int32(100)
1919

20-
defaultCompactionSummaryPrompt = "Summarize the current chat so a " +
21-
"new assistant can continue seamlessly. Include the user's goals, " +
22-
"decisions made, concrete technical details (files, commands, APIs), " +
23-
"errors encountered and fixes, and open questions. Be dense and factual. " +
24-
"Omit pleasantries and next-step suggestions."
25-
defaultCompactionSystemSummaryPrefix = "Summary of earlier chat context:"
26-
defaultCompactionTimeout = 90 * time.Second
20+
defaultCompactionSummaryPrompt = "You are performing a context compaction. " +
21+
"Summarize the conversation so a new assistant can seamlessly " +
22+
"continue the work in progress.\n\n" +
23+
"Include:\n" +
24+
"- The user's overall goal and current task\n" +
25+
"- Key decisions made and their rationale\n" +
26+
"- Concrete technical details: file paths, function names, " +
27+
"commands, APIs, and configurations\n" +
28+
"- Errors encountered and how they were resolved\n" +
29+
"- Current state of the work: what is DONE, what is IN PROGRESS, " +
30+
"and what REMAINS to be done\n" +
31+
"- The specific action the assistant was performing or about to " +
32+
"perform when this summary was triggered\n\n" +
33+
"Be dense and factual. Every sentence should convey essential " +
34+
"context for continuation. Do not include pleasantries or " +
35+
"conversational filler."
36+
defaultCompactionSystemSummaryPrefix = "The following is a summary of " +
37+
"the earlier conversation. The assistant was actively working when " +
38+
"the context was compacted. Continue the work described below:"
39+
defaultCompactionTimeout = 90 * time.Second
2740
)
2841

2942
type CompactionOptions struct {

0 commit comments

Comments
 (0)