claude-code - 💡(How to fix) Fix Model selection should be per-session, not global [1 comments, 2 participants]

Official PRs (…)
ON THIS PAGE

Recommended Tools

×6

Utilities matched from this issue’s tags and category — try them while you read without losing context.

GitHub issue graph ai analysis

Paste a GitHub issue URL. We fetch that issue, discover linked issues from bodies/comments/timeline, collect linked pull requests, and produce a structured English report.

The report is written in English Markdown for sharing and archival.

Helpful · Quick feedback

Loading…
GitHub stats
anthropics/claude-code#45301Fetched 2026-04-09 08:08:32
View on GitHub
Comments
1
Participants
2
Timeline
3
Reactions
0
Author
Timeline (top)
labeled ×2commented ×1
RAW_BUFFERClick to expand / collapse

Problem

When switching models via /model inside a session, the change applies globally to all running sessions. This means if I'm running two sessions — one intentionally on Sonnet for a lightweight task, and another on Opus for a complex task — switching the model in one session unexpectedly changes the other.

Current behavior

  1. Start session A with claude --model claude-sonnet-4-6
  2. Start session B with claude --model claude-opus-4-6
  3. In session A, run /model and switch to Opus
  4. Session B is now also affected — the global model setting has changed

Expected behavior

Model selection should be scoped to the current session. /model should only affect the session where it's invoked. Other running sessions should retain whatever model they were started with or last switched to.

Use case

Multi-session workflows where different tasks need different models:

  • Lightweight tasks (quick fixes, documentation) → Sonnet (faster, cheaper)
  • Complex tasks (architecture, multi-file refactors) → Opus (more capable)

Running these in parallel is common, and having them interfere with each other's model settings is disruptive.

Suggested approach

Store the model selection in session-level state rather than (or in addition to) the global config. The --model flag at startup already implies per-session intent — /model during the session should follow the same principle.

extent analysis

TL;DR

Store model selection in session-level state to prevent global changes when switching models via /model in a session.

Guidance

  • Review the current implementation of the /model command to identify where the global model setting is being updated.
  • Consider adding a session-specific model override that takes precedence over the global setting.
  • Update the --model flag to initialize the session-level model state, ensuring that each session starts with its intended model.
  • Modify the /model command to update the session-level model state instead of the global config.

Example

# Pseudo-code example of session-level model state
class Session:
    def __init__(self, model):
        self.model = model  # Initialize session-level model state

    def switch_model(self, new_model):
        self.model = new_model  # Update session-level model state

Notes

The suggested approach requires changes to the internal state management of the application. It may involve refactoring existing code to accommodate session-level model state.

Recommendation

Apply workaround by storing model selection in session-level state, as this approach aligns with the intended per-session behavior implied by the --model flag at startup.

Vote matrix · Quick signals

Works
Did the solution work? Tap to confirm.
Easy Fix
Was it a quick fix?
Time Saver
Did it save you time?
Blocking
Was it severely blocking?
Common Issue
Are others likely hitting this too?
Flaky / Intermittent
Is it intermittent?
Verified / Reproducible
Can you reproduce it reliably?
Loading…

FAQ

Expected behavior

Model selection should be scoped to the current session. /model should only affect the session where it's invoked. Other running sessions should retain whatever model they were started with or last switched to.

Still need to ship something?

×6

Another batch ranked right after the header list — different links, same matching logic.

Back to top recommendations

TRENDING