Agent Upstart

Cool things people are building with agents — and practical help getting the most out of them.

Playbooks · Coding tasks

Run LongCat-2.5 in Claude Code without the 200K cap

Written November 4, 2026 · Edited November 12, 2026

Claude Code does not recognize the model ID LongCat-2.5, so it assumes a 200,000-token window and compacts the conversation there. Point one launch at LongCat's endpoint, tell Claude Code the model's real window, and read the startup warning before doing real work.

What happens without the fix

LongCat-2.5 became generally available on the LongCat API Platform on 2 November 2026, listed as compatible with Claude Code, Codex, and Hermes. Claude Code's own model configuration docs say that when it does not recognize a session's model ID, it cannot tell the model's context window and assumes 200K tokens, auto-compacting at that assumed size. The warning appears at startup. If the model's real window is 200K, there is nothing to correct; for any larger window, the fix is one variable, set in the environment that starts Claude Code.

Before you start

You need a LongCat API key, Claude Code installed, and a throwaway copy of a project for the first session. Create the key on the API Keys page: it is shown only once, so store it somewhere safe right away. The same key works for both the OpenAI-format and Anthropic-format endpoints. Read the pricing page and the model page on LongCat's platform before a long session, and take the window size for the next step from the model page, not from memory. LongCat's docs say failed requests, including 401, 403, 429, and 500 responses, are not charged, and only successful requests are billed on actual token use.

Steps

  1. Keep the trial to one launch. Do not paste the routing into ~/.claude/settings.json unless you want every Claude Code session on the machine to go to LongCat: Claude Code's environment variable docs say that file applies to you, in every project. A wrapper script keeps plain claude on your normal setup. Never put the key in a project .claude/settings.json file, which is checked into source control.
  2. Write the wrapper. Save this as a file such as ~/bin/claude-longcat, replacing the window value with the number on LongCat's model page:
    • export ANTHROPIC_BASE_URL="https://api.longcat.chat/anthropic"
    • export ANTHROPIC_AUTH_TOKEN="$LONGCAT_API_KEY"
    • export ANTHROPIC_MODEL="LongCat-2.5"
    • export ANTHROPIC_DEFAULT_OPUS_MODEL="LongCat-2.5"
    • export ANTHROPIC_DEFAULT_SONNET_MODEL="LongCat-2.5"
    • export ANTHROPIC_DEFAULT_HAIKU_MODEL="LongCat-2.5"
    • export CLAUDE_CODE_MAX_CONTEXT_TOKENS=<window from the model page>
    • exec claude "$@"
    The base URL and model ID come from LongCat's FAQ and API docs. The ANTHROPIC_BASE_URL variable is how Claude Code routes requests through a proxy or gateway, and ANTHROPIC_AUTH_TOKEN supplies the Authorization header. Set the haiku slot too: it is also used for background work, and leaving it unset leaves part of the session on the default model. Make the file executable, export LONGCAT_API_KEY in your shell, and run the wrapper in the throwaway project.
  3. Read the startup lines. The 200K warning should be gone once Claude Code uses the window you gave it. If the warning is still there, the variable did not take effect: check that the ID does not start with claude- and carries no [1m] suffix, the two cases where the docs say the variable applies on its own. Run /status in the session to see which model is active.
  4. Run one small task first. Ask for a small change with a test you can run yourself, in the throwaway copy. After the session, compare the token use against LongCat's billing records before moving real work to it. A first session that never shows the model in /status has not proved anything about the window.
  5. Plan long outputs against the lower cap. LongCat's FAQ says LongCat-2.5 outputs up to 256K tokens, but Claude Code's environment variable docs say that for a model ID it cannot resolve, the output default is 32,000 and the cap is 128,000, and Claude Code lowers a higher value to the cap. Inside Claude Code, the 128,000 cap governs until a run proves otherwise. Raising CLAUDE_CODE_MAX_OUTPUT_TOKENS reduces the effective context window available before auto-compaction triggers, so do not raise it casually on a long-context session.
  6. Leave the traffic switch out. CLAUDE_CODE_DISABLE_NONESSENTIAL_TRAFFIC disables auto-updates, telemetry, and error reporting, and any non-empty value turns it on, including 0. Setting it to 0 expecting "off" still disables that traffic. Omit it unless you mean to stop Claude Code updating itself.

What can go wrong

Limits

Related playbooks

Sources

Back to: Coding playbooks hub · Also: Bring your own Anthropic key: what it costs · What an agent costs · GPT-6.1 Sol, Ultrafast, and the new Pro tiers · Agent cost estimator · Use Claude Code login inside OpenCode