Repository navigation
Closed as not planned
Labels
area:corebugSomething isn't workingSomething isn't workinghas reproHas detailed reproduction stepsHas detailed reproduction stepsmemoryplatform:linuxIssue specifically occurs on LinuxIssue specifically occurs on LinuxstaleIssue is inactiveIssue is inactive
Description
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 JSONThe 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%"
fiAdditional 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
Reacted by Oleksandr Kuvshynov, Carlos Bentzen and Samuel Scheit
Reacted by Zakaria Mehbi and Samuel Scheit
Metadata
Metadata
Assignees
Labels
area:corebugSomething isn't workingSomething isn't workinghas reproHas detailed reproduction stepsHas detailed reproduction stepsmemoryplatform:linuxIssue specifically occurs on LinuxIssue specifically occurs on LinuxstaleIssue is inactiveIssue is inactive
Activity
github-actions commentedon Jan 15, 2026
Found 3 possible duplicate issues:
This issue will be automatically closed as a duplicate in 3 days.
🤖 Generated with Claude Code
zakariamehbi commentedon Jan 15, 2026
Having a close issue since updating from 2.1.2 to 2.1.7. Auto-compact is disabled. Context usage is at 66%, with a 3k buffer for compaction. However, it blocks and prompts to compact manually (at 66%) rather than reaching 100% and prompting to compact.
john-savepoint commentedon Jan 17, 2026
I got the same.... they arent addressing this. I got offered a refund and to close my account. Anthropic is falling apart I think.
qte77 commentedon Feb 15, 2026
autoCompact: false ignored - compaction triggers at ~78%
Confirmed duplicates:
Same issue reported in #24856 (85% trigger, macOS), #19018 (70% trigger, macOS), and #18152 (regression since v2.1.7).
The problem:
CLAUDE_AUTOCOMPACT_PCT_OVERRIDEdefault 95% = 5% buffer/contextshows: 16.5% buffer (33k tokens) consistentlyRegression: Issue #18152 reports this worked before v2.1.7 —
autoCompact: falseused to allow full 200k usage.Related: #17292 reports opposite bug (autocompact never triggers at 90%+), showing inconsistent behavior.
Recommendation: Fix here, close #24856, #19018, #18152 as duplicates.
Sn3th commentedon May 29, 2026
you must set "CLAUDE_CODE_AUTO_COMPACT_WINDOW=1000000" this is what guards auto compaction now or unset it, either or. hope that helps.
alex-ironside commentedon May 29, 2026
Still occuring in 2.1.157 on Windows
github-actions commentedon Jul 2, 2026
Closing for now — inactive for too long. Please open a new issue if this is still relevant.
github-actions commentedon Sep 3, 2026
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.