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 (or when the provider reports a context overflow)
- Generating a structured checkpoint of discarded history (goal, progress, next steps)
- Marking older messages as compacted (they stay in history)
- Continuing with the checkpoint plus recent messages kept verbatim
How It Works
Auto-compact is checkpoint-and-replay, not a wipe:
- Cut: Walk backward from the newest message until a keep-recent budget is filled. Cuts only at user or assistant messages, never a lone tool result.
- Summarize: A dedicated summarizer (no tools) writes Goal, Constraints, Progress, Decisions, Next Steps, and Critical Context. Later compacts update the previous checkpoint instead of replacing it.
- Rebuild: Active context is system prompt + checkpoint + the recent tail. Original messages remain stored.
If a request fails because the prompt was too large, BraceKit compact-and-retries once.
Configuration
Enable Auto-Compact
- Open Settings
- Find Auto Compact section
- Toggle Enable Auto Compact
Compact at / Keep recent
Sliders are percentages of the selected modelโs context window (not raw token counts). Defaults: compact at 87%, keep recent 16%.
Context Window
The context window comes from the selected model, not the whole provider. Built-in models use BraceKitโs known limits. For a custom model, set Context on the Advanced card or in the add/edit model dialog (Settings โ AI).
If that number is wrong, compact may fire too early or too late.
Manual Compact
Trigger compact manually with the slash command:
/compact
/compact preserve the exact failing test output
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:
- Check Context on the selected model (Settings โ AI โ Advanced)
- Custom models: set the real token limit there
- Default is 128K if not set
Troubleshooting
Compact triggers too often
- Increase the threshold (e.g., 95%)
- Check Context on the selected model (Settings โ AI โ Advanced)
- Consider using a model with larger context
Compact not triggering
- Ensure auto-compact is enabled
- Check threshold isnโt too high
- Verify Context on the selected model 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