Skip to content

fix(tui): respect model-agent selection in the home screen - #4741

Closed
ucirello wants to merge 2 commits into
anomalyco:devfrom
ucirello:fix-tui-model-agent-selection
Closed

ucirello wants to merge 2 commits into
anomalyco:devfrom
ucirello:fix-tui-model-agent-selection

Conversation

@ucirello

@ucirello ucirello commented Nov 25, 2025 •

Copy link
Copy Markdown
Contributor

This PR restores the agent-model tuple switching behavior of pre-v1.0.

Closes #4344

@ucirello ucirello changed the title fix(tui): respect model-agent selection in the home screen DNM fix(tui): respect model-agent selection in the home screen Nov 25, 2025
@ucirello

Copy link
Copy Markdown
Contributor Author

Overlaps with #4514 - please close this one if that one is the desired fix.

@rekram1-node

Copy link
Copy Markdown
Collaborator

@ucirello is this still a wip?

Also if you wanna get it into the correct state ill just close the AI one that was a one shot and a poor one

@ucirello

Copy link
Copy Markdown
Contributor Author

@rekram1-node - it is good, in the sense that I think it is write. But I didn't want to crowd the AI attempt out. I am going to mark this as ready to review.

@ucirello
ucirello marked this pull request as ready for review November 26, 2025 16:06
@ucirello ucirello changed the title DNM fix(tui): respect model-agent selection in the home screen fix(tui): respect model-agent selection in the home screen Nov 26, 2025
@ucirello

Copy link
Copy Markdown
Contributor Author

@rekram1-node -- I will make one more set of tests, and then I'd ping you, if that's OK.

@rekram1-node

Copy link
Copy Markdown
Collaborator

yeah no problem ping me anytime

@ucirello

Copy link
Copy Markdown
Contributor Author

ams

@rekram1-node I think it is OK now.

@rekram1-node

rekram1-node commented Nov 26, 2025 •

Copy link
Copy Markdown
Collaborator

This does introduce a regression, and note that none of my agents have a hardcoded model id.

Now my model selections are persisted but not used

regression.mov

@ucirello
ucirello marked this pull request as draft November 26, 2025 16:59
@ucirello

Copy link
Copy Markdown
Contributor Author

@rekram1-node -- moving this to WIP, and digging harder for the issue.

@ucirello

Copy link
Copy Markdown
Contributor Author

@rekram1-node -- I dug further - and I think I validated the behavior thoroughly.

validation

@ucirello
ucirello marked this pull request as ready for review November 26, 2025 17:50
@rekram1-node

Copy link
Copy Markdown
Collaborator

But now if I switch agents and don't have a model set in my config, it resets the model each time.

Also it isn't a huge deal but it wipes your last used model for people so if someone upgraded and opened opencode it wouldnt start up with their actual last used model

@ucirello

ucirello commented Nov 26, 2025 •

Copy link
Copy Markdown
Contributor Author

@rekram1-node -- thank you for working with me. Let me try it harder - thank you.

@ucirello
ucirello marked this pull request as draft November 26, 2025 18:36
@ucirello

Copy link
Copy Markdown
Contributor Author

OK - as of c427ada, I think each agent remembers its own model selection independently, so switching between agents no longer causes one agent's model to leak into another. I tested this by assigning different models to Build, Plan, and Docs, then cycling through them repeatedly to confirm no cross-contamination. I also verified that agents with hard-coded models in their config files cannot be overridden through the UI. Then, I sent messages to each agent and confirmed the responses matched the expected model. At last, I check for the persistence across restarts and simulated an upgrade scenario where an existing user with only recent history (no per-agent selections) correctly falls back to their last-used model while hard-coded agents would still take precedence.

validation

@ucirello
ucirello marked this pull request as ready for review November 26, 2025 19:54
@ucirello

Copy link
Copy Markdown
Contributor Author

@rekram1-node I should be closer - I tried to test more scenarios, and I tried to find some more. If there is a regression, then I guess it wouldn't be an obvious one. We are getting closer - thanks for working with me.

@rekram1-node

Copy link
Copy Markdown
Collaborator

sounds good, want me to take another look?

@ucirello

Copy link
Copy Markdown
Contributor Author

@rekram1-node -- yes please.

@rekram1-node

Copy link
Copy Markdown
Collaborator

Now if I hardcode a model and switch to the agent with hardcoded model the model doesnt change to the specified one

@ucirello

ucirello commented Nov 26, 2025 •

Copy link
Copy Markdown
Contributor Author

Now if I hardcode a model and switch to the agent with hardcoded model the model doesnt change to the specified one

Also it seems I found a bug in current release that models set in opencode.json aren't being used as default either.

I will try and address these two additional cases.

@ucirello

Copy link
Copy Markdown
Contributor Author

@rekram1-node

I covered these scenarios:

  • no model in opencode.json
  • model in opencode.json
  • seeing agents-models pairs correctly switching in home screen, and confirming that agents with hard-coded models can't be overriden.
  • seeing agents-models pairs correctly switching in chat screen, and confirming that agents with hard-coded models can't be overriden.
  • one upgrade path (when only recent model is declared)
  • corner-case: hard-coded model in agent file set after model has been chosen for the given agent.

Is there any other scenario that I should cover?

validation-20251127

@ucirello
ucirello marked this pull request as ready for review November 27, 2025 20:29
@rekram1-node

Copy link
Copy Markdown
Collaborator

@ucirello so close this is almost perfect. Only thing now is that if I hardcode an agent model, then i have that agent selected, then try to change models. It is impossible to do now

@ucirello

ucirello commented Nov 29, 2025 •

Copy link
Copy Markdown
Contributor Author

@rekram1-node -- thank you for checking it and for working with me. We'll get there! Ping when I am done with this round of changes.

@ucirello
ucirello marked this pull request as draft November 29, 2025 04:34
@ucirello

ucirello commented Dec 1, 2025

Copy link
Copy Markdown
Contributor Author

@rekram1-node - Please take a look at 07c448b ?

I had a bit of a hard time to think what the appropriate behavior would be to address this:

Only thing now is that if I hardcode an agent model, then i have that agent selected, then try to change models. It is impossible to do now

@ucirello
ucirello marked this pull request as ready for review December 1, 2025 16:34
@rekram1-node

Copy link
Copy Markdown
Collaborator

Yeah this still has bugs:

switch model, tab through agents, 2 agents will have the new model, 3rd one wont. (None of the agents have hardcoded models and "model" isn't set in config).

The agents I am referring to are ones in this repo: build, plan, docs

@ucirello

Copy link
Copy Markdown
Contributor Author

I plan to get back to this at a later date. I will close this PR and re-open it when I pick this up.

@ucirello ucirello closed this Dec 16, 2025
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

Selected model for agent in TUI doesn't stick between Agent Alternation

2 participants