fix(opencode): preserve subagent model variants#29066
Conversation
|
Thanks for your contribution! This PR doesn't have a linked issue. All PRs must reference an existing issue. Please:
See CONTRIBUTING.md for details. |
|
The following comment was made by an LLM, it may be inaccurate: I found several related PRs that address similar concerns about model variants and subagent inheritance: Potential Related PRs
These PRs appear to address the same or overlapping concerns about preserving and inheriting model variants for subagents. PR #12567 seems most directly related as it also deals with passing variants from parent to subagent prompts. |
There was a problem hiding this comment.
Pull request overview
Note
Copilot was unable to run its full agentic suite in this review.
This PR adds and verifies variant inheritance behavior across parent/child agent prompts, ensuring variants are only propagated when the child uses the same model (and no explicit child variant/model is configured).
Changes:
- Extend test seeding to support setting an assistant variant/model and add new TaskTool variant inheritance tests.
- Update TaskTool to inherit the parent assistant variant for same-model subagents when the subagent has no configured variant.
- Update SessionPrompt variant application logic and add tests for agent-variant application and variant non-propagation on explicit model overrides.
Reviewed changes
Copilot reviewed 4 out of 4 changed files in this pull request and generated 2 comments.
| File | Description |
|---|---|
| packages/opencode/test/tool/task.test.ts | Adds seed options and new TaskTool tests covering variant inheritance and persistence. |
| packages/opencode/test/session/prompt.test.ts | Adds SessionPrompt tests for applying agent variant to inherited models and avoiding variant propagation across explicit model changes. |
| packages/opencode/src/tool/task.ts | Implements parent-variant inheritance for same-model subagent execution when no child variant is configured. |
| packages/opencode/src/session/prompt.ts | Restricts variant propagation to same-model scenarios and broadens when agent variant can apply to inherited/default models. |
💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.
| ) | ||
| const model = input.model ?? ag.model ?? (yield* currentModel(input.sessionID)) | ||
| const same = ag.model && model.providerID === ag.model.providerID && model.modelID === ag.model.modelID | ||
| const same = !ag.model || (model.providerID === ag.model.providerID && model.modelID === ag.model.modelID) |
| const seed = Effect.fn("TaskToolTest.seed")(function* ( | ||
| title = "Pinned", | ||
| opts?: { assistantVariant?: string; assistantModel?: typeof ref }, | ||
| ) { |
|
Thanks for updating your PR! It now meets our contributing guidelines. 👍 |
Issue for this PR
Closes #29067
Type of change
What does this PR do?
Preserves the selected model variant/thinking level when a same-model subagent is created without its own configured variant.
The fix passes the parent assistant variant into the child prompt only when the child uses the same provider/model and has no configured variant. It also lets inherited-model agents apply their configured variant when the provider supports it, and prevents explicit different subtask models from copying the parent variant.
How did you verify your code works?
Screenshots / recordings
Not applicable; backend prompt/session state fix for a TUI-observed bug.
Checklist