[BUG] Restarting claude with --resume clears out context and allows sessions to continue longer
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?
I can consistently extend claude's context window by existing out of claude and using --resume. This happens on the latest production claude version.
Here's what a session looks like before the ctl-c, claude --resume:
Here's after:
What Should Happen?
Claude seems no dumber after the ctl-c loop, so claude should drop whatever context that is lost by doing ctl-c instead of jumping to /compact.
Error Messages/Logs
Steps to Reproduce
- Use claude a lot
- See a few percent left of context
- Run
/context -
ctl -c -
claude --resume - Run
/context
The second time of running /context, the context will be way lower.
Claude Model
Sonnet (default)
Is this a regression?
Yes, this worked in a previous version
Last Working Version
No response
Claude Code Version
2.0.25
Platform
Anthropic API
Operating System
macOS
Terminal/Shell
Terminal.app (macOS)
Additional Information
No response
Another example. After a restart, you can see 1% context but really 30% is available.
https://github.com/user-attachments/assets/c2a8e2ce-c896-4fc7-8508-e046f8b02e0a please fix this. it seems so easy given --continue just always clears out enough context to make much more progress!
https://github.com/user-attachments/assets/092818a9-7691-40b7-8923-211ae8cc01de so easy to reproduce!
@ejc3 has your "before" state gone through a round of compaction already?
Yes, most likely it has gone through one round
At least in one case the difference was due to the CLAUDE.md not being in the trajectory after the restart loop:
⏺ Based on the diff output, here's a summary of the key differences between the two files:
Summary: Differences Between the Two Requests
| Aspect | 04-36-02 (newer) | 04-34-03 (older) |
|---------------|------------------|--------------------------------------------|
| Input Tokens | 122,063 | 140,283 |
| Output Tokens | 6 | 5 |
| File size | 1004 lines | 973 lines (larger due to embedded content) |
Key Differences:
1. Git Status: The older request (04-34-03) shows src/firecracker/vm.rs as modified, while the newer one doesn't
2. Recent Commits:
- Newer (04-36-02) includes commit 3cf50ad ("Remove duplicate vm_name/vm_id from Firecracker log output")
- Older (04-34-03) includes commit ad08893 ("Replace RwLock with DashMap in PassthroughFs") which is missing from the newer
3. System Context: The older request (04-34-03) includes embedded CLAUDE.md content from the fcvm project (a Firecracker VM manager), showing that a Read tool was called to read
/Users/ejcampbell/src/fcvm/.claude/CLAUDE.md. This adds ~200+ lines of escaped documentation about the fcvm project.
4. Token Count: The older request has ~18,000 more input tokens, likely due to the embedded CLAUDE.md content
In short: The newer request is a simpler/cleaner API call with fewer tokens, while the older one includes extensive project documentation that was read during the conversation.
──────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────
>
──────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────
? for shortcuts
Additional analysis: https://ejc3.github.io/claude-restart-trajectory-analysis/
This issue has been inactive for 30 days. If the issue is still occurring, please comment to let us know. Otherwise, this issue will be automatically closed in 30 days for housekeeping purposes.
This issue has been automatically locked since it was closed and has not had any activity for 7 days. If you're experiencing a similar issue, please file a new issue and reference this one if it's relevant.