anomalyco / anomalyco/opencode
v2: subagent spawn ignores agents.*.model and uses parent session model
Nobody has claimed this yet.
- Dominant language
- TypeScript
- Stars
- 209k
- Forks
- 27.5k
- PR merge metrics
- PR metrics pending
Description
Description
On OpenCode 2.0.8, agents.<name>.model is loaded into the agent catalog but is not applied when a subagent is spawned.
GET /api/agent shows the configured model on general / explore. The child session still runs with the parent session model. The parent variant is also dropped (#xhigh → #default).
This matches the V2 agents docs ("a subagent uses its configured model, or inherits the parent session model when none is configured") but not the current runner, which resolves only session.model.
The parent subagent tool schema also says not to pass model unless the user names one, so the configured agent model is never applied on the default path.
Related: #21952 #36250 #36289 #37797. Those were mostly V1; this is a V2 2.0.8 regression/gap.
Plugins
None
OpenCode version
2.0.8 (OpenCode Desktop, latest)
Steps to reproduce
- Set the primary session to model A, with a non-default variant (example:
provider-a/model-a#xhigh). - Pin a different model B on the built-in subagents in
opencode.jsonc:
{
"agents": {
"general": {
"mode": "subagent",
"model": "provider-b/model-b#high"
},
"explore": {
"mode": "subagent",
"model": "provider-b/model-b#high"
}
}
}
- Start a new session. Confirm the catalog:
GET /api/agent
general / explore resolve to provider-b/model-b with variant high.
- Ask the primary agent to spawn
generalorexplore. Do not name a model in the prompt (so thesubagenttool does not receivemodel). - Inspect the child session:
GET /api/session/{childID}
Expected Behavior
Child session uses the agent catalog model: provider-b/model-b#high.
Actual Behavior
Child session uses the parent model with variant reset:
- parent:
provider-a/model-a#xhigh - child
generalsessions:provider-a/model-a#default
Observed on three child sessions from one parent. Reproducible, not intermittent. Custom providers were used in the original run; the mismatch is catalog model B vs spawned session model A.
packages/core/src/session/runner/model.ts (SessionRunnerModel.resolve) selects from session.model only. agent.model is never consulted. packages/core/src/tool/builtins.ts still lists task as not ported.
Screenshot and/or share link
N/A. API evidence (IDs generalized):
GET /api/agent
→ general.model = { id: model-b, providerID: provider-b, variant: high }
GET /api/session/{child}
→ agent=general, model={ id: model-a, providerID: provider-a, variant: default }
Operating System
Windows 11 (10.0.26200.9457)
Terminal
OpenCode Desktop (@opencode-aidesktop)
Contributor guide
First steps
- Read the whole issue, then the project's contributing guide.
- Comment on the issue to say you are picking it up — it saves two people doing the same work.
- Fork the repository and make your change on a branch.
- Open a pull request that references the issue number.
Research direction
Start with packages/core/src/session/runner/model.ts and inspect SessionRunnerModel.resolve, then trace the subagent spawn entry point in packages/core/src/tool/builtins.ts. Reproduce the issue with GET /api/agent and GET /api/session/{childID}. Done means a configured agent model and variant are used for the child session, while an unconfigured agent still inherits the parent model.
Written by the indexing model from the issue text.
Assessment
- Tech stack
- typescript
- Domain
- backend-api-design
- Issue type
- Bug
- Difficulty
- 3/5
- Estimated time
- 1-2 days
- Activity status
- Active
- Clarity
- Clearly specified
- Newbie friendliness
- 74/100