[BUG] [UX] Auto-compaction during Q&A leaves question unanswered, summary consumes remaining context budget
Preflight Checklist
- [x] I have searched existing issues and this hasn't been reported yet
- [x] This is a single bug report (please file separate reports for different bugs)
- [x] I am using the latest version of Claude Code
What's Wrong?
When a user asks a question with code changes (e.g., "update X and explain why"), auto-compaction can trigger mid-response. The compaction summary itself then consumes the remaining context budget, leaving the original question unanswered and the code output truncated or vice versa (code generated but explanation dropped).
Suggested Fix
- Detect pending Q&A turns before compaction if the current user message contains a question, flag it as unresolved
- Post-compaction re-injection: After compaction completes, re-ask any unanswered questions from the triggering turn
- Minimum: Surface a message like:
"Context was compacted mid-response. Your question about X wasn't answered resuming now..." so the user isn't left guessing
Impact
- Users lose answers silently with no indication
- Common in "explain + fix" workflows (very common pattern)
- Creates distrust in longer sessions
What Should Happen?
When compaction triggers during a response that has both a code ask and a pending question, the question should be queued and answered after compaction completes or at minimum, Claude should surface that the answer was truncated and offer to re-answer it.
Error Messages/Logs
Steps to Reproduce
- Start a long session with mixed Q&A + code edits
- Approach context limit (~75-85% capacity)
- Ask a question that requires both a code change and an explanation
- Auto-compaction triggers during response generation
Claude Model
Sonnet (default)
Is this a regression?
I don't know
Last Working Version
_No response_
Claude Code Version
2.1.72
Platform
Anthropic API
Operating System
macOS
Terminal/Shell
Terminal.app (macOS)
Additional Information
_No response_
This issue has 3 comments on GitHub. Read the full discussion on GitHub ↗