feat(opencode): runtime subagent model selection#1
Conversation
|
Warning Review limit reached
Next review available in: 40 minutes Enable usage-based reviews in Billing to review now. Otherwise, wait until the next included review is available. How can I continue?After more reviews become available, a review can be triggered using the To avoid repeated limits, reduce automatic review volume by pausing incremental auto-reviews earlier, using label-based review opt-in, excluding WIP or generated PR titles, or requesting reviews manually when the PR is ready. If your team needs uninterrupted high-volume reviews, an organization admin can enable usage-based reviews. How do review limits work?CodeRabbit enforces per-developer PR review limits for each organization. Most developers receive the normal plan review availability. For paid Pro and Pro+ PR reviews, CodeRabbit uses adaptive limits for sustained high-volume activity. When a developer's recent PR review activity reaches the 95th percentile or higher among CodeRabbit users, additional reviews become available more gradually as earlier reviews age out of the rolling window. Please refer docs for additional details. Review details⚙️ Run configurationConfiguration used: defaults Review profile: CHILL Plan: Pro Run ID: 📒 Files selected for processing (1)
📝 WalkthroughWalkthroughAdds runtime subagent model selection with provider selector resolution, variant handling, child-session persistence, route metadata, UI display, and tests for ambiguity, resumption, disabled routes, and concurrent selections. ChangesSubagent model selection
Estimated code review effort: 4 (Complex) | ~45 minutes Sequence Diagram(s)sequenceDiagram
participant TaskTool
participant Provider
participant Auth
participant Sessions
participant PromptOps
TaskTool->>Provider: resolve requested model
TaskTool->>Auth: load provider authentication
TaskTool->>Sessions: persist child model and variant
TaskTool->>PromptOps: execute with effective route
PromptOps-->>Sessions: store route metadata
🚥 Pre-merge checks | ✅ 3 | ❌ 2❌ Failed checks (2 warnings)
✅ Passed checks (3 passed)
✨ Finishing Touches🧪 Generate unit tests (beta)
Thanks for using CodeRabbit! It's free for OSS, and your support helps us grow. If you like it, consider giving us a shout-out. Comment |
There was a problem hiding this comment.
🧹 Nitpick comments (1)
packages/tui/test/cli/tui/inline-tool-wrap-snapshot.test.tsx (1)
288-290: 📐 Maintainability & Code Quality | 🔵 Trivial | 💤 Low valueTest verifies the full-parameter case correctly.
The assertion matches the
formatSubagentTitleoutput. Consider adding a case with onlymodel(novariant/authVia) to verify thefilter(Boolean)path produces[openai/gpt-5.6-sol]rather than[openai/gpt-5.6-sol · · ]— low risk given the simple join logic, but it would lock in the partial-metadata contract.🤖 Prompt for AI Agents
Verify each finding against current code. Fix only still-valid issues, skip the rest with a brief reason, keep changes minimal, and validate. In `@packages/tui/test/cli/tui/inline-tool-wrap-snapshot.test.tsx` around lines 288 - 290, Add a test case for formatSubagentTitle that provides only the model while omitting variant and authVia, and assert the title metadata is formatted as [openai/gpt-5.6-sol] without empty separators. Keep the existing full-parameter assertion unchanged.
🤖 Prompt for all review comments with AI agents
Verify each finding against current code. Fix only still-valid issues, skip the
rest with a brief reason, keep changes minimal, and validate.
Nitpick comments:
In `@packages/tui/test/cli/tui/inline-tool-wrap-snapshot.test.tsx`:
- Around line 288-290: Add a test case for formatSubagentTitle that provides
only the model while omitting variant and authVia, and assert the title metadata
is formatted as [openai/gpt-5.6-sol] without empty separators. Keep the existing
full-parameter assertion unchanged.
ℹ️ Review info
⚙️ Run configuration
Configuration used: defaults
Review profile: CHILL
Plan: Pro
Run ID: 78b794ed-68fb-44dc-ab7b-4a92607f0aa9
📒 Files selected for processing (9)
packages/opencode/src/provider/provider.tspackages/opencode/src/tool/registry.tspackages/opencode/src/tool/task.tspackages/opencode/src/tool/task.txtpackages/opencode/test/fake/provider.tspackages/opencode/test/tool/task.test.tspackages/tui/src/routes/session/index.tsxpackages/tui/test/cli/tui/inline-tool-wrap-snapshot.test.tsxspecs/subagent-model-selection.md
Summary
Implements
specs/subagent-model-selection.md: a parent agent can now choose the model for each subagent invocation at runtime instead of requiring one statically configured agent per model.modelandvariantfields.modelaccepts a canonicalprovider/modelreference or a natural model name ("Fable five", "GPT 5.6 Sol Pro").Provider.resolveModelresolves natural names via normalized token matching (number words normalize to digits, version tokens must match in order) and only selects when exactly one usable route matches. Duplicate routes (e.g. an OpenAI subscription and AWS Bedrock exposing the same model) fail withAmbiguousModelSelectorErrorlisting the canonical choices instead of silently picking one.modelpreserves the existing default chain for new children: agent-configured model, then the parent turn's exact provider/model. Resumed children now keep their own stored model instead of drifting to the parent's current model; an explicitmodelon resume switches it.variantis validated against the resolved model (case-insensitive). Explicit invalid variants fail with the available options; inherited variants from agent config or the parent turn silently drop, matching the legacy prompt path.account/env/custom, never credentials).General Task [direct/claude-fable-5 · high · account] — description.Behavior notes
Testing
packages/opencode:bun test test/tool/task.test.ts(25 pass, incl. ambiguity, transposed-version rejection, disabled-provider filtering, resume preservation, explicit switch, parallel mixed-model children, strict vs lenient variant handling) andbun test test/provider/provider.test.ts(96 pass)packages/tui:bun test test/cli/tui/inline-tool-wrap-snapshot.test.tsx(17 pass)bun turbo typecheckacross all 30 packages passes (pre-push hook)Summary by CodeRabbit
New Features
UI
Bug Fixes
Documentation