Checked other resources
Area (Required)
Feature description
The current SummarizationMiddleware uses a generic LLM prompt to summarize conversations during context window compaction. This produces unstructured summaries that lose critical technical context — file paths, code snippets, error history, user feedback, and pending tasks — making it difficult for the agent to resume work accurately in long sessions.
Proposed solution (optional)
Replace the default summarization prompt with a structured 9-section compaction prompt that guides the LLM to systematically preserve:
- Primary Request and Intent
- Key Technical Concepts
- Files and Code Sections (with code snippets)
- Errors and Fixes (with user feedback)
- Problem Solving
- All User Messages (non-tool-result)
- Pending Tasks
- Current Work
- Optional Next Step
Additionally, update the post-compaction continuation message to:
- Include a transcript path reference for retrieving pre-compaction details
- Add a direct resume instruction so the agent picks up exactly where it left off without recapping
The LLM is also instructed to use an scratchpad block for internal reasoning, which is stripped from the final summary to save tokens while improving summary quality.
Additional context (optional)
- Long coding sessions (20+ turns) frequently trigger compaction, and the current generic summary loses context that is essential for continuing development work
- The structured prompt ensures the LLM covers all critical dimensions systematically rather than producing a freeform summary
- The continuation message format enables seamless session resumption
- Backward-compatible: callers who provide a custom summary_prompt are unaffected
Checked other resources
Area (Required)
Feature description
The current SummarizationMiddleware uses a generic LLM prompt to summarize conversations during context window compaction. This produces unstructured summaries that lose critical technical context — file paths, code snippets, error history, user feedback, and pending tasks — making it difficult for the agent to resume work accurately in long sessions.
Proposed solution (optional)
Replace the default summarization prompt with a structured 9-section compaction prompt that guides the LLM to systematically preserve:
Additionally, update the post-compaction continuation message to:
The LLM is also instructed to use an scratchpad block for internal reasoning, which is stripped from the final summary to save tokens while improving summary quality.
Additional context (optional)