-
Notifications
You must be signed in to change notification settings - Fork 2.7k
structured compaction prompt for session summarization #2389
Copy link
Copy link
Open
Labels
deepagentsRelated to the `deepagents` SDK / agent harnessRelated to the `deepagents` SDK / agent harnessexternalUser is not a member of the `langchain-ai` GitHub organizationUser is not a member of the `langchain-ai` GitHub organization
Description
Checked other resources
- This is a feature request, not a bug report.
- I searched existing issues and didn't find this feature.
- I checked the docs and README for existing functionality.
- This request applies to this repo (deepagents) and not an external package.
Area (Required)
- deepagents (SDK)
- cli
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
Reactions are currently unavailable
Metadata
Metadata
Assignees
Labels
deepagentsRelated to the `deepagents` SDK / agent harnessRelated to the `deepagents` SDK / agent harnessexternalUser is not a member of the `langchain-ai` GitHub organizationUser is not a member of the `langchain-ai` GitHub organization