[Bug] Unexpected Model Switching Between Terminal Sessions

Status Closed — duplicate
Maintainer reply ✓ Yes — claude[bot]
Activity 14 comments · opened Sep 9, 2025 · closed Apr 17, 2026
💡 Likely answer: A maintainer (claude[bot], contributor) responded on this thread — see the highlighted reply below.

Bug Description
I had claude open in one terminal tab (in ghostty), on macOS; I was running a task with Sonnet 4. I started claude in another terminal (in VSCode); I was running a task with Opus 4.1. I go back to the first terminal tab, and I see that in Claude's response to me, it was waiting on a permission prompt to proceed. and when I approved it, I noticed the model in my statusline has changed from Sonnet to Opus. this has happened several times in the past week or so, possibly always (?). thank you for your help resolving this. and thank you for building such a wonderful product.

Environment Info

  • Platform: darwin
  • Terminal: ghostty
  • Version: 1.0.109
  • Feedback ID:

Errors

[{"error":"SyntaxError: Unexpected token H in JSON at position 53\n    at JSON.parse (<anonymous>)\n    at file:///Users/whoami/.nvm/versions/node/v18.19.1/lib/node_modules/@anthropic-ai/claude-code/cli.js:733:9932\n    at Q (file:///Users/whoami/.nvm/versions/node/v18.19.1/lib/node_modules/@anthropic-ai/claude-code/cli.js:713:13288)\n    at at2 (file:///Users/whoami/.nvm/versions/node/v18.19.1/lib/node_modules/@anthropic-ai/claude-code/cli.js:1095:1982)\n    at process.processTicksAndRejections (node:internal/process/task_queues:95:5)","timestamp":"2025-09-09T09:01:36.817Z"},{"error":"Error: Request was aborted.\n    at i61._createMessage (file:///Users/whoami/.nvm/versions/node/v18.19.1/lib/node_modules/@anthropic-ai/claude-code/cli.js:971:7955)","timestamp":"2025-09-09T09:31:49.486Z"},{"error":"AxiosError: Request failed with status code 403\n    at XN (file:///Users/whoami/.nvm/versions/node/v18.19.1/lib/node_modules/@anthropic-ai/claude-code/cli.js:715:1077)\n    at Unzip.G0 (file:///Users/whoami/.nvm/versions/node/v18.19.1/lib/node_modules/@anthropic-ai/claude-code/cli.js:716:9955)\n    at Unzip.emit (node:events:529:35)\n    at Unzip.emit (node:domain:489:12)\n    at endReadableNT (node:internal/streams/readable:1400:12)\n    at process.processTicksAndRejections (node:internal/process/task_queues:82:21)\n    at fB1.request (file:///Users/whoami/.nvm/versions/node/v18.19.1/lib/node_modules/@anthropic-ai/claude-code/cli.js:718:2088)\n    at process.processTicksAndRejections (node:internal/process/task_queues:95:5)\n    at async AL5 (file:///Users/whoami/.nvm/versions/node/v18.19.1/lib/node_modules/@anthropic-ai/claude-code/cli.js:2414:472)\n    at async Promise.all (index 0)\n    at async file:///Users/whoami/.nvm/versions/node/v18.19.1/lib/node_modules/@anthropic-ai/claude-code/cli.js:2400:9205","timestamp":"2025-09-09T09:36:31.816Z"}]

View original on GitHub ↗

14 Comments

github-actions[bot] · 11 months ago

Found 3 possible duplicate issues:

  1. https://github.com/anthropics/claude-code/issues/3559
  2. https://github.com/anthropics/claude-code/issues/961
  3. https://github.com/anthropics/claude-code/issues/2272

This issue will be automatically closed as a duplicate in 3 days.

  • If your issue is a duplicate, please close it and 👍 the existing issue instead
  • To prevent auto-closure, add a comment or 👎 this comment

🤖 Generated with Claude Code

0MarkB · 9 months ago

I am having the same issue at v2.0.42!
I just used Opus 4.1 for multiple dumb tasks.. very frustrating

benvanik · 9 months ago

Same here - blew through opus quota for the week. The status line showing the model didn't seem to update consistently across sessions and though I noticed it on one, interrupted, and reset the others kept running with the wrong model. Very sad :( This did used to work: I could switch one session to opus, plan, and switch back to sonnet in isolation, so it's a recent regression.

akatz-ai · 9 months ago

Still reproducing on v2.0.53 (Linux/WSL2). I've done some diagnostic work that may help identify the root cause.

Diagnostic Setup

Added logging to my statusline script to capture what Claude Code sends via the hook:

session_id=$(echo "$input" | jq -r '.session_id // empty')
model_name=$(echo "$input" | jq -r '.model.display_name // empty')
echo "$(date +%H:%M:%S.%3N) [${session_id:0:8}] model=${model_name}" >> ~/full-input.log

Findings

1. Cross-session model bleeding confirmed:
When running /model in one session, other sessions' statuslines update to show the same model:

13:13:31 Session 4dbabacd: Sonnet 4.5 → Opus 4.5
13:13:33 Session 0eceb1d5: Opus 4.5 → Sonnet 4.5   ← Different session, changed 2s later
13:13:38 Session 4dbabacd: Opus 4.5 → Sonnet 4.5
13:13:39 Session 0eceb1d5: Sonnet 4.5 → Opus 4.5   ← Mirroring in lockstep

2. /model updates API calls but NOT statusline hook data:
After running /model sonnet, the API correctly uses Sonnet (Claude responds as Sonnet), but the statusline hook still receives:

14:16:23.193 [0eceb1d5] model=Opus 4.5 model_id=claude-opus-4-5-20251101
14:16:25.479 [0eceb1d5] model=Opus 4.5 model_id=claude-opus-4-5-20251101

Root Cause Hypothesis

Claude Code appears to have two separate code paths:

  1. API request path: Uses the correct, updated model ✓
  2. Statusline hook path: Sends stale/shared model data ✗

The statusline hook JSON generation may be reading from global state that gets overwritten when any session changes models, rather than per-session state.

The session_id in the JSON is correct and unique per session - only the model field is wrong.

github-actions[bot] · 8 months ago

This issue has been inactive for 30 days. If the issue is still occurring, please comment to let us know. Otherwise, this issue will be automatically closed in 30 days for housekeeping purposes.

HayatoKamono · 8 months ago
hongvincent · 7 months ago

Still reproducing on v2.0.76+ (macOS Darwin 25.2.0).

This issue is CRITICAL - it causes actual financial damage when users unknowingly use expensive models.

Confirmed Reproduction (2026-01-23)

Environment:

  • Platform: macOS Darwin 25.2.0
  • Claude Code: 2.0.76+
  • Terminal: Terminal.app
  • Custom statusLine: ~/.claude/scripts/context-bar.sh

Steps:

  1. Session A (Terminal 1): /model sonnet → Status bar shows "Sonnet 4.5" ✅
  2. Session B (Terminal 2): /model opus → Session B shows "Opus 4.5" ✅
  3. BUG: Session A's status bar NOW shows "Opus 4.5" ❌
  4. Verified with /model: Session A is still using Sonnet (API calls correct) ✅

Impact:

  • ❌ Status bar completely unreliable across sessions
  • 💰 Users blow through Opus quota unintentionally (as reported by @benvanik)
  • 😰 Trust issue - cannot verify which model is actually in use

Supporting Evidence

Per @akatz-ai's excellent diagnostics:

  • API request path: ✅ Correct model used
  • Statusline hook path: ❌ Stale/shared global state

The session_id in statusline JSON is correct, but model.display_name is shared globally instead of per-session.

Workaround

No reliable workaround exists. Users must:

  1. Run /model in EVERY session after ANY model change
  2. Never trust the status bar
  3. Check API usage frequently

Related Issues

This is the ORIGINAL issue. All others are duplicates:

  • #9106 (closed - inactivity)
  • #15226, #16595, #18270 (closed - marked duplicate)
  • #17820, #19570 (open - newer reports)

This issue has been open since September 2025 and needs urgent attention.

azolotov · 6 months ago

This is still happening on 2.1.37

bloodcarter · 6 months ago

This is happening on 2.1.45 (Claude Code)

NerdyMihir · 6 months ago

Still happening on 2.1.63

bassner · 5 months ago

Still happening.

stefanodecillis · 5 months ago

Still happening in v2.1.83

claude[bot] contributor · 4 months ago

This is a duplicate of #37596, which was fixed as of version 2.1.85.

github-actions[bot] · 4 months ago

This issue has been automatically locked since it was closed and has not had any activity for 7 days. If you're experiencing a similar issue, please file a new issue and reference this one if it's relevant.