You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
{{ message }}
Repository navigation
Feature Request: Remember last used model/agent across sessions #10407
Is your feature request related to a problem?
When starting OpenCode, it always uses the default model/agent from config, even if the user switched to a different model in the previous session. Users have to manually switch models every time they start a new session.
Describe the solution you'd like
OpenCode should remember the last used model/agent and restore it when starting a new session. This could be:
A global preference stored in ~/.local/share/opencode/ (e.g., last_model.json)
Or a config option like remember_last_model: true in opencode.json or oh-my-opencode.json
Describe alternatives you've considered
Currently users must manually edit config files to change the default model, which is inconvenient for those who frequently switch between models.
Additional context
This would greatly improve UX for users who:
Switch between local models (LMStudio) and cloud models
Favorites: More control, useful if you switch between specific models often
Happy to go with whatever @thdxr thinks fits better with OpenCode's direction.
Also, the current "Recents" section feels a bit confusing - when scrolling through the model list, I sometimes think my model config is broken, only to realize it just moved to Recents. A dedicated favorites list with quick switching would be much clearer.
@IdrisGit Thanks for offering to look into this! 🙏
@nxxxsooo regarding the "Recent" section issue, I have a open PR (#10518) for it, check it out and do give your feedback, if you like the solution thumbsup the PR.
@IdrisGit I tested removing the default model from config. After restart, it didn't use my last selected model - instead it fell back to a different provider's model (anthropic/Opus 4.5).
It seems like the "last used" part of the selection order (config → last used → provider fallback) isn't working, and it's jumping straight to provider fallback.
Steps to reproduce:
Have multiple providers configured (e.g., lmstudio, anthropic, google)
Set a default model in config, use opencode, then switch to a different model
Remove the default model from config and restart
Expected: uses last selected model
Actual: falls back to a different provider's model
@nxxxsooo I tried the steps you mentioned, seems to be working fine for me, can you please share your opencode version, a screenrecoding of the issue would be much helpful as well
So I have 3 providers (lmstudio, google, claudecode-relay) with a default model set. During a session I switch to e.g. a lmstudio model, then restart — it goes back to the config default instead of remembering the last used model.
I understand the intended order is config → last used → provider fallback, but the "last used" step seems to not persist across restarts for me. Happy to provide a screen recording if this config info isn't enough to reproduce.
Activity
github-actions commentedon Jan 24, 2026
This issue might be a duplicate of existing issues. Please check:
Feel free to ignore if none of these address your specific case.
IdrisGit commentedon Jan 24, 2026
@thdxr I can look into this, if it's a valid request.
nxxxsooo commentedon Jan 25, 2026
@amio Both approaches would solve my problem:
Happy to go with whatever @thdxr thinks fits better with OpenCode's direction.
Also, the current "Recents" section feels a bit confusing - when scrolling through the model list, I sometimes think my model config is broken, only to realize it just moved to Recents. A dedicated favorites list with quick switching would be much clearer.
@IdrisGit Thanks for offering to look into this! 🙏
IdrisGit commentedon Jan 25, 2026
@nxxxsooo so I misread the issue a bit, I thought the model was not loading from the config.
The behaviour is very much intended, here is the order of model selection on startup or new session, config —> last used —> provider fallback.
If you want to always use the last model used, just remove the default model from config.
If your issue is something else, can please provide steps to reproduce.
IdrisGit commentedon Jan 25, 2026
@nxxxsooo regarding the "Recent" section issue, I have a open PR (#10518) for it, check it out and do give your feedback, if you like the solution thumbsup the PR.
nxxxsooo commentedon Jan 25, 2026
@IdrisGit I tested removing the default model from config. After restart, it didn't use my last selected model - instead it fell back to a different provider's model (anthropic/Opus 4.5).
It seems like the "last used" part of the selection order (config → last used → provider fallback) isn't working, and it's jumping straight to provider fallback.
Steps to reproduce:
IdrisGit commentedon Jan 25, 2026
@nxxxsooo will check 👍🏼
IdrisGit commentedon Jan 26, 2026
@nxxxsooo I tried the steps you mentioned, seems to be working fine for me, can you please share your opencode version, a screenrecoding of the issue would be much helpful as well
rekram1-node commentedon Jan 26, 2026
yeah please share:
opencode debug config
nxxxsooo commentedon Feb 6, 2026
@IdrisGit @rekram1-node
Version: 1.1.53 (macOS, Apple Silicon)
Config (providers/MCP redacted):
{ "provider": { "lmstudio": { "options": { "baseURL": "http://127.0.0.1:1234/v1" }, "models": { "qwen3-30b-a3b-instruct-2507": { ... }, "codestral-22b-v0.1": { ... }, "qwen2.5-72b-instruct@4bit": { ... }, "deepseek-r1-distill-llama-70b": { ... } } }, "google": { "models": { "antigravity-gemini-3-pro": { ... }, "antigravity-gemini-3-flash": { ... }, "gemini-2.5-flash": { ... }, "gemini-2.5-pro": { ... }, "gemini-3-flash-preview": { ... }, "gemini-3-pro-preview": { ... } } }, "claudecode-relay": { "npm": "@ai-sdk/anthropic", "models": { "claude-opus-4-6": { ... }, "claude-opus-4-5-20251101": { ... }, "claude-opus-4-1-20250805": { ... }, "claude-opus-4-20250514": { ... }, "claude-sonnet-4-5-20250929": { ... }, "claude-sonnet-4-20250514": { ... }, "claude-haiku-4-5-20251001": { ... }, "claude-3-5-haiku-20241022": { ... }, "claude-3-5-sonnet-20241022": { ... }, "claude-3-7-sonnet-20250219": { ... }, "claude-3-haiku-20240307": { ... }, "claude-3-opus-20240229": { ... } } } }, "model": "claudecode-relay/claude-opus-4-5-20251101" }So I have 3 providers (lmstudio, google, claudecode-relay) with a default model set. During a session I switch to e.g. a lmstudio model, then restart — it goes back to the config default instead of remembering the last used model.
I understand the intended order is config → last used → provider fallback, but the "last used" step seems to not persist across restarts for me. Happy to provide a screen recording if this config info isn't enough to reproduce.
IdrisGit commentedon Feb 6, 2026
yeah a screen recording would be really helpful
github-actions commentedon Apr 8, 2026
To stay organized issues are automatically closed after 90 days of no activity. If the issue is still relevant please open a new one.