[BUG] Resume session overwrites settings.json model[1m] with API-returned model ID — loses 1M context window

Resolved 💬 3 comments Opened May 21, 2026 by fengshao1227 Closed May 24, 2026

### Preflight Checklist

  • [x] I have searched existing issues and this hasn't been reported yet
  • [x] This is a single bug report
  • [x] I am using the latest version of Claude Code

### What's Wrong?

When resuming a session, Claude Code extracts message.model from the last
assistant message in the conversation history. The API naturally returns model
IDs without the [1m] context window suffix (e.g. claude-opus-4-6
instead of claude-opus-4-6[1m]). This bare model ID is then set as
mainLoopModelOverride, overriding the [1m] variant configured in
settings.json.

Root cause (from binary reverse-engineering of v2.1.146):

The function responsible is Bk_ (decompiled name), called during session
restore:

```javascript
// Pseudocode reconstructed from binary
function Bk_(messages) {
// Guard: only skip if runtime override OR env var is set
if (getMainLoopModelOverride() || process.env.ANTHROPIC_MODEL ||
!isFirstParty()) return;

// Walk messages backwards, find last assistant message's model
for (let i = messages.length - 1; i >= 0; i--) {
let msg = messages[i];
if (msg?.type !== "assistant" || msg.isMeta) continue;
let model = msg.message.model; // ← API returns "claude-opus-4-6" (no
[1m])
// ... validity checks ...
return model; // Returns bare model ID
}
}

// Caller in session restore:
let model = Bk_(savedMessages);
if (model) setMainLoopModelOverride(model); // ← Overwrites settings [1m]
variant

v2.1.144 regression: The guard was changed from "skip if any model setting
exists" to "skip only if CLI --model was passed". This was part of the /model
session-only change. Side effect: settings.json model with [1m] suffix is no
longer protected from being overwritten by the API's bare model ID on resume.

A separate normalizer function ZX(H) = H.replace(/\[(1|2)m\]/gi, "") strips
context window suffixes during canonical comparison, so Bk_ considers
claude-opus-4-6 and claude-opus-4-6[1m] as "the same model" and happily
overwrites.

What Should Happen?

When resuming a session, if settings.json specifies a model with [1m] suffix
and the API-returned model is the same base model (just without [1m]), the
settings value should be preserved. The [1m] suffix should not be silently
dropped.

Suggested fix options:

  1. Bk_ guard should also check settings.model — if settings already specifies

a model, don't override from message history

  1. Or: when Bk_ returns a model, check if the configured model (from

settings/initialMainLoopModel) has a [1m] suffix for the same canonical model,
and preserve the [1m] variant

  1. Or: restore the pre-v2.1.144 guard behavior for the [1m] suffix case

specifically

Steps to Reproduce

  1. Set "model": "claude-opus-4-6[1m]" in ~/.claude/settings.json
  2. Start a new session, verify 1M context with /context
  3. Close the session
  4. Resume the session with --resume or --continue
  5. Run /context — observe model is claude-opus-4-6 (200k), not

claude-opus-4-6[1m] (1M)

Workaround

Set ANTHROPIC_MODEL environment variable — Bk_'s guard checks it and skips the
override:

// ~/.claude/settings.json
{
"env": {
"ANTHROPIC_MODEL": "claude-opus-4-6[1m]"
},
"model": "claude-opus-4-6[1m]"
}

Claude Model

Opus 4.6 (1M context)

Is this a regression?

Yes — introduced in v2.1.144

Last Working Version

v2.1.143

Claude Code Version

2.1.146

Platform

Anthropic (First Party)

Operating System

macOS (Darwin 24.5.0)

Terminal/Shell

zsh

Additional Information

Related issues (all closed as duplicate or stale, none fixed):

  • #50803 — [1m] suffix stripped by --model flag (still open, stale)

View original on GitHub ↗

This issue has 3 comments on GitHub. Read the full discussion on GitHub ↗