Model selection: prefer session history over agent default (-m) #8065

Open
opened 2026-02-16 18:09:04 -05:00 by yindo · 2 comments
Owner

Originally created by @rickross on GitHub (Jan 30, 2026).

Originally assigned to: @thdxr on GitHub.

When a session's model is changed via the model picker, integrations that call session.prompt without an explicit model can still be forced back to the agent's default model (e.g. when started with -m).\n\nExpected: the session's currently selected model (last used for that agent) should be used unless the request explicitly supplies a model.\n\nCurrent: resolution order is input.model ?? agent.model ?? lastModel(sessionID), which makes -m effectively pin the model and ignore session selection.\n\nRepro:\n1) Start a session with opencode -m \n2) Switch model to in the session\n3) Submit a prompt from another caller that does not pass model\n4) It uses modelA instead of modelB

Originally created by @rickross on GitHub (Jan 30, 2026). Originally assigned to: @thdxr on GitHub. When a session's model is changed via the model picker, integrations that call session.prompt without an explicit model can still be forced back to the agent's default model (e.g. when started with -m).\n\nExpected: the session's currently selected model (last used for that agent) should be used unless the request explicitly supplies a model.\n\nCurrent: resolution order is input.model ?? agent.model ?? lastModel(sessionID), which makes -m effectively pin the model and ignore session selection.\n\nRepro:\n1) Start a session with opencode -m <modelA>\n2) Switch model to <modelB> in the session\n3) Submit a prompt from another caller that does not pass model\n4) It uses modelA instead of modelB
Author
Owner

@github-actions[bot] commented on GitHub (Jan 30, 2026):

This issue might be a duplicate of existing issues. Please check:

  • #4901: SDK Messages cause switch back to default model
  • #4475: Plugins using noReply seem to cause model to switch to agent default
  • #8349: Model selection is "lost" on continuation and Agent selection is "lost" on compaction
  • #7948: TUI: User selected agent/model is overwritten by server defaults when creating a new session
  • #7099: Server API ignores agent's configured model when only agent parameter is passed
  • #6928: Subtask commands do not inherit model
  • #6636: Subagent with specific model results in model change in build and plan mode
  • #4344: Selected model for agent in TUI doesn't stick between Agent Alternation
  • #4243: Cycle through model do not work when a default model is set
  • #4930: Feature Request: Retain current model and agent selection when switching sessions
  • #10407: Feature Request: Remember last used model/agent across sessions
  • #7211: The selected model is not taken into account

Feel free to ignore if none of these address your specific case.

@github-actions[bot] commented on GitHub (Jan 30, 2026): This issue might be a duplicate of existing issues. Please check: - #4901: SDK Messages cause switch back to default model - #4475: Plugins using noReply seem to cause model to switch to agent default - #8349: Model selection is "lost" on continuation and Agent selection is "lost" on compaction - #7948: TUI: User selected agent/model is overwritten by server defaults when creating a new session - #7099: Server API ignores agent's configured model when only agent parameter is passed - #6928: Subtask commands do not inherit model - #6636: Subagent with specific model results in model change in build and plan mode - #4344: Selected model for agent in TUI doesn't stick between Agent Alternation - #4243: Cycle through model do not work when a default model is set - #4930: Feature Request: Retain current model and agent selection when switching sessions - #10407: Feature Request: Remember last used model/agent across sessions - #7211: The selected model is not taken into account Feel free to ignore if none of these address your specific case.
Author
Owner

@rickross commented on GitHub (Jan 30, 2026):

Likely same root cause as #4243 and #4901 (agent/default model taking precedence when a prompt doesn't explicitly pass model). PR #11332 proposes resolving session-selected model before agent default.

@rickross commented on GitHub (Jan 30, 2026): Likely same root cause as #4243 and #4901 (agent/default model taking precedence when a prompt doesn't explicitly pass model). PR #11332 proposes resolving session-selected model before agent default.
Sign in to join this conversation.
1 Participants
Notifications
Due Date
No due date set.
Dependencies

No dependencies set.

Reference: anomalyco/opencode#8065