Skip to content

CLAUDE_AUTOCOMPACT_PCT_OVERRIDE not triggering at configured threshold #36381

Description

@YebooLixoo

Bug Description

CLAUDE_AUTOCOMPACT_PCT_OVERRIDE=55 is set as an environment variable but auto-compaction does not trigger at 55% context usage. The main session regularly exceeds the configured threshold without compacting — observed at 67% in one session and over 80% in another before compaction finally occurred.

Environment

  • Claude Code version: 2.1.79
  • Model: Claude Opus 4.6 (Max plan)
  • OS: macOS (Darwin 23.5.0)
  • Shell: zsh

Steps to Reproduce

  1. Set export CLAUDE_AUTOCOMPACT_PCT_OVERRIDE=55 in ~/.zshrc
  2. Verify the variable is loaded: echo $CLAUDE_AUTOCOMPACT_PCT_OVERRIDE55
  3. Start a Claude Code session and use it until context exceeds 55%
  4. Observe that auto-compaction does not trigger at 55%

Expected Behavior

Auto-compaction should trigger when context window usage reaches ~55%, as configured by CLAUDE_AUTOCOMPACT_PCT_OVERRIDE.

Actual Behavior

  • Context reached 67% (see screenshot) without triggering auto-compaction
  • In another session, context reached over 80% before auto-compaction finally fired
  • The env var appears to be ignored for the main session

Screenshot

Context at 67% with no auto-compaction triggered:

Image

Additional Context

  • The env var is confirmed set in the shell environment
  • CLAUDE_CODE_AUTO_COMPACT_WINDOW is not set (default)
  • According to the docs, CLAUDE_AUTOCOMPACT_PCT_OVERRIDE should apply to both main conversations and subagents
  • The HUD percentage comes from Claude Code's native used_percentage field, so the reported percentage should match what the compaction engine sees

Metadata

Metadata

Assignees

No one assigned

    Labels

    area:corebugSomething isn't workinghas reproHas detailed reproduction stepsplatform:macosIssue specifically occurs on macOS

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions