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.