Summary
When routing to a custom model via ANTHROPIC_BASE_URL (an Anthropic-Messages-compatible gateway) whose real context window is larger than 200k, Claude Code assumes a 200k window and there is no reliable way to tell it the true size. This makes the status line and auto-compaction behave wrongly for large-window models.
Environment
- Claude Code 2.1.177 (native), macOS (arm64).
- Model id is a non-built-in string (e.g.
my-gateway/big-model) served via ANTHROPIC_BASE_URL + ANTHROPIC_AUTH_TOKEN.
- The backend model's real context window is large (e.g. ~1M tokens).
Observed
- Status line shows
…/200k; the statusline JSON context_window.context_window_size is 200000.
context_window.used_percentage is computed against 200k, so resuming a session whose context exceeds 200k shows >100% and triggers auto-compaction prematurely — even though the backend supports far more.
- The
[1m] suffix works for built-in model names, but there is no equivalent for an unrecognized custom/gateway model id.
Expected
A way to declare a custom model's true context window, so both the status line and the auto-compaction math use it.
Tried (and why it didn't resolve)
- Env vars around max-context / auto-compact window: I could not find a documented, working knob that makes an unrecognized custom model report or use a >200k window (the docs found were unclear/conflicting, and the status line stayed at 200k).
[1m] suffix: applies only to known Claude model names, not custom ids.
Request (any one would solve it)
- A
--model my-gateway/big-model[ctx=1048576]-style suffix for custom ids, or
- a
modelOverrides / per-model contextWindow field in settings.json, or
- have gateway model discovery read a
context_length / max_input_tokens field from the gateway's GET /v1/models and apply it to both the status line and compaction.
Summary
When routing to a custom model via
ANTHROPIC_BASE_URL(an Anthropic-Messages-compatible gateway) whose real context window is larger than 200k, Claude Code assumes a 200k window and there is no reliable way to tell it the true size. This makes the status line and auto-compaction behave wrongly for large-window models.Environment
my-gateway/big-model) served viaANTHROPIC_BASE_URL+ANTHROPIC_AUTH_TOKEN.Observed
…/200k; the statusline JSONcontext_window.context_window_sizeis200000.context_window.used_percentageis computed against 200k, so resuming a session whose context exceeds 200k shows >100% and triggers auto-compaction prematurely — even though the backend supports far more.[1m]suffix works for built-in model names, but there is no equivalent for an unrecognized custom/gateway model id.Expected
A way to declare a custom model's true context window, so both the status line and the auto-compaction math use it.
Tried (and why it didn't resolve)
[1m]suffix: applies only to known Claude model names, not custom ids.Request (any one would solve it)
--model my-gateway/big-model[ctx=1048576]-style suffix for custom ids, ormodelOverrides/ per-modelcontextWindowfield insettings.json, orcontext_length/max_input_tokensfield from the gateway'sGET /v1/modelsand apply it to both the status line and compaction.