OpenCode Agent toggle does not honor the agent model specification #2345

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

Originally created by @johnelrick-prog on GitHub (Oct 29, 2025).

Description

opencode v0.15.28

Description:
Working through a simple test, I created an agent with the model set to openai/gpt-oss-20b. If I then launch opencode and select the new agent, the selected model is the last built in model selected

Example:
If Plan Agent is set to Claude Sonnet 4.5 and I tab forward, my custom agent is set to Claude Sonnet 4.5
If Build Agent is set to GPT OSS 120B and I tab backward, my custom agent is set to GPT OSS 120B

If I then exit out of OpenCode and restart with the custom agent as the last picked, the system shows GTP OSS 20B. However, this is changed as soon as I tab through the agents and is reset according to the above example.

Expected result:
I would expect that the Agent would always default to the model specified in the .md file in .opencode/agent.

If someone can point me to exactly where this would likely be implemented, I'd be happy to take a look at it myself.

OpenCode version

v0.15.28

Steps to reproduce

  1. Create a very simple new agent and set the model to something other than your normal default. I used the .opencode/agent markdown solution to create the agent.
  2. Open opencode
  3. Cycle tab through the agents until you see your custom agent.
  4. Notice that the model will be the default model and not the one set in the .md file.
  5. Now exit
  6. Open opencode
  7. Notice that the model will match the one you set in the .md file.
  8. Cycle tab through the agents until you see your custom agent.
  9. Notice that the model will be the default model and not the one set in the .md file.

Screenshot and/or share link

No response

Operating System

Ubuntu 22.04

Terminal

bash

Originally created by @johnelrick-prog on GitHub (Oct 29, 2025). ### Description opencode v0.15.28 **Description:** Working through a simple test, I created an agent with the model set to `openai/gpt-oss-20b`. If I then launch `opencode` and select the new agent, the selected model is the last built in model selected **Example:** If Plan Agent is set to Claude Sonnet 4.5 and I tab forward, my custom agent is set to Claude Sonnet 4.5 If Build Agent is set to GPT OSS 120B and I tab backward, my custom agent is set to GPT OSS 120B If I then exit out of OpenCode and restart with the custom agent as the last picked, the system shows GTP OSS 20B. However, this is changed as soon as I tab through the agents and is reset according to the above example. **Expected result:** I would expect that the Agent would always default to the model specified in the `.md` file in `.opencode/agent`. If someone can point me to exactly where this would likely be implemented, I'd be happy to take a look at it myself. ### OpenCode version v0.15.28 ### Steps to reproduce 1. Create a very simple new agent and set the model to something other than your normal default. I used the `.opencode/agent` markdown solution to create the agent. 2. Open `opencode` 3. Cycle tab through the agents until you see your custom agent. 4. Notice that the model will be the default model and not the one set in the .md file. 5. Now exit 6. Open `opencode` 7. Notice that the model will match the one you set in the .md file. 8. Cycle tab through the agents until you see your custom agent. 9. Notice that the model will be the default model and not the one set in the .md file. ### Screenshot and/or share link _No response_ ### Operating System Ubuntu 22.04 ### Terminal bash
yindo added the bug label 2026-02-16 17:35:13 -05:00
yindo closed this issue 2026-02-16 17:35:14 -05:00
Author
Owner

@github-actions[bot] commented on GitHub (Oct 29, 2025):

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

  • #1661: Model switch automatically when changing the mode - This issue describes similar behavior where the model changes when switching between modes/agents
  • #3028: Switch model for all agents - Related issue about model switching behavior across agents
  • #3241: Opencode stuck in Plan mode - Another agent mode switching issue with related behaviors

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

@github-actions[bot] commented on GitHub (Oct 29, 2025): This issue might be a duplicate of existing issues. Please check: - #1661: Model switch automatically when changing the mode - This issue describes similar behavior where the model changes when switching between modes/agents - #3028: Switch model for all agents - Related issue about model switching behavior across agents - #3241: Opencode stuck in Plan mode - Another agent mode switching issue with related behaviors Feel free to ignore if none of these address your specific case.
Author
Owner

@rekram1-node commented on GitHub (Oct 29, 2025):

Yeah I think this is a pretty easy fix I think this is the relevant file: https://github.com/sst/opencode/blob/dev/packages/tui/internal/app/app.go

@rekram1-node commented on GitHub (Oct 29, 2025): Yeah I think this is a pretty easy fix I think this is the relevant file: https://github.com/sst/opencode/blob/dev/packages/tui/internal/app/app.go
Author
Owner

@rekram1-node commented on GitHub (Oct 29, 2025):

PR welcome

@rekram1-node commented on GitHub (Oct 29, 2025): PR welcome
Author
Owner

@johnelrick-prog commented on GitHub (Oct 30, 2025):

Thanks! i'll investigate.

@johnelrick-prog commented on GitHub (Oct 30, 2025): Thanks! i'll investigate.
Author
Owner

@oribarilan commented on GitHub (Oct 30, 2025):

solved in #3572

@oribarilan commented on GitHub (Oct 30, 2025): solved in #3572
Author
Owner

@johnelrick-prog commented on GitHub (Oct 30, 2025):

I'll be interested in seeing this in action. I did conduct an investigation and the problem appeared to be in updateModelForNewAgent.

Personally, I noted the exact opposite of 3571's report - the only way to get the Custom Agent to pick up its defined model was to open opencode with that agent already selected.

FWIW - my fix was to extract the code into a single function and call it from both InitializeProvider and updateModelForNewAgent. I was actually just looking at submitting a pull request when this came through.

Anyhow, I'll wait and pull down the next release - here's hoping this does address the problem I noted.

@johnelrick-prog commented on GitHub (Oct 30, 2025): I'll be interested in seeing this in action. I did conduct an investigation and the problem appeared to be in `updateModelForNewAgent`. Personally, I noted the exact opposite of 3571's report - the only way to get the Custom Agent to pick up its defined model was to open `opencode` with that agent already selected. FWIW - my fix was to extract the code into a single function and call it from both `InitializeProvider` and `updateModelForNewAgent`. I was actually just looking at submitting a pull request when this came through. Anyhow, I'll wait and pull down the next release - here's hoping this does address the problem I noted.
Author
Owner

@johnelrick-prog commented on GitHub (Oct 30, 2025):

@rekram1-node @oribarilan

FYI - I pulled the current code and ran an experiment with a new dummy agent which has the model set to gpt oss 20B.

The current fix does NOT address my reported scenario - tabbing through does not change the Agent to its specified model.

As I am new to this project, what would you like me to do next?

@johnelrick-prog commented on GitHub (Oct 30, 2025): @rekram1-node @oribarilan FYI - I pulled the current code and ran an experiment with a new dummy agent which has the model set to gpt oss 20B. The current fix does NOT address my reported scenario - tabbing through does not change the Agent to its specified model. As I am new to this project, what would you like me to do next?
Author
Owner

@rekram1-node commented on GitHub (Oct 30, 2025):

hm we should fix that then, reopening issue

@rekram1-node commented on GitHub (Oct 30, 2025): hm we should fix that then, reopening issue
Author
Owner

@johnelrick-prog commented on GitHub (Oct 30, 2025):

I believe I discovered the cause of my problem and it's more of a
documentation issue.

After testing numerous times with slog.Debug, I finally determined that I
was not specifying the model correctly. It should have been:

openrouter/openai/gpt-oss-20b

instead of

openai/gpt-oss-20b

Once I added the openrouter prefix, the link worked. The source I was using
didn't use openrouter as a starting point, so it may be using openrouter as
the provider instead of just the openai segment is necessary. I mistakenly
assumed that the system would detect the fact that the only
openai/gpt-oss-20b in the listing was via openrouter.

I can say that with this extra link in place, the system appears to be
working correctly regardless of the version I run.

I would consider this more of a documentation issue now than a bug in the
system. Thanks for all your help and direction - it's been interesting
poking about the code.

On Thu, Oct 30, 2025 at 2:34 PM Aiden Cline @.***>
wrote:

rekram1-node left a comment (sst/opencode#3550)
https://github.com/sst/opencode/issues/3550#issuecomment-3469507020

hm we should fix that then, reopening issue


Reply to this email directly, view it on GitHub
https://github.com/sst/opencode/issues/3550#issuecomment-3469507020, or
unsubscribe
https://github.com/notifications/unsubscribe-auth/BZOWFGR5U7FT66Z3P3J2NEL32JK4XAVCNFSM6AAAAACKTBGXGSVHI2DSMVQWIX3LMV43OSLTON2WKQ3PNVWWK3TUHMZTINRZGUYDOMBSGA
.
You are receiving this because you authored the thread.Message ID:
@.***>

@johnelrick-prog commented on GitHub (Oct 30, 2025): I believe I discovered the cause of my problem and it's more of a documentation issue. After testing numerous times with slog.Debug, I finally determined that I was not specifying the model correctly. It should have been: openrouter/openai/gpt-oss-20b instead of openai/gpt-oss-20b Once I added the openrouter prefix, the link worked. The source I was using didn't use openrouter as a starting point, so it may be using openrouter as the provider instead of just the openai segment is necessary. I mistakenly assumed that the system would detect the fact that the only openai/gpt-oss-20b in the listing was via openrouter. I can say that with this extra link in place, the system appears to be working correctly regardless of the version I run. I would consider this more of a documentation issue now than a bug in the system. Thanks for all your help and direction - it's been interesting poking about the code. On Thu, Oct 30, 2025 at 2:34 PM Aiden Cline ***@***.***> wrote: > *rekram1-node* left a comment (sst/opencode#3550) > <https://github.com/sst/opencode/issues/3550#issuecomment-3469507020> > > hm we should fix that then, reopening issue > > — > Reply to this email directly, view it on GitHub > <https://github.com/sst/opencode/issues/3550#issuecomment-3469507020>, or > unsubscribe > <https://github.com/notifications/unsubscribe-auth/BZOWFGR5U7FT66Z3P3J2NEL32JK4XAVCNFSM6AAAAACKTBGXGSVHI2DSMVQWIX3LMV43OSLTON2WKQ3PNVWWK3TUHMZTINRZGUYDOMBSGA> > . > You are receiving this because you authored the thread.Message ID: > ***@***.***> >
Author
Owner

@rekram1-node commented on GitHub (Oct 30, 2025):

Ahh that makes sense, we try to document in a few places that you always need the provider prefix, for future reference if you run opencode models you can see the models u have available.

@rekram1-node commented on GitHub (Oct 30, 2025): Ahh that makes sense, we try to document in a few places that you always need the provider prefix, for future reference if you run `opencode models` you can see the models u have available.
Author
Owner

@oribarilan commented on GitHub (Oct 31, 2025):

@rekram1-node
This happened to me when I first used opencode. Do you have any thoughts on improving this UX?
For example, notifying the user that the specified model is not available, falling back to x... (i dont think there is an existing notification flow in the UI though)

@oribarilan commented on GitHub (Oct 31, 2025): @rekram1-node This happened to me when I first used opencode. Do you have any thoughts on improving this UX? For example, notifying the user that the specified model is not available, falling back to x... (i dont think there is an existing notification flow in the UI though)
Author
Owner

@johnelrick-prog commented on GitHub (Oct 31, 2025):

I was thinking about that last night. After 44 years in software
development, the core thing I've taken away is that you cannot debug code,
you can only debug data transformations. In this case, the missing
information would be some indicator that says "cannot find
{provider}/{model} in available providers. Falling back to {fallback}. Use
opencode models for a complete list of known models."

It might also be useful (if noisey) to put the actual full provider/model
path in small font in the list under the more Human Friendly name.

The downside is that it's a lot to do for an error someone is only likely
to make once - I understand it now so I won't make it again. On the other
hand, it lowers the barrier; I did spend a (productive) day digging through
dev log outputs before I finally hit the insight that the provider string
might contain the prefix as well. The downside is that I used up a day
trying to figure out what was wrong. The upside is I have a lot better
understanding of some of the things going on under the hood.

On Fri, Oct 31, 2025 at 2:33 AM oribi @.***> wrote:

oribarilan left a comment (sst/opencode#3550)
https://github.com/sst/opencode/issues/3550#issuecomment-3471512217

@rekram1-node https://github.com/rekram1-node
This happened to me when I first used opencode. Do you have any thoughts
on improving this UX?
For example, notifying the user that the specified model is not available,
falling back to x... (i dont think there is an existing notification flow
in the UI though)


Reply to this email directly, view it on GitHub
https://github.com/sst/opencode/issues/3550#issuecomment-3471512217, or
unsubscribe
https://github.com/notifications/unsubscribe-auth/BZOWFGVOU5UCRM2XCVWUVSD32L7CBAVCNFSM6AAAAACKTBGXGSVHI2DSMVQWIX3LMV43OSLTON2WKQ3PNVWWK3TUHMZTINZRGUYTEMRRG4
.
You are receiving this because you authored the thread.Message ID:
@.***>

@johnelrick-prog commented on GitHub (Oct 31, 2025): I was thinking about that last night. After 44 years in software development, the core thing I've taken away is that you cannot debug code, you can only debug data transformations. In this case, the missing information would be some indicator that says "cannot find {provider}/{model} in available providers. Falling back to {fallback}. Use `opencode models` for a complete list of known models." It might also be useful (if noisey) to put the actual full provider/model path in small font in the list under the more Human Friendly name. The downside is that it's a lot to do for an error someone is only likely to make once - I understand it now so I won't make it again. On the other hand, it lowers the barrier; I did spend a (productive) day digging through dev log outputs before I finally hit the insight that the provider string might contain the prefix as well. The downside is that I used up a day trying to figure out what was wrong. The upside is I have a lot better understanding of some of the things going on under the hood. On Fri, Oct 31, 2025 at 2:33 AM oribi ***@***.***> wrote: > *oribarilan* left a comment (sst/opencode#3550) > <https://github.com/sst/opencode/issues/3550#issuecomment-3471512217> > > @rekram1-node <https://github.com/rekram1-node> > This happened to me when I first used opencode. Do you have any thoughts > on improving this UX? > For example, notifying the user that the specified model is not available, > falling back to x... (i dont think there is an existing notification flow > in the UI though) > > — > Reply to this email directly, view it on GitHub > <https://github.com/sst/opencode/issues/3550#issuecomment-3471512217>, or > unsubscribe > <https://github.com/notifications/unsubscribe-auth/BZOWFGVOU5UCRM2XCVWUVSD32L7CBAVCNFSM6AAAAACKTBGXGSVHI2DSMVQWIX3LMV43OSLTON2WKQ3PNVWWK3TUHMZTINZRGUYTEMRRG4> > . > You are receiving this because you authored the thread.Message ID: > ***@***.***> >
Author
Owner

@rekram1-node commented on GitHub (Oct 31, 2025):

@oribarilan yeah we should notify about that, or hard error and tell them why

@rekram1-node commented on GitHub (Oct 31, 2025): @oribarilan yeah we should notify about that, or hard error and tell them why
Sign in to join this conversation.
1 Participants
Notifications
Due Date
No due date set.
Dependencies

No dependencies set.

Reference: anomalyco/opencode#2345