Context limit UX failure: No progressive warnings, misleading error messages, cascade failure in compaction

Status Fixed / completed
Reported on v2.1.111
Maintainer reply None cached
Activity 4 comments · opened Jun 2, 2026 · closed Jun 8, 2026

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, /compact command 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

  1. Start long-running Claude Code session with extensive tool usage
  2. Perform complex work involving many file reads, tool calls, detailed analysis
  3. Continue until session reaches ~2500 lines / 4.5MB
  4. Attempt any new prompt → "Prompt is too long" error
  5. Attempt /compact → "Conversation too long" error
  6. 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.

View original on GitHub ↗

4 Comments

junaidtitan · 4 months ago

The 13-hour / 4.5MB session → /compact fails 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 /compact to run, cozempic can still recover the session because it works directly on the .jsonl file — no API call, so it's not blocked by the context being over the limit.

cozempic treat current --execute prunes 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 /compact ceiling and lets CC continue. Running cozempic guard continuously 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.

alnotaic2 · 4 months ago

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:

  1. Cozempic (junaidtitan's suggestion)
  • Integrated proactive session pruning and reactive recovery hooks
  • Added SessionStart, PreCompact, and PostCompact hooks for automatic context management
  • System now prevents context overflow and provides recovery mechanisms
  1. Memory Lifecycle System (kehansama's AgentRelay concept)
  • Implemented connection-based memory architecture with full hooks system
  • Added 20+ specialized hooks for circuit breaking, write gating, session management
  • Integrated ONNX embedding model (384-dimension sentence-transformers alternative)
  • Connected to Gemini API for memory consolidation and routing

Current Status:

  • Both systems running in parallel, providing layered protection
  • Automatic session management eliminates need for manual intervention
  • Context cascade failures like my 2026-06-02 incident (45 mappings, 13 hours lost) are now impossible
  • Memory system preserves work across context boundaries
  • Successfully tested with buffer entries and decision-type memories

Technical Details:

  • Windows environment with bash shell compatibility
  • Hooks integrated into Claude Code settings with proper timeout handling
  • Memory buffer handles connection, consolidation, routing, and aging phases
  • All systems fully autonomous and self-managing

The implementation solved the exact problem described in my original ticket. Thank you both for the thoughtful and comprehensive solutions.

Best regards,
Alan

junaidtitan · 4 months ago

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.

github-actions[bot] · 2 months ago

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.