[BUG] --resume loses [1m] context window on non-first-party ANTHROPIC_BASE_URL when session model differs from default

Status Fixed / completed
Reported on v2.1.266
Maintainer reply None cached
Activity 0 comments · opened Sep 9, 2026 · closed Sep 11, 2026

Preflight Checklist

  • [x] I have searched existing issues and this hasn't been reported yet
  • [x] This is a single bug report (please file separate reports for different bugs)
  • [x] I am using the latest version of Claude Code

What's Wrong?

When ANTHROPIC_BASE_URL points at a non-first-party host (a corporate gateway, or any proxy in front of api.anthropic.com) and the session model differs from the model key in settings.json, claude
--resume
restores the model as bare claude-fable-5-1 with a 200,000 context window instead of claude-fable-5-1[1m] with 1,000,000.

This is not cosmetic: the resumed session also stops sending context-1m-2025-08-07 in the anthropic-beta request header, so the API is asked for a 200K window and auto-compaction kicks in at 200K.

In the transcript, the fresh run writes an attachment.type=model record with modelId: "claude-fable-5-1[1m]". The resume ignores it and writes a second record with bare modelId: "claude-fable-5-1".
Assistant messages carry "model":"claude-fable-5-1" (the API-echoed id, which never includes [1m]), which looks like what resume falls back to.

On api.anthropic.com directly the bare id already means 1M, so the bug is masked there. It also does not occur when the settings default equals the session model.

What Should Happen?

--resume should restore the exact model the session was started with, claude-fable-5-1[1m], and keep the 1,000,000 window and the context-1m-2025-08-07 beta header, regardless of host and
regardless of the settings default.

Error Messages/Logs

Fresh run (modelUsage):   claude-fable-5-1[1m]  contextWindow=1000000
Resume run (modelUsage):  claude-fable-5-1      contextWindow=200000

Transcript grep (grep -oE '"modelId":"[^"]*"|"model":"claude[^"]*"' $SID.jsonl | sort | uniq -c):
     2 "model":"claude-fable-5-1"
     1 "modelId":"claude-fable-5-1"
     1 "modelId":"claude-fable-5-1[1m]"
     
  Proxy log (transparent pass-through to api.anthropic.com):
  REQ  POST /v1/messages?beta=true  model='claude-fable-5-1'  anthropic-beta contains context-1m-2025-08-07   (fresh)
  RESP 200  message_start model='claude-fable-5-1'
  REQ  POST /v1/messages?beta=true  model='claude-fable-5-1'  anthropic-beta MISSING context-1m-2025-08-07    (resume)
  RESP 200  message_start model='claude-fable-5-1'
  
  --debug-file on the resume run:
  [ToolSearch:optimistic] disabled: ANTHROPIC_BASE_URL=http://127.0.0.1:8798 is not a first-party Anthropic host.
  [auto-mode] verifyAutoModeGateAccess: ... model=claude-opus-5[1m] ...
  [API:timing] dispatching to firstParty model=claude-fable-5-1

Steps to Reproduce

  1. Start any transparent reverse proxy to https://api.anthropic.com on http://127.0.0.1:8798 (I used a ~40-line stdlib Python proxy that forwards requests unchanged). The only purpose is to make the

hostname non-first-party while responses are genuine.

  1. Run a fresh session with a settings override whose default model differs from the session model:

OV='{"env":{"ANTHROPIC_BASE_URL":"http://127.0.0.1:8798","ANTHROPIC_CUSTOM_HEADERS":""},"model":"opus[1m]"}'
SID=$(uuidgen | tr A-Z a-z)
claude -p "Reply with exactly: ok" --model 'claude-fable-5-1[1m]' --session-id $SID --settings "$OV" --output-format json
→ modelUsage key is claude-fable-5-1[1m], contextWindow 1000000

  1. Resume it:

claude -p "Reply with exactly: ok" --resume $SID --settings "$OV" --output-format json
→ modelUsage key is claude-fable-5-1, contextWindow 200000, and the request no longer carries context-1m-2025-08-07

Controls (same commands):

  • Without the proxy, against api.anthropic.com: both runs report 1000000.
  • Through the proxy but with "model":"claude-fable-5-1[1m]" in the override: resume keeps claude-fable-5-1[1m] at 1000000.

Claude Model

Other

Is this a regression?

I don't know

Last Working Version

_No response_

Claude Code Version

2.1.266

Platform

Other

Operating System

macOS

Terminal/Shell

Terminal.app (macOS)

Additional Information

Auth: Anthropic OAuth (claude.ai subscription), not an API key. Reproduced 100% across three separate session ids on macOS 26 (Darwin 25.4.0).

This is a serious problem for companies running their own gateways for security and compliance purposes.
It seems to also be happening when a session was idle for some time. Writing something new in the session has been reported to cause the same behavior.

View original on GitHub ↗