Skip to content

autoCompact: false ignored - compaction triggers at ~78% #18264

Closed as not planned

Description

@Simspeed

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:

  1. When manually requested by user (/compact)
  2. 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

  1. Set "autoCompact": false in ~/.claude/settings.json
  2. Start a Claude Code session
  3. Work until context reaches ~78%
  4. 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_percentage field (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

  1. Honor autoCompact: false - never trigger automatic compaction when disabled
  2. Ctrl+C during compaction should cleanly abort
  3. Include context percentage in PreCompact hook input JSON

Activity

  1. github-actions commented on Jan 15, 2026

    @github-actions

    Found 3 possible duplicate issues:

    1. [BUG] Turning auto-compact OFF won't allow to continue until you fill the 200K tokens window anymore (it worked before). #18152
    2. [Bug] Context limit reached with 32k tokens free space and auto-compact disabled #18159
    3. [Bug] Instant Auto-Compact increases token consumption even when disabled #13569

    This issue will be automatically closed as a duplicate in 3 days.

    • If your issue is a duplicate, please close it and 👍 the existing issue instead
    • To prevent auto-closure, add a comment or 👎 this comment

    🤖 Generated with Claude Code

  2. zakariamehbi commented on Jan 15, 2026

    @zakariamehbi

    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.

  3. john-savepoint commented on Jan 17, 2026

    @john-savepoint

    I got the same.... they arent addressing this. I got offered a refund and to close my account. Anthropic is falling apart I think.

  4. qte77 commented on Feb 15, 2026

    @qte77

    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:

    • Documented: CLAUDE_AUTOCOMPACT_PCT_OVERRIDE default 95% = 5% buffer
    • Observed: Compaction triggers at 70-85% = 15-30% buffer
    • /context shows: 16.5% buffer (33k tokens) consistently

    Regression: Issue #18152 reports this worked before v2.1.7 — autoCompact: false used 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.

  5. Sn3th commented on May 29, 2026

    @Sn3th

    you must set "CLAUDE_CODE_AUTO_COMPACT_WINDOW=1000000" this is what guards auto compaction now or unset it, either or. hope that helps.

  6. alex-ironside commented on May 29, 2026

    @alex-ironside

    Still occuring in 2.1.157 on Windows

  7. github-actions commented on Jul 2, 2026

    @github-actions

    Closing for now — inactive for too long. Please open a new issue if this is still relevant.

  8. github-actions commented on Sep 3, 2026

    @github-actions

    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.

  9. locked as resolved and limited conversation to collaborators on Sep 3, 2026
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

No one assigned

    Labels

    area:corebugSomething isn't workinghas reproHas detailed reproduction stepsmemoryplatform:linuxIssue specifically occurs on LinuxstaleIssue is inactive

    Type

    No type

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions