Claude Code

Model "qwen3.8:27b" isn't recognized · context assumed to be 200k tokens · update Claude Code, or see the docs

Last checked

The error

⚠ Model "qwen3.8:27b" isn't recognized · context assumed to be 200k tokens · update Claude Code, or see https://code.claude.com/docs/en/model-config

The glyph in front (⚠ or ‼) is just the warning mark. The model name and the assumed size vary: the Claude Code docs' own example reads context assumed to be 1m tokens for a gateway model; with an Ollama tag such as qwen3.8:27b or gemma4:12b users see 200k.

This is a warning, not an error, and Claude Code keeps working. It appears when you point Claude Code at a model ID it has no record of, such as an Ollama tag like qwen3.8:27b, so it assumes a context window and plans compaction around that number. If the model's real window is different, set CLAUDE_CODE_MAX_CONTEXT_TOKENS to the real size (Claude Code v2.1.193 or newer), and make sure your server actually loads the model with that window.

Why it matters: the window mismatch

Claude Code compacts the conversation when it gets close to the window it believes in. If it believes 200k but Ollama loaded the model with a much smaller window, things go wrong long before Claude Code ever compacts: the server can drop the oldest part of the prompt, so the model loses your instructions mid-task and starts failing tool calls that worked a minute ago, or the server rejects the request and you see "Prompt is too long" in a session that doesn't look long.

The opposite mismatch, a 1M model treated as smaller, just makes Claude Code compact earlier than it needs to. So the fix has two halves: tell Claude Code the real window, and make sure the server actually loads the model with that window. The same kind of mismatch is behind OpenClaw's context-window error.

Why it happens

Claude Code knows the context window of the models it ships with. A model ID that isn't in that list and doesn't start with claude- gives it nothing to look up, so it falls back to an assumed window and warns you. Compaction, the status line's context size and "Prompt is too long" handling all run off that assumed number.

  1. A local model through Ollama or LM Studio: qwen3.8:27b, gemma4:12b and gpt-oss:20b are Ollama tags Claude Code has never heard of.
  2. A gateway's name for a model Claude Code does know, such as my-gateway-opus on a corporate proxy.
  3. A Claude model released after your Claude Code version.
  4. A typo. That one reads differently: Model "…" isn't recognized · did you mean "…"?

The fix

  1. 1 Decide whether it matters: if the model's real context window is the assumed size, you can ignore the warning.
  2. 2 For a local or other unknown model, set CLAUDE_CODE_MAX_CONTEXT_TOKENS to the real window in the environment that starts Claude Code, or in the env block of ~/.claude/settings.json. Needs v2.1.193 or newer for IDs that don't start with claude-.
  3. 3 For a gateway alias of a Claude model, add a modelOverrides entry mapping the Anthropic model ID to your gateway's ID instead.
  4. 4 For a new Claude model, run claude update.
  5. 5 For a model with a 1M window, append [1m] to the ID: claude --model 'my-gateway-opus[1m]'.
  6. 6 On Ollama or LM Studio, load the model with the same window you told Claude Code (OLLAMA_CONTEXT_LENGTH or num_ctx; LM Studio's context length), then restart Claude Code.
export CLAUDE_CODE_MAX_CONTEXT_TOKENS=65536

Fix 1: Tell Claude Code the real context window

Pick the row that matches your situation. This is the decision table from the Claude Code model configuration docs, condensed.

# Local Qwen model loaded with a 64k window
export CLAUDE_CODE_MAX_CONTEXT_TOKENS=65536
claude --model qwen3.8:27b

# Or for every session, in ~/.claude/settings.json:
{ "env": { "CLAUDE_CODE_MAX_CONTEXT_TOKENS": "65536" } }
Your situationDo this
A new Claude model your build doesn't knowclaude update, then restart
A gateway alias for a Claude model it does knowIn settings: "modelOverrides": { "claude-opus-4-8": "my-gateway-opus" } (Anthropic ID → your gateway's ID)
A model with a 1M windowAppend [1m] to the ID: claude --model 'my-gateway-opus[1m]'
Any other window (all local models)Set CLAUDE_CODE_MAX_CONTEXT_TOKENS to the real window, in the environment that starts Claude Code

For an unrecognised ID that doesn't start with claude-, the variable takes effect on its own from v2.1.193; the maintainer who closed GitHub #68522 confirmed that both the status line's context window size and the auto-compaction threshold use the declared value. Before v2.1.193 it only worked together with DISABLE_COMPACT=1, which is why some guides still say that; update instead.

Two related variables: CLAUDE_CODE_MAX_OUTPUT_TOKENS (for a model ID Claude Code can't resolve, the default is 32,000 and the cap 128,000; lower it if your local model's maximum output is smaller) and CLAUDE_CODE_AUTO_COMPACT_WINDOW (how full the context gets before compaction, from 100,000 to 1,000,000 tokens).

Fix 2: Make the server load the model with that window

The variable tells Claude Code what to expect; it doesn't change the server. Match them, because the smaller of the two wins.

Ollama: its default context depends on your GPU memory (Ollama's docs give 4k under 24 GB of VRAM, 32k at 24–48 GB and 256k above), and ollama ps shows the CONTEXT of the loaded model. Ollama recommends at least 64k for agents and coding tools. Set it before you start Claude Code; ollama launch claude sets the three ANTHROPIC_ variables for you.

OLLAMA_CONTEXT_LENGTH=65536 ollama serve
# or per model, in a Modelfile:
#   FROM qwen3.8:27b
#   PARAMETER num_ctx 65536
# ollama create qwen3.8-64k -f Modelfile

export ANTHROPIC_BASE_URL=http://localhost:11434
export ANTHROPIC_AUTH_TOKEN=ollama
export ANTHROPIC_API_KEY=""
export CLAUDE_CODE_MAX_CONTEXT_TOKENS=65536
claude --model qwen3.8:27b

A 64k window on a 27B model needs roughly 24 GB of VRAM at Q4; drop to a 12B–14B model if you don't have it.

LM Studio: set Context Length in the model's load settings, or load from the CLI with lms load <model> --context-length 65536. Its Anthropic-compatible endpoint is on port 1234: ANTHROPIC_BASE_URL=http://localhost:1234 ANTHROPIC_AUTH_TOKEN=lmstudio CLAUDE_CODE_MAX_CONTEXT_TOKENS=65536 claude --model <model>. LM Studio recommends more than about 25k context for Claude Code.

LiteLLM or another gateway: set the gateway's own limit (model_info.max_input_tokens with enable_pre_call_checks: true in LiteLLM's router settings) so it rejects oversize prompts cleanly, and still set CLAUDE_CODE_MAX_CONTEXT_TOKENS on the Claude Code side; Claude Code doesn't read the gateway's limit.

If Claude Code can't reach Ollama at all, that's a different problem: see the connection-refused guides below.

Check it worked

Restart Claude Code with the same model: the warning should be gone. /context shows how much of the window is in use against the size Claude Code now believes, and a custom status line can show it too (context_window.context_window_size). On Ollama, ollama ps in another terminal should show the same context size for the loaded model.

If the warning persists, the variable isn't reaching Claude Code: the VS Code extension doesn't see your terminal's exports, so put it in the env block of ~/.claude/settings.json, which both the CLI and the extension read.

Which local models actually work in Claude Code

Making the warning go away doesn't make a model good at Claude Code's tool calls. Larger local models with reliable tool calling handle small edits; small ones tend to struggle with multi-step tool use. These go deeper on the two families in this warning, and on the tools error Ollama gives for models with no tool support.

Full guideQwen 3.8 27B tool calling fails in agents: fix

Hit a different error?

Paste any agent error and get the cause and fix in seconds.

Open the decoder

Frequently asked questions

What does model "qwen3.8:27b" isn't recognized · context assumed to be 200k tokens · update claude code, or see the docs mean?

Claude Code doesn't have qwen3.8:27b, an Ollama tag, in its model list, so it assumes a 200k context window and warns you. Nothing is broken, but Ollama has probably loaded the model with a much smaller window. Set the real value on both sides: OLLAMA_CONTEXT_LENGTH=65536 ollama serve, and CLAUDE_CODE_MAX_CONTEXT_TOKENS=65536 before starting Claude Code (v2.1.193 or newer).

What does model "gemma4:12b" isn't recognized · context assumed to be 200k tokens mean?

The same warning for Gemma 4 12B via Ollama. Ollama only loads the context that num_ctx or OLLAMA_CONTEXT_LENGTH allows, so set that to the window you can afford in GPU memory and set CLAUDE_CODE_MAX_CONTEXT_TOKENS to the same number.

Does "update Claude Code" fix it?

Only if the unrecognised ID is a new Claude model. Updating won't add local or gateway models to Claude Code's list; use CLAUDE_CODE_MAX_CONTEXT_TOKENS, or modelOverrides for a gateway alias of a Claude model. Be on at least v2.1.193 for the variable to apply on its own.

Can I just ignore the warning?

Yes, if the model really has that window. If it's smaller, you'll eventually see dropped instructions or "Prompt is too long" in a session that doesn't look long, because Claude Code won't compact until it believes it's near the assumed size.

Where do I put CLAUDE_CODE_MAX_CONTEXT_TOKENS so it always applies?

In the env block of ~/.claude/settings.json, for example {"env": {"CLAUDE_CODE_MAX_CONTEXT_TOKENS": "65536"}}. That file is shared by the CLI and the VS Code extension; a shell export only reaches the terminal you set it in.

Stop firefighting agent errors

Decoding errors one at a time is the manual version of what BetterClaw automates. Run your agents on a no-code AI agent platform with managed models, retries and config validation built in.

Free plan available · Pro $49/mo · BYOK · 7-day free trial