Repository navigation
feat(core): let subagents pick a model and expose models tool - #49194
Merged
Merged
Conversation
rekram1-node
force-pushed
the
subagent-model
branch
from
September 16, 2026 05:30
b1aa63b to
0dbd995
Compare
rekram1-node
force-pushed
the
subagent-model
branch
from
September 16, 2026 05:31
0dbd995 to
a46c146
Compare
|
https://github.com/anomalyco/opencode/blob/v2.0.15/packages/core/src/tool/plugin/subagent.ts#L36-L39 |
jinhuang712
pushed a commit
to jinhuang712/opencode
that referenced
this pull request
Sep 26, 2026
This was referenced Oct 1, 2026
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
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. Theopencodenamespace description now mentions model search so agents can find the tool from the catalog header without it being pinned.querymatches every word againstproviderID/modelIDand the display name, so"glm flash"findsglm-5.3-flash.providerfilters by provider id or name.(provider, family)is listed, applied afterquery;all: trueincludes older versions. This removes the "pickedclaude-sonnet-4-6because it was in the list" failure without prompt text about versions.modelon the subagent toolOptional
"providerID/modelID"or"providerID/modelID#variant". Precedence: explicit input > agent's configured model > parent's model; validated againstModel.available()(ref and variant). Passingmodelwhile continuing a child switches its model, mirroring agent switching. Theagentinput now notes that an unrecognized subagent name most likely refers to a model.Identity block
# Your Modelnow readsName / Provider ID / Model IDinstead ofProvider: <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, andopencode/muse-spark-1.3through 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 pathsearch → models → subagentin 4 steps, every lookup-based pick on the agent's own provider and newest version, every control omittingmodel. 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 withall, disabled exclusion),tool-subagent.test.ts(override on create, switch on continue, three validation failures),identity.test.tsand the session-runner cassette for the identity block.