--model is ignored when resuming a session with --session · Issue #53806 · anomalyco/opencode · GitHub
Skip to content

--model is ignored when resuming a session with --session #53806

Closed as not planned

Description

@glmn

Description

When a session is resumed with --session <id> --model <provider/model>, the --model flag is ignored: the TUI switches to the model of the session's last user message, and the next prompt is sent to that model.

--agent is already kept in this case (// Keep command line --agent if specified. in packages/tui/src/component/prompt/index.tsx), but the model from the last message is applied unconditionally right below it.

This matters for anything that relaunches OpenCode on an existing session with a different model (I hit it in an app that runs OpenCode in a terminal and restarts it with --session when the user changes the model).

OpenCode version

1.18.35 (also current dev)

Steps to reproduce

  1. opencode run --model provider-a/model-a "hi" (creates a session whose messages use model-a)
  2. opencode --session <that id> --model provider-b/model-b
  3. The footer shows model-a; send a prompt — the request goes to model-a, not model-b.

Operating System

Windows 10 (the code path is platform-independent)

Terminal

Windows Terminal

Activity

  1. opencode-agent commented on Oct 7, 2026

    @opencode-agent
    Contributor

    Thanks for the detailed report and for finding the exact code path.

    This is about OpenCode v1 (1.18.35). v1 now only gets fixes for critical bugs such as data loss, security problems or breakage with no workaround. Since the model can still be switched in the TUI after resuming, this one is unlikely to be fixed in v1.

    Please consider moving to v2 (@opencode/cli, the opencode command). It's a separate implementation and handles startup flags differently: --agent and --model are applied when the app starts, before it opens the --session session. If you can reproduce the problem on v2 (2.x), or you think it is critical, please reply here with the v2 version and steps.

    Related issues, most closely related first:

  2. glmn commented on Oct 7, 2026

    @glmn
    Author

    Thanks. Checked on v2 (@opencode/cli 2.0.24, Windows, --standalone, a local OpenAI-compatible stub with two providers):

    • opencode mini -s <id> --model fakeb/mb on a session last used with fakea/ma: footer shows model B and the next request goes to mb. So v2's mini interface handles it.
    • The default v2 interface doesn't accept --model / --agent at all (opencode --standalone -s <id> --model … prints the usage), so there's nothing to reproduce there.

    Closing #53807 since v1 won't take it. One question for v2, if it's useful: are --model / --agent planned for the full interface too (as in mini)? Wrappers that relaunch OpenCode on an existing session with a different model need one of them.

  3. opencode-agent commented on Oct 7, 2026

    @opencode-agent
    Contributor

    Thanks for testing on v2. Good to know that opencode mini -s <id> --model … works there.

    To answer your question: the full v2 interface doesn't support --model / --agent yet, and that's already tracked:

    The v2 interface code already applies --model and --agent before it opens the --session session. So once the main command accepts these flags, relaunching on an existing session with a different model should work like mini does. I can't promise when that will happen. Until then, opencode mini is the way to do this on v2. You could also add a 👍 or your use case on #53728.

    The v1 behaviour reported here is still unlikely to be fixed, since v1 only gets critical fixes. This issue will be closed on that basis.

  4. opencode-agent commented on Oct 8, 2026

    @opencode-agent
    Contributor

    Closing this as not planned. It's a v1 (1.18.35) behaviour, v1 only gets critical fixes, and there's a workaround: you can switch the model after resuming.

    On v2, your test showed that opencode mini -s <id> --model … already keeps the requested model. Support for --model / --agent on the full v2 interface is tracked in #53728, and there's an open PR adding --model there in #48163. Please follow those for your wrapper use case.

    Thanks for the clear report and for checking it on v2. If you see this again on v2, please open a new issue.

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

Metadata

Metadata

Assignees

Type

No type

Projects

No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions