Skip to content

Feature Request: Remember last used model/agent across sessions #10407

Closed

Description

@nxxxsooo

Feature Request

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:

  1. A global preference stored in ~/.local/share/opencode/ (e.g., last_model.json)
  2. 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
  • Use different models for different types of tasks
  • Want their workspace preferences to persist

Activity

  1. github-actions commented on Jan 24, 2026

    @github-actions
    Contributor

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

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

  2. IdrisGit commented on Jan 24, 2026

    @IdrisGit
    Contributor

    @thdxr I can look into this, if it's a valid request.

  3. nxxxsooo commented on Jan 25, 2026

    @nxxxsooo
    Author

    @amio Both approaches would solve my problem:

    • Last used: Zero config, just works
    • 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! 🙏

  4. IdrisGit commented on Jan 25, 2026

    @IdrisGit
    Contributor

    @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.

  5. IdrisGit commented on Jan 25, 2026

    @IdrisGit
    Contributor

    @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.

  6. nxxxsooo commented on Jan 25, 2026

    @nxxxsooo
    Author

    @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:

    1. Have multiple providers configured (e.g., lmstudio, anthropic, google)
    2. Set a default model in config, use opencode, then switch to a different model
    3. Remove the default model from config and restart
    4. Expected: uses last selected model
    5. Actual: falls back to a different provider's model
  7. IdrisGit commented on Jan 25, 2026

    @IdrisGit
    Contributor

    @nxxxsooo will check 👍🏼

  8. IdrisGit commented on Jan 26, 2026

    @IdrisGit
    Contributor

    @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

  9. rekram1-node commented on Jan 26, 2026

    @rekram1-node
    Contributor

    yeah please share:

    opencode debug config

  10. nxxxsooo commented on Feb 6, 2026

    @nxxxsooo
    Author

    @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.

  11. IdrisGit commented on Feb 6, 2026

    @IdrisGit
    Contributor

    yeah a screen recording would be really helpful

  12. github-actions commented on Apr 8, 2026

    @github-actions
    Contributor

    To stay organized issues are automatically closed after 90 days of no activity. If the issue is still relevant please open a new one.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

Labels

No labels
No labels

Type

No type

Projects

No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions