Prompt too long error persists when compact command fails despite CLAUDE_AUTOCOMPACT_PCT_OVERRIDE=60
Description
When hitting context limits, the automatic compact command fails with a "prompt too long" error, even with CLAUDE_AUTOCOMPACT_PCT_OVERRIDE set to 60. The compaction itself seems to exceed the context window, creating a deadlock where you can't compact because the prompt is too long, but the prompt is too long because it can't compact.
Steps to Reproduce
- Set environment variable
CLAUDE_AUTOCOMPACT_PCT_OVERRIDE=60 - Work in a session until context fills up
- Auto-compact triggers (or manually run
/compact) - Compact command itself fails with "prompt too long" message
Expected Behavior
The compact command should be able to summarize and reduce context even when nearing the context limit. Setting CLAUDE_AUTOCOMPACT_PCT_OVERRIDE=60 to trigger compaction earlier should prevent this scenario entirely.
Actual Behavior
Compact fails with a "prompt too long" error, leaving the session in an unrecoverable state where context is full and cannot be reduced.
Environment
- OS: Windows 10 (MSYS2/Git Bash)
- Claude Code: latest
- Model: claude-opus-4-6
CLAUDE_AUTOCOMPACT_PCT_OVERRIDE=60
This issue has 6 comments on GitHub. Read the full discussion on GitHub ↗