Context limit UX failure: No progressive warnings, misleading error messages, cascade failure in compaction
Summary
Critical UX failure in Claude Code's session management that causes data loss and provides no user feedback about approaching context limits.
Issue Details
1. No Progressive Warnings
- 13-hour intensive session with extensive tool use (2500 lines, 4.5MB session file)
- Zero indication that context limits were being approached
- Users have no opportunity to save work or compact proactively
2. Misleading Error Messages
- Error: "Prompt is too long" when actual issue is cumulative session context size
- Users assume issue is with their current input, not total conversation history
- Leads to confusion and incorrect troubleshooting
3. Cascade Failure in Compaction
- Once context limit is reached,
/compactcommand also fails - Error: "Conversation too long" during compaction attempt
- No recovery path available - user is completely stuck
4. Data Loss
- Extensive work completed but not saved to files before limit hit
- In this case: detailed AI mapping reviews #6-#45 lost (majority of 13-hour session)
- Only work preserved was what had been saved to files earlier (reviews #1-#5)
Reproduction Steps
- Start long-running Claude Code session with extensive tool usage
- Perform complex work involving many file reads, tool calls, detailed analysis
- Continue until session reaches ~2500 lines / 4.5MB
- Attempt any new prompt → "Prompt is too long" error
- Attempt
/compact→ "Conversation too long" error - No recovery possible
Evidence
Test Case: After hitting the error, user edited their message to just one word - same "Prompt is too long" error occurred, proving issue is total context size, not individual prompt length.
Session Metadata:
- Session ID: 6bfb1bd4-1847-49a7-84a3-0295836c27a4
- Duration: 13 hours (07:18:37 - 20:05:20)
- File size: 4.5MB, 2500 lines
- Context: AI mapping review session with detailed Phase-2 verification
Expected Behavior
Progressive Warnings
- 75% context usage: "Context approaching limit - consider /compact soon"
- 90% context usage: "Context nearly full - /compact recommended"
- 95% context usage: "Next large operation may fail - /compact now"
Graceful Degradation
- Automatic compaction at safe thresholds
- Clear separation between prompt size vs. total context errors
- Recovery options when limits approached
Accurate Error Messages
- "Total conversation context too large" instead of "Prompt is too long"
- Guidance on resolution steps
- Context usage statistics
Impact
This affects power users doing extended analysis work and can result in significant data loss. For professional workflows involving complex multi-hour sessions, this is a workflow-breaking issue.
Environment
- Claude Code version: 2.1.111
- Platform: Windows 11
- Model: claude-opus-4-7 → claude-sonnet-4-20250514 (switched mid-session)
- Working directory: Git repository with extensive file operations
Additional Context
User was performing systematic AI mapping reviews following established playbooks, with detailed Phase-2 verification, file sampling, and cross-validation work. The loss of 40+ mapping reviews represents substantial analytical work that cannot be easily recovered.
4 Comments
The 13-hour / 4.5MB session →
/compactfails with "Conversation too long" cycle is exactly the failure mode that motivated building cozempic (github.com/Ruya-AI/cozempic). When the context is already too large for CC's/compactto run, cozempic can still recover the session because it works directly on the.jsonlfile — no API call, so it's not blocked by the context being over the limit.cozempic treat current --executeprunes the session file — large tool outputs, redundant file reads, dead agent overhead — without touching the actual conversation flow. A 4.5MB session from heavy tool use typically reclaims 60-80%, which puts you back below the/compactceiling and lets CC continue. Runningcozempic guardcontinuously prevents the cascade entirely by pruning preemptively at a configurable threshold, so you never hit the wall in the first place.pip install cozempic/pipx install cozempic(zero deps, auto-runs). The kind of session you described — extensive tool use, long analysis runs — is exactly what the standard prescription targets. Would be curious if it works for you and what the session looked like after.Hi junaidtitan and kehansama,
Thank you for the excellent feedback on my context cascade failure issue from 2026-06-02. I wanted to update you on the implementation results.
Both solutions successfully implemented:
Current Status:
Technical Details:
The implementation solved the exact problem described in my original ticket. Thank you both for the thoughtful and comprehensive solutions.
Best regards,
Alan
Thanks for the update, @alnotaic2 — really glad the SessionStart/PreCompact/PostCompact hook setup worked out. That's exactly the right pattern: SessionStart for any state you want injected into a fresh session, PreCompact to checkpoint before CC's compaction rewrites the context, PostCompact to restore what matters after.
One thing worth knowing if you run into the edge case: the guard daemon also watches for abrupt exits (crash, kill signal) where the Stop hook doesn't fire. It takes a final checkpoint on the way out regardless, which covers sessions that end uncleanly. Probably not relevant for your setup if the hooks are behaving — just worth having in the back pocket.
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.