Repository navigation
subagent model variants are parsed but not applied at runtime in v1.4.0 #21632
Description
Description
After upgrading from v1.3.17 to v1.4.0, subagents no longer appear to honor agent-level variant settings at runtime.
The config is parsed correctly, but the effective request behavior does not reflect the configured model variant. Downgrading back to v1.3.17 restores the expected behavior.
Expected behavior:
If a subagent is configured like this:
"gsd-code-reviewer": {
"model": "codex/gpt-5.3-codex",
"variant": "high"
}and the model defines:
"gpt-5.3-codex": {
"variants": {
"high": {
"reasoningEffort": "high"
}
}
}then the spawned subagent should use the high variant's effective options at runtime.
Actual behavior in v1.4.0:
opencode debug configshows the subagent has the expectedvariantopencode debug agent gsd-code-revieweralso shows the resolved variant-derived options- but when the subagent is invoked through the task/subagent path, the actual runtime behavior does not reflect the configured reasoning level
This was previously working in v1.3.17.
What I verified:
- Config parsing is correct
opencode debug configshows the subagent config correctlyopencode debug agent gsd-code-reviewershows the resolved values including the variant-derived options
- This is not a config merge issue
- I verified both global config and project config resolution
- The final resolved config is correct
- This seems specific to subagent runtime
- Running a subagent directly with
opencode run --agent gsd-code-reviewer ...falls back to the default primary agent - so the only meaningful path is through task/subagent execution, and that is where the configured variant appears to be lost or ignored
- Running a subagent directly with
Regression:
- Works as expected:
v1.3.17 - Broken / no longer effective:
v1.4.0
I also tested adding reasoningEffort directly on the subagent config. The config/debug layer still reflects it, but runtime behavior still appears incorrect for subagents in v1.4.0.
This suggests the issue is likely in the subagent execution path rather than config parsing.
This may be related to agent.variant handling issues such as #13790, but this report is specifically about subagents: the variant is visible in debug output yet appears not to affect runtime behavior when invoked through the task/subagent path.
Plugins
No response
OpenCode version
v1.4.0
Steps to reproduce
- Install
opencode v1.4.0 - Configure a model with a variant that changes reasoning settings, for example:
"model": {
"gpt-5.3-codex": {
"provider": "codex",
"options": {
"reasoningEffort": "medium"
},
"variants": {
"high": {
"reasoningEffort": "high"
}
}
}
}- Configure a subagent to use that model variant, for example:
"agent": {
"gsd-code-reviewer": {
"model": "codex/gpt-5.3-codex",
"variant": "high",
"mode": "subagent"
}
}- Verify config resolution:
- run
opencode debug config - run
opencode debug agent gsd-code-reviewer - confirm both show the expected
variant/ variant-derived options
- run
- Invoke the subagent through the task/subagent execution path in a normal session
- Compare behavior with
v1.3.17
Observed result:
In v1.4.0, the subagent does not appear to use the configured variant at runtime, even though debug output shows it resolved correctly.
Expected result:
The spawned subagent should inherit and use the configured model variant at runtime.
Screenshot and/or share link
No response
Operating System
Linux 6.17.0-19-generic x86_64 GNU/Linux
Terminal
xterm-256color
Activity
github-actions commentedon Apr 9, 2026
This issue doesn't fully meet our contributing guidelines.
What needs to be fixed:
_No response_) — please specify the exact version (e.g.,v1.4.0)_No response_) — please provide a minimal, reproducible sequence of steps so maintainers can verify the regressionPlease edit this issue to address the above within 2 hours, or it will be automatically closed.
This issue might be a duplicate of or related to existing issues. Please check:
TypeError: undefined is not an object (evaluating 'agent.variant')) #13790: Similaragent.variantbug where variant is parsed but not correctly applied at runtime for custom agentsIf you believe this was flagged incorrectly, please let a maintainer know.
github-actions commentedon Apr 9, 2026
Thanks for updating the issue! It now follows the contributing guidelines and includes all the required information. We appreciate the detailed reproduction steps and version context.
nilltadios commentedon Apr 17, 2026
The bug reported here (a subagent's configured
variantnot applied at runtime) has a second, closely-related manifestation on the same code path: when a subagent has no configuredmodeland inherits the parent's model, it also does not inherit the parent's activevariant. The subagent ends up withvariant = undefinedand falls back to the provider default.Concrete symptom: a parent running gpt-5.4 at variant
xhighspawns a subagent that silently runs atreasoningEffort: "medium"(the default injected inprovider/transform.tsaround line 871–883 for gpt-5.4 when no variant is present). The subagent "thinks" visibly less than the parent, which is what first tipped me off.Root cause trace (on current
dev, 54078c4):packages/opencode/src/tool/task.ts:102-105reads onlymodelID/providerIDfrom the parent assistant message:msg.info.variantexists on the assistant message schema (session/message-v2.ts:448) but is never read.task.ts:131-145then callsops.prompt({ ..., model: { modelID, providerID }, ... })with novariantfield.packages/opencode/src/session/prompt.ts:935-941resolves variant as:For an inherited-model subagent,
ag.modelis undefined →sameisfalse→ theag.variantbranch is gated off →variantisundefined.So there are two distinct failure modes routing through the same spot:
model+variant, but something in the v1.4.0 runtime path still drops it. (Guard on line 941 requiringfull?.variants?.[ag.variant]is a likely suspect — iffullfails to resolve for any reason, the variant is silently dropped.)variantis never forwarded throughtask.ts.Minimal fix for the second case: carry
msg.info.variantthroughtask.tsand pass it asinput.varianttoops.prompt, so variant inheritance follows model inheritance. That alone should address the parent-inheritance symptom; the configured-variant-ignored path on line 941 likely needs a separate look.0serna commentedon Apr 24, 2026
same issue
21pounder commentedon Apr 29, 2026
I've investigated this bug and can confirm the root cause with debug logs.
Root cause
In
packages/opencode/src/session/prompt.ts:902:When a subagent has no explicit
modelconfigured (inheriting the parent's),ag.modelisundefined→sameisfalse→ag.variantis silently dropped.I added a temporary debug log to confirm:
Subagent running (configured with
variant: "high", nomodel):Bug confirmed —
agVariant=highis present butvariantis missing (undefined):Fix
I'll open a PR with this one-line change.
jsheremeta-alt commentedon Jun 4, 2026
Still reproducing on v1.15.13. Here is additional evidence from the runtime binary and local session database.
Binary analysis
The Task tool execute function resolves the model like this:
Then passes only modelID and providerID to the prompt call:
No
variant, nooptions, noreasoningEffort, noenable_thinking, notemperature. The prompt function does acceptvariantas a top-level parameter (the TUI path uses it this way), but the Task tool never passes it. This is the same root cause that @nilltadios and @21pounder traced above.Session database evidence
I queried the OpenCode SQLite database (
~/.local/share/opencode/opencode.db) to check what sub-agent sessions actually record at runtime:Every single sub-agent session has
variant: "default"in the model field, regardless of what is configured in agent frontmatter. My build-steward sub-agent hasenable_thinking: true, reasoningEffort: highin its frontmatter but recorded 0 reasoning tokens in its actual run. Other sub-agents show similarly mismatched token counts.Primary agents do apply variants correctly. Those sessions show the correct variant value.
About the closed PRs
PR #20742 by @dbpolito addressed this but was closed by automated PR cleanup on May 15 due to insufficient reactions. PR #12567 by @mugnimaestra has been open since February with a working fix and video demonstration but remains unmerged.
Could #20742 be reopened? It had tests and was from an SST team member.
github-actions commentedon Aug 4, 2026
To stay organized issues are automatically closed after 60 days of no activity. If the issue is still relevant please open a new one.