3
43
Fork
You've already forked opencode.el
16

Last used model not preserved for the session #15

Closed
opened 2026年01月18日 11:42:33 +01:00 by daut · 8 comments
Contributor
Copy link

Hey, thanks for this awesome package. I've been testing it lately and it works great so far!

I noticed a minor behavior difference between opencode TUI and this package: the last used model is not preserved when resuming a session. It seems to always revert to the default model

Is this a bug, or did I miss a configuration option?

Thanks!

Hey, thanks for this awesome package. I've been testing it lately and it works great so far! I noticed a minor behavior difference between opencode TUI and this package: the last used model is not preserved when resuming a session. It seems to always revert to the default model Is this a bug, or did I miss a configuration option? Thanks!
Owner
Copy link

I just added restoring the last model used when you resume a session. I also changed the model setting to be per agent per session, as the TUI is, rather than just per session as I had it before, so now you can set a different model for build and plan mode easier.

I just added restoring the last model used when you resume a session. I also changed the model setting to be per agent per session, as the TUI is, rather than just per session as I had it before, so now you can set a different model for build and plan mode easier.
Author
Contributor
Copy link

Thanks!

One more thing I've noticed is that the TUI selects the most recently used model as the default for a new session. I'm not sure if that's ideal default behavior, but it's something I've gotten used to. Maybe it's worth supporting, at least via an optional flag.

Thanks! One more thing I've noticed is that the TUI selects the most recently used model as the default for a new session. I'm not sure if that's ideal default behavior, but it's something I've gotten used to. Maybe it's worth supporting, at least via an optional flag.
Owner
Copy link

The way I have it right now, new sessions will inherit the agent/model settings of the buffer you spawn it from. So if you call opencode-new-session from some existing session buffer, it will get the same model settings.
When you call opencode-new-session from anywhere else, it will get the default settings, which the default model you have configured in opencode for a given agent, and if one isn't configured, then opencode-default-model which you can configure in emacs and we default to big pickle.

The way I have it right now, new sessions will inherit the agent/model settings of the buffer you spawn it from. So if you call `opencode-new-session` from some existing session buffer, it will get the same model settings. When you call `opencode-new-session` from anywhere else, it will get the default settings, which the default model you have [configured in opencode for a given agent](https://opencode.ai/docs/agents/#model), and if one isn't configured, then `opencode-default-model` which you can configure in emacs and we default to big pickle.
Owner
Copy link

I realized my previous commit was pretty incomplete, ie if you had a session where you set build agent to glm 4.7 and plan mode to minimax, and the last message was using plan mode, when you reopen the session, it would now set the model to minimax but in build mode, and plan mode would still have the default model. Now it actually restores whatever model was last used with each agent in a session, and sets the agent to the one from the last message.

I realized my previous commit was pretty incomplete, ie if you had a session where you set build agent to glm 4.7 and plan mode to minimax, and the last message was using plan mode, when you reopen the session, it would now set the model to minimax but in build mode, and plan mode would still have the default model. Now it actually restores whatever model was last used with each agent in a session, and sets the agent to the one from the last message.
Author
Contributor
Copy link

@daut wrote in #15 (comment):

Thanks!

One more thing I've noticed is that the TUI selects the most recently used model as the default for a new session. I'm not sure if that's ideal default behavior, but it's something I've gotten used to. Maybe it's worth supporting, at least via an optional flag.

To clarify a bit: This is default behavior when no default model has been selected in opencode.json. If there is one, then the TUI behaves the same way opencode.el does. So maybe having the most recently used model as a fallback, before relying on opencode-default-model, would more closely match how the TUI behaves.

@daut wrote in https://codeberg.org/sczi/opencode.el/issues/15#issuecomment-9961785: > Thanks! > > One more thing I've noticed is that the TUI selects the most recently used model as the default for a new session. I'm not sure if that's ideal default behavior, but it's something I've gotten used to. Maybe it's worth supporting, at least via an optional flag. To clarify a bit: This is default behavior when no default model has been selected in `opencode.json`. If there is one, then the TUI behaves the same way `opencode.el` does. So maybe having the most recently used model as a fallback, before relying on `opencode-default-model`, would more closely match how the TUI behaves.
Owner
Copy link

Yea that'd probably be slightly nicer, then opencode-default-model would never be used except on the very first run, it'd always fallback to the most recently used model. So I could just get rid of opencode-default-model and users have one less thing to configure, and if they want the behavior of opencode-default-model then they can just configure that in opencode.json

Yea that'd probably be slightly nicer, then `opencode-default-model` would never be used except on the very first run, it'd always fallback to the most recently used model. So I could just get rid of `opencode-default-model` and users have one less thing to configure, and if they want the behavior of `opencode-default-model` then they can just configure that in `opencode.json`
Owner
Copy link

it should work like that now

it should work like that now
Author
Contributor
Copy link

works smoothly now

works smoothly now
Sign in to join this conversation.
No Branch/Tag specified
main
No results found.
Labels
Clear labels
No items
No labels
Milestone
Clear milestone
No items
No milestone
Projects
Clear projects
No items
No project
Assignees
Clear assignees
No assignees
2 participants
Notifications
Due date
The due date is invalid or out of range. Please use the format "yyyy-mm-dd".

No due date set.

Dependencies

No dependencies set.

Reference
sczi/opencode.el#15
Reference in a new issue
sczi/opencode.el
No description provided.
Delete branch "%!s()"

Deleting a branch is permanent. Although the deleted branch may continue to exist for a short time before it actually gets removed, it CANNOT be undone in most cases. Continue?