Model incorrectly changes on agent switch using -m, but correctly sticks using config #2559

Closed
opened 2026-02-16 17:36:13 -05:00 by yindo · 2 comments
Owner

Originally created by @jdanbrown on GitHub (Nov 3, 2025).

Originally assigned to: @thdxr on GitHub.

Description

Related issues from pre-1.0:

Now in 1.0, if I set my model in the config file then the model correctly doesn't change when I switch agents:

  1. In config opencode.jsonc, set "model": "anthropic/claude-sonnet-4-5"
    1. Run opencode → UI shows "Anthropic Claude Sonnet 4.5"
    2. Press tab to switch agents → UI still shows "Anthropic Claude Sonnet 4.5" — correct
  2. In config opencode.jsonc, set "model": "openai/gpt-5"
    1. Run opencode → UI shows "OpenAI GPT-5"
    2. Press tab to switch agents → UI still shows "OpenAI GPT-5" — correct

But if I instead set my model using -m/--model on the command line, then when I switch agents the model incorrectly changes to the last-used model:

  1. Disable config "model" setting above
  2. Run opencode (with no -m and no config "model")
    1. UI shows "OpenAI GPT-5" — correct, last-used model (from above)
    2. Press tab to switch agents → UI still shows "OpenAI GPT-5" — correct, last-used model (from above)
  3. Run opencode -m anthropic/claude-sonnet-4-5
    1. UI shows "Anthropic Claude Sonnet 4.5" — correct
    2. Press tab to switch agents → UI shows "OpenAI GPT-5" — bug, last-used model instead of -m model
  4. Run opencode (with no -m and no config "model")
    1. UI shows "Anthropic Claude Sonnet 4.5" — correct
    2. Press tab to switch agents → UI shows "Anthropic Claude Sonnet 4.5" — weird, now it works?
  5. Run opencode -m openai/gpt-5
    1. UI shows "OpenAI GPT-5" — correct
    2. Press tab to switch agents → UI shows "Anthropic Claude Sonnet 4.5" — bug, last-used model instead of -m model
  6. Run opencode (with no -m and no config "model")
    1. UI shows "OpenAI GPT-5" — correct
    2. Press tab to switch agents → UI shows "OpenAI GPT-5" — weird, now it works?

OpenCode version

1.0.18

Steps to reproduce

(above)

Screenshot and/or share link

No response

Operating System

macOS 15.5

Terminal

VS Code terminal

Originally created by @jdanbrown on GitHub (Nov 3, 2025). Originally assigned to: @thdxr on GitHub. ### Description Related issues from pre-1.0: - https://github.com/sst/opencode/issues/3028 - https://github.com/sst/opencode/issues/1661 Now in 1.0, if I set my model in the config file then the model correctly doesn't change when I switch agents: 1. In config `opencode.jsonc`, set `"model": "anthropic/claude-sonnet-4-5"` 1. Run `opencode` → UI shows "Anthropic Claude Sonnet 4.5" 1. Press `tab` to switch agents → UI still shows "Anthropic Claude Sonnet 4.5" — correct 1. In config `opencode.jsonc`, set `"model": "openai/gpt-5"` 1. Run `opencode` → UI shows "OpenAI GPT-5" 1. Press `tab` to switch agents → UI still shows "OpenAI GPT-5" — correct But if I instead set my model using `-m`/`--model` on the command line, then when I switch agents the model incorrectly changes to the last-used model: 1. Disable config `"model"` setting above 1. Run `opencode` (with no `-m` and no config `"model"`) 1. UI shows "OpenAI GPT-5" — correct, last-used model (from above) 2. Press `tab` to switch agents → UI still shows "OpenAI GPT-5" — correct, last-used model (from above) 1. Run `opencode -m anthropic/claude-sonnet-4-5` 1. UI shows "Anthropic Claude Sonnet 4.5" — correct 2. Press `tab` to switch agents → UI shows "OpenAI GPT-5" — **bug**, last-used model instead of `-m` model 1. Run `opencode` (with no `-m` and no config `"model"`) 1. UI shows "Anthropic Claude Sonnet 4.5" — correct 2. Press `tab` to switch agents → UI shows "Anthropic Claude Sonnet 4.5" — **weird**, now it works? 1. Run `opencode -m openai/gpt-5` 1. UI shows "OpenAI GPT-5" — correct 2. Press `tab` to switch agents → UI shows "Anthropic Claude Sonnet 4.5" — **bug**, last-used model instead of `-m` model 1. Run `opencode` (with no `-m` and no config `"model"`) 1. UI shows "OpenAI GPT-5" — correct 2. Press `tab` to switch agents → UI shows "OpenAI GPT-5" — **weird**, now it works? ### OpenCode version 1.0.18 ### Steps to reproduce (above) ### Screenshot and/or share link _No response_ ### Operating System macOS 15.5 ### Terminal VS Code terminal
yindo added the opentuibug labels 2026-02-16 17:36:13 -05:00
yindo closed this issue 2026-02-16 17:36:13 -05:00
Author
Owner

@github-actions[bot] commented on GitHub (Nov 3, 2025):

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

  • #3857: Similar model configuration issues with CLI (-m flag) vs config file behavior in 1.0
  • #3706: Reports that separate model assignments per agent no longer work after 1.0, which is related to model switching behavior

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

@github-actions[bot] commented on GitHub (Nov 3, 2025): This issue might be a duplicate of existing issues. Please check: - #3857: Similar model configuration issues with CLI (-m flag) vs config file behavior in 1.0 - #3706: Reports that separate model assignments per agent no longer work after 1.0, which is related to model switching behavior Feel free to ignore if none of these address your specific case.
Author
Owner

@jdanbrown commented on GitHub (Nov 4, 2025):

Thanks! Confirmed fixed in 1.0.20.

@jdanbrown commented on GitHub (Nov 4, 2025): Thanks! Confirmed fixed in 1.0.20.
Sign in to join this conversation.
1 Participants
Notifications
Due Date
No due date set.
Dependencies

No dependencies set.

Reference: anomalyco/opencode#2559