Skip to content

fix(core): use the agent's model when a session has none - #58355

Merged
rekram1-node merged 1 commit into
devfrom
agent-model
Oct 23, 2026
Merged

rekram1-node merged 1 commit into
devfrom
agent-model

Conversation

@rekram1-node

@rekram1-node rekram1-node commented Oct 23, 2026 •

Copy link
Copy Markdown
Contributor

Problem

An agent's model setting (config agents.<id>.model or agent frontmatter) was ignored when a session started without a model, so opencode run and opencode run --agent <id> always used the server's default model. Only the TUI applied it, on the client side.

Change

 session has no model:
+  1. the agent's model, if it's available
   2. config "model"
   3. newest released model that supports text

SessionRunnerModel.resolve checks the session agent's model before falling back to the resolver. If the agent's model isn't in the available list, it falls back the same way as before.

Out of scope

  • run --agent X --variant V without --model still asks the model.default endpoint, which doesn't know about the agent.

Verification

  • bun typecheck in packages/core
  • Session generate, title, native, compaction, subagent and execution tests pass
  • With agents.build.model set to opencode/gpt-6.1-sol in a project config, bun run dev run --standalone "reply ok" picks gpt-6.1-sol

Fixes #55727
Fixes #42561


Added by the opencode bot (AI-generated).

Related: #51326, #47071, #49765, #53060

@opencode-agent opencode-agent Bot left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Looks good. I reproduced #55727 on the base with the bot's stub-provider script, run from source: opencode run --standalone with the default agent, --agent plan and --agent reviewer (frontmatter model) all sent the default model-a instead of the agent's model-b. With this PR all three use and send model-b, and -m still overrides. The nearby core tests pass, and the core package type-checks with typecheck:tsc.

Public API is unchanged: no config keys, flags, endpoints or events change. Only the default model for a session without an explicit model now comes from the agent first.

No blocking concerns.

Related: #51326, #47071, #49765, #53060

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

Labels

None yet

Projects

None yet

1 participant