Skip to content

feat(core): let subagents pick a model and expose models tool - #49194

Merged
rekram1-node merged 10 commits into
v2from
subagent-model
Sep 16, 2026
Merged

rekram1-node merged 10 commits into
v2from
subagent-model

Conversation

@rekram1-node

@rekram1-node rekram1-node commented Sep 15, 2026 •

Copy link
Copy Markdown
Collaborator

Follow-up to #49129. Lets an agent resolve a model the user names loosely ("luna", "glm flash", "sonnet with high reasoning") into an exact reference on its own provider, and run a subagent on it.

tools.opencode.models({ query?, provider?, all?, limit?, offset? })

Codemode tool. Output is grouped by provider — { providers: [{ id, name, models: [{ id: "providerID/modelID", name, released, variants, cost, status }] }], total, next } — the caller's own provider first, then alphabetical, newest first within each provider. The opencode namespace description now mentions model search so agents can find the tool from the catalog header without it being pinned.

  • query matches every word against providerID/modelID and the display name, so "glm flash" finds glm-5.3-flash.
  • provider filters by provider id or name.
  • By default only the newest model per (provider, family) is listed, applied after query; all: true includes older versions. This removes the "picked claude-sonnet-4-6 because it was in the list" failure without prompt text about versions.
  • Paging over the ordered list; default 20, max 100.

model on the subagent tool

Optional "providerID/modelID" or "providerID/modelID#variant". Precedence: explicit input > agent's configured model > parent's model; validated against Model.available() (ref and variant). Passing model while continuing a child switches its model, mirroring agent switching. The agent input now notes that an unrecognized subagent name most likely refers to a model.

Identity block

# Your Model now reads Name / Provider ID / Model ID instead of Provider: <display name>. Agents were passing the first word of the display name ("anomaly") as a provider filter and getting zero results.

Evaluation

Drove opencode/gpt-5.6-luna, opencode/glm-5.3-flash, and opencode/muse-spark-1.3 through the HTTP API on nickname prompts that never mention a provider, plus a control with no model named. Scored by the child session's actual model. Baseline (tool present, first wording) was 9/15: refs guessed from memory (anthropic/claude-sonnet-4-5, muse/spark, opencode/luna), wrong providers, stale versions. Final configuration: 86/90 across six rounds, typical path search → models → subagent in 4 steps, every lookup-based pick on the agent's own provider and newest version, every control omitting model. Every miss was a run that never called the tool (guessed a reference from memory or shelled out to the installed CLI); every run that used the tool picked correctly.

Tests: tool-opencode.test.ts (grouping, paging across a group boundary, provider by id/name, multi-word query, family collapsing with all, disabled exclusion), tool-subagent.test.ts (override on create, switch on continue, three validation failures), identity.test.ts and the session-runner cassette for the identity block.

@rekram1-node rekram1-node changed the title feat(core): let subagents pick a model and expose model_list feat(core): let subagents pick a model and expose models tool Sep 15, 2026
@rekram1-node
rekram1-node merged commit 7d7962b into v2 Sep 16, 2026
10 checks passed
@rekram1-node
rekram1-node deleted the subagent-model branch September 16, 2026 06:16
@trin4ik

trin4ik commented Sep 23, 2026

Copy link
Copy Markdown

https://github.com/anomalyco/opencode/blob/v2.0.15/packages/core/src/tool/plugin/subagent.ts#L36-L39
What is the point of using such wording? "NEVER" breaks the spawning of sub-agents for skills using the specified model.

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

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants