Auto-Compact
Automatically summarize long conversations to stay within context limits.
Auto-Compact
Long conversations eventually exceed the modelโs context window. Auto-compact automatically summarizes conversations to stay within limits.
Why Auto-Compact?
Every AI model has a context limit, for example:
| Model | Context Window |
|---|---|
| GPT-5.2 | 400K tokens |
| Claude Sonnet 4.6 | 200K tokens |
| gemini-2.5-flash | 1M tokens |
When you approach this limit:
- New messages may fail
- Older context is lost
- Responses become less coherent
Auto-compact solves this by:
- Detecting when youโre near the limit
- Generating a summary of the conversation
- Marking older messages as compacted
- Appending the summary to continue fresh
How It Works
Auto-compact uses a non-destructive approach:
-
Summarize Phase: Your conversation is sent to the AI with a special prompt to generate a comprehensive summary capturing key points, decisions, and context.
-
Tag Phase: Existing messages are marked with a
condenseParentflag (they remain in history but are visually compacted). -
Append Phase: A new summary message is appended to the conversation, allowing you to continue with a fresh context window.
What Gets Summarized
- All messages in the current conversation
- Tool calls and results
- Code snippets and decisions
Whatโs Preserved
- All original messages (non-destructive)
- System prompt
- Conversation history
Configuration
Enable Auto-Compact
- Open Settings
- Find Auto Compact section
- Toggle Enable Auto Compact
Threshold
The threshold slider (50% - 95%) determines when compact triggers:
| Threshold | Behavior |
|---|---|
| 50-70% | More frequent compaction |
| 90% | Balanced (default, recommended) |
| 95% | Compact only when nearly full |
Context Window
The context window is auto-detected from your provider, but you can override it in Provider Settings:
- Open Settings โ Providers
- Find Context Window field
- Enter your modelโs token limit (e.g.,
128000for GPT-4o)
This affects when auto-compact triggers โ if set incorrectly, compact may trigger too early or too late.
Custom Summary Prompt
Customize how summaries are generated by editing the prompt textarea. Leave empty to use the default prompt.
The default prompt asks the AI to produce a structured summary including:
- Primary request and intent
- Key concepts discussed
- Files, code, and data
- Errors and fixes
- Pending tasks
- Current work and next steps
Manual Compact
Trigger compact manually with the slash command:
/compact
This is useful when:
- You want to clean up before a long message
- Youโre preparing to branch
- The conversation feels bloated
Usage Indicator
When youโre within 15% of the threshold, a warning indicator appears above the input area:
- โค15% remaining: Gray indicator
- โค10% remaining: Yellow warning
- โค5% remaining: Red pulsing warning
Hover over the indicator to see exact token usage.
What Happens During Compact
When compact triggers:
- Indicator shows โCompactingโฆโ
- Conversation is sent to AI for summarization
- Summary is generated
- Messages tagged as compacted (non-destructive)
- Summary appended to conversation
- Conversation continues normally
Best Practices
Let It Run Automatically
- Donโt manually compact too often
- Trust the threshold setting
- Only manual compact when necessary
Review Summaries
After compact, check the summary:
- Ensure key points are captured
- Add important details if missed
Branch Before Compact
If you want to preserve full context:
- Branch the conversation
- Compact the original
- Original has summary, branch has full history
Set Correct Context Window
For accurate auto-compact timing:
- Configure context window in Provider Settings
- Match it to your modelโs actual limit
- Default is 128K if not set
Troubleshooting
Compact triggers too often
- Increase the threshold (e.g., 95%)
- Check context window in Provider Settings matches your model
- Consider using a model with larger context
Compact not triggering
- Ensure auto-compact is enabled
- Check threshold isnโt too high
- Verify context window in Provider Settings is correct
Summaries missing key info
- Edit the custom summary prompt
- Add important context back manually
- Consider branching before compact
โCompactingโฆโ stuck
- Wait up to 30 seconds
- Check network connection
- Restart the sidebar if needed
Related
- Branching โ Preserve full context
- Memory System โ Persistent preferences
- Configuration โ All settings