Skip to content

fix(opencode): apply agent variant when no explicit model is configured#24962

Open
21pounder wants to merge 4 commits intoanomalyco:devfrom
21pounder:fix/subagent-variant-inheritance
Open

fix(opencode): apply agent variant when no explicit model is configured#24962
21pounder wants to merge 4 commits intoanomalyco:devfrom
21pounder:fix/subagent-variant-inheritance

Conversation

@21pounder
Copy link
Copy Markdown
Contributor

@21pounder 21pounder commented Apr 29, 2026

Issue for this PR

Closes #21632

Type of change

  • Bug fix
  • New feature
  • Refactor / code improvement
  • Documentation

What does this PR do?

In packages/opencode/src/session/prompt.ts:902, the same variable is computed as:

const same = ag.model && model.providerID === ag.model.providerID && model.modelID === ag.model.modelID

When a subagent has no explicit model configured, ag.model is undefined, so same is false. This gates off the ag.variant branch, causing the configured variant to be silently dropped at runtime.

Fix: treat a missing ag.model as "same model" (inherited), so the variant is applied:

const same = !ag.model || (model.providerID === ag.model.providerID && model.modelID === ag.model.modelID)

How did you verify your code works?

Added a temporary debug log at line 908 to trace variant resolution, then ran the subagent before and after the fix.

Before fix: agVariant=high is present but variant is missing (undefined).
After fix: variant=high is correctly resolved.

Screenshots / recordings

Subagent running (configured with variant: "high", no model):

屏幕截图 2026-04-29 220444

Before fix — agVariant=high but variant missing:

屏幕截图 2026-04-29 221003

After fix — variant=high correctly resolved:

屏幕截图 2026-04-29 221109

Checklist

  • I have tested my changes locally
  • I have not included unrelated changes in this PR

@github-actions github-actions Bot added contributor needs:compliance This means the issue will auto-close after 2 hours. labels Apr 29, 2026
@github-actions
Copy link
Copy Markdown
Contributor

The following comment was made by an LLM, it may be inaccurate:

Based on my search, I found several related PRs that address variant inheritance and agent configuration:

Potentially Related PRs:

  1. fix(opencode): Subtasks and task calls don’t inherit selected thinking level #20742 - fix(opencode): Subtasks and task calls don't inherit selected thinking level

    • Directly related: addresses variant/thinking level inheritance for subagents, which is the same core issue
  2. feat(task): pass variant to subagent so it inherits parent's thinking level #12567 - feat(task): pass variant to subagent so it inherits parent's thinking level

    • Related: implements variant inheritance for subagents from parent agents
  3. fix(acp): sync model and variant when activating session modes #18663 - fix(acp): sync model and variant when activating session modes

    • Related: addresses syncing model and variant configuration
  4. fix(acp): session/set_mode now activates agent's configured model #18621 - fix(acp): session/set_mode now activates agent's configured model

    • Related: handles agent model configuration activation

These PRs all touch on similar areas of agent variant/model configuration and inheritance, particularly for subagents. PR #20742 appears most closely related as it specifically addresses thinking level (variant) inheritance for subtasks.

@github-actions github-actions Bot removed the needs:compliance This means the issue will auto-close after 2 hours. label Apr 29, 2026
@github-actions
Copy link
Copy Markdown
Contributor

Thanks for updating your PR! It now meets our contributing guidelines. 👍

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

Projects

None yet

Development

Successfully merging this pull request may close these issues.

subagent model variants are parsed but not applied at runtime in v1.4.0

1 participant