[FEATURE] Plan mode compacts context too aggressively near completion
Preflight Checklist
- [x] I have searched existing requests and this feature hasn't been requested yet
- [x] This is a single feature request (not multiple features)
Problem Statement
In plan mode, receiving sub-agent feedback often pushes context just over the compaction threshold (~166k tokens). This triggers compaction at the worst possible moment—right when the agent has everything it needs to finish. After compaction, the agent frequently forgets it received the feedback and starts the planning process over, rather than completing the plan.
The compaction threshold is the same across all modes, but plan mode is particularly sensitive because sub-agent responses arrive as large chunks late in the process.
Proposed Solution
Make compaction more graceful in plan mode specifically. Consider:
- Detecting when the agent is near completion and deferring compaction
- Adding a short hold period after receiving sub-agent responses before allowing compaction
- Prioritising retention of recent sub-agent feedback during compaction
Alternative Solutions
- Increase the compaction threshold for plan mode
- Allow the agent to signal "nearly done" to defer compaction
- Compact more aggressively earlier in the session to leave headroom for sub-agent responses
Priority
Medium - Would be very helpful
<!-- Options: Critical - Blocking my work | High - Significant impact on productivity | Medium - Would be very helpful | Low - Nice to have -->
Feature Category
Interactive mode (TUI)
<!-- Options: CLI commands and flags | Interactive mode (TUI) | File operations | API and model interactions | MCP server integration | Performance and speed | Configuration and settings | Developer tools/SDK | Documentation | Other -->
Use Case Example
Working on a complex feature plan. The plan agent returns detailed architectural feedback, pushing context to ~168k tokens. Compaction triggers immediately. The main agent loses track of that feedback and restarts the planning process from scratch, wasting time and requiring the user to re-explain context.
Additional Context
The core issue is timing: sub-agent feedback arrives as a large chunk that crosses the threshold, and compaction fires before the agent can act on that feedback. A more adaptive approach would recognise that plan mode is about to complete and preserve that critical context.
This issue has 3 comments on GitHub. Read the full discussion on GitHub ↗