autoCompact: false ignored - compaction triggers at ~78%
Resolved 💬 7 comments Opened Jan 15, 2026 by Simspeed Closed Jul 2, 2026
Summary
Claude Code triggers automatic context compaction at approximately 78% context usage even when autoCompact: false is explicitly set in settings.json.
Environment
- Claude Code Version: 2.1.7
- OS: Ubuntu Linux (6.8.0-58-generic)
- Date: 2026-01-14
Configuration
// ~/.claude/settings.json
{
"autoCompact": false,
// ... other settings
}
Expected Behavior
With autoCompact: false, automatic compaction should NEVER trigger. Compaction should only occur:
- When manually requested by user (
/compact) - When hitting the hard API context limit (100%)
Actual Behavior
- Compaction triggered automatically at ~78-79% context usage
- CONFIRMED: Status line shows "68% used" + "Context left until auto-compact: 11%" = 79% trigger point
- PreCompact hook fired with
trigger: auto - User attempted to cancel with Ctrl+C multiple times, but compaction kept restarting
- 5 compaction attempts occurred within ~25 minutes (17:39, 17:59, 18:00, 18:01, 18:02)
Evidence
PreCompact hook backups show:
trigger: auto
context_used: unknown # Hook couldn't read percentage from input JSON
The trigger: auto field confirms this was automatic compaction, not user-initiated.
Impact
- Session context corruption: Compaction degrades Claude's memory of the conversation
- Work interruption: User cannot cancel compaction effectively with Ctrl+C
- Data loss risk: If user has session handoff workflow (save to external notes before exit), premature compaction bypasses this
Steps to Reproduce
- Set
"autoCompact": falsein ~/.claude/settings.json - Start a Claude Code session
- Work until context reaches ~78%
- Observe compaction triggering despite the setting
Workaround
Using UserPromptSubmit hook to warn at 70%/75% and manually exit before 78%:
# In hook, warn at 75% to allow manual save before buggy compaction
if [ "$USED_INT" -ge 75 ]; then
echo "MANDATORY: Save session and exit before compaction triggers at ~78%"
fi
Additional Notes
- The PreCompact hook receives JSON that doesn't include
context_window.used_percentagefield (shows as "unknown"), making it impossible to log the actual context level when compaction fires - Ctrl+C during compaction should abort, not restart compaction
Requested Fix
- Honor
autoCompact: false- never trigger automatic compaction when disabled - Ctrl+C during compaction should cleanly abort
- Include context percentage in PreCompact hook input JSON
This issue has 7 comments on GitHub. Read the full discussion on GitHub ↗