t3code icon indicating copy to clipboard operation
t3code copied to clipboard

[Bug]: Claude context meter ignores CLAUDE_CODE_AUTO_COMPACT_WINDOW

Open sungyongcho opened this issue 3 weeks ago • 1 comments

Before submitting

  • [x] I searched existing issues and did not find a duplicate.
  • [x] I included enough detail to reproduce or investigate the problem.

Area

apps/server

Steps to reproduce

  1. Leave Settings → Providers → Claude → "Auto-compact after" empty.
  2. Set CLAUDE_CODE_AUTO_COMPACT_WINDOW=300000 in the env block of ~/.claude/settings.json.
  3. Start a Claude thread on a 1M-context model and send turns.
  4. Look at the context meter.

Expected behavior

The meter reports the auto-compaction threshold Claude actually uses (about 267,000 tokens): a compaction tick and the "Compacts automatically at about N tokens" note, the same as for autoCompactWindow since #29220.

Actual behavior

The meter reads e.g. 85k / 1m with no compaction tick and no note. The variable is in effect: it reads 300000 in the session's shell, and /autocompact 300k is refused with "CLAUDE_CODE_AUTO_COMPACT_WINDOW is set and takes precedence". The meter looks nearly empty right up to the point where Claude compacts.

With the same value moved to T3's "Auto-compact after" instead, the tick appears at about 267k, so the gap is only the environment-variable source.

Impact

Minor bug or occasional failure

Version or commit

T3 Code desktop 0.1.8 (.deb)

Environment

Ubuntu 26.04, GNOME Wayland, Claude provider, Claude Fable 5.2.

Notes

  • #29220 lists environment overrides as out of scope ("The threshold does not yet account for Claude's environment overrides, --autocompact, ..."). This issue is that remaining case.
  • Claude Code documents that its own used_percentage is measured against the full model window while this variable is set, so T3 can't rely on Claude's percentage here and needs to read the variable itself (from settings.json env and the process environment, with Claude's precedence).
  • This is about the threshold only. The / 1m denominator is the separate follow-up in #27810, which reads settings files only and would also miss this variable.

Workaround

Set the window in T3's Settings → Providers → Claude → "Auto-compact after" instead of the environment variable.

sungyongcho avatar Nov 10 '26 10:11 sungyongcho

A related case with the same root cause: both sources are set and they disagree, so the T3 setting is silently ignored and the meter shows the wrong tick.

Setup (T3 Code desktop 0.1.9 .deb, Claude Code 2.1.322, Claude Opus 5.5, 1M window)

  1. Settings → Providers → Claude → "Auto-compact after" = 400000.
  2. ~/.claude/settings.json env also has CLAUDE_CODE_AUTO_COMPACT_WINDOW=1000000 (set earlier for CLI use).

What happens

  • T3 passes the value correctly: the spawned process gets --settings {"fastMode":false,"autoCompactWindow":400000,...}.
  • Claude uses the environment variable instead (CLAUDE_CODE_AUTO_COMPACT_WINDOW is set and takes precedence), so the thread grew to 818k / 1m without compacting.
  • The meter still draws the compaction tick at ~400k from T3's own setting, which suggests that compaction is overdue or broken. Nothing shows that the setting has no effect.

Suggestion

When resolving the threshold this issue describes, also handle the conflict case: if CLAUDE_CODE_AUTO_COMPACT_WINDOW is set (in settings.json env or the process environment), show a note under "Auto-compact after" that the variable overrides it, and draw the tick from the effective value.

Removing the variable from settings.json fixed it for new sessions.

sungyongcho avatar Nov 11 '26 20:11 sungyongcho