Claude Code. Any Model. The most powerful AI coding agent now speaks every language.
Both env levers, why the status line reports the ENFORCED window, and local-model context accounting.
Extracted from
CLAUDE.md(v7.64.0). Indexed inREADME.md.
Context Window and Auto-Compaction (v7.24.0+, status line v7.28.0+)
Claude Code resolves its compaction point as min(CLAUDE_CODE_AUTO_COMPACT_WINDOW, maxContextTokens(model)), and maxContextTokens falls back to a hardcoded 200,000 for any model name it does not recognise — which is every model claudish proxies. Setting only the first lever therefore accomplishes nothing: the real window is accepted and then thrown away by the min(). resolveContextWindowEnv() (claude-runner.ts) sets both, and Claude Code honours CLAUDE_CODE_MAX_CONTEXT_TOKENS only for model names not starting with claude-, i.e. exactly the pure-proxy case.
CLAUDE_CODE_AUTO_COMPACT_WINDOW has a ceiling of 1,000,000. Claude Code clamps a larger value and prints ... is too large, so Claude Code treats it as the 1M maximum on every launch (measured on 2.1.304 with catalog windows of 1,050,000 and 1,007,997). claudish sends min(window, MAX_AUTO_COMPACT_WINDOW), which moves no compaction point. CLAUDE_CODE_MAX_CONTEXT_TOKENS raised no warning at the same values and keeps the real window.
The env is read at SPAWN and never revisited. A long-running claudish process keeps whatever window it was launched with; upgrading the package on disk does nothing for a live session. Diagnosing this is easy once you know the tell: inside ONE pre-fix process, subagents pinned to model: "opus" (a name Claude Code knows as 1M) compact at ~340K while the main thread on the proxied model compacts at ~170K. Ground truth is compactMetadata.preTokens in the Claude Code transcript.
The status line reports the ENFORCED window, not the spec window. TokenTracker.writeFile derives context_left_percent from inputTokens alone — folding in the session-CUMULATIVE outputTokens made the value decay with session AGE and pin at 0 forever once lifetime output passed the window (measured: input 94,018 of a 372,000 window reporting 0% left). Both generated status-line variants then recompute against min(spec window, CLAUDE_CODE_MAX_CONTEXT_TOKENS ?? 200000, CLAUDE_CODE_AUTO_COMPACT_WINDOW) and render 18% (164k/200k of 372k) when those disagree, so a clamp is visible on day one instead of costing days of half-context work.
The status line is a generated shell one-liner (and a generated JS file on Windows), so TypeScript cannot catch a typo in it — test the generated artifact by executing it (status-line-context.test.ts). The token file's path is ONE rule, resolveTokenFilePath in session/token-file.ts, used by the tracker that writes it, the status line and the end-of-session summary: an ASSIGNED CLAUDISH_TOKEN_FILE (a team slot's or MCP session's own path; tests use it too), else <home>/.claudish/tokens-<port>.json with <home> read $HOME-first — Bun's os.homedir() ignores a runtime HOME, so a tracker that called it wrote a file the summary never read under a redirected HOME. claude-runner publishes the session's file to Claude Code as both CLAUDISH_TOKEN_FILE and CLAUDISH_PUBLISHED_TOKEN_FILE; when a claudish started from that session's Bash tool sees the two equal, the file is its parent's status-line file, not an assignment, and it keeps its own (sharing one made each status line show the other's model and cost). Bash integer division truncates where JS Math.round rounds, so the bash variant uses ((x*200/w)+1)/2 to keep both platforms on the same number.
Bare-name context-window lookup
resolveLocalContextWindow routes a bare name first, then asks discovery and the slim
catalog for the primary hop's wire id on that provider. The canonical model id can differ
from the served id (muse-wonder-full → muse-wonder-full-1.0); discovery keyed by the
canonical id misses the account's served window. A slim-catalog miss by wire id still tries
the canonical model id, so canonical-keyed windows remain available.
Context Tracking for Local Models
Local model APIs (LM Studio, Ollama) report prompt_tokens as the full conversation context each request, not incremental tokens. The writeTokenFile function uses assignment (=) not accumulation (+=) for input tokens to handle this correctly.