Repository navigation
fix(opencode2): keep an agent's model when its variant is not offered - #266
Conversation
An agent-level `variant` the selected model does not offer rejected the model entry. `variant none` on a Claude model (Copilot's Claude models have no `none` variant; GPT models do) made every entry fail, so the agent fell to a builtin fallback or to no model, and a subagent then ran on its parent's model. The agent-level variant now applies to whichever entry is selected: a model that lacks it runs without it, and status reports `variant_unavailable`. A `#variant` on an entry stays strict. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com> Claude-Session: https://claude.ai/code/session_01SFsPx8V3UJ3xP4E9qZDpKw
|
Navigate logical layers of code changes, visualize relationships, and explore their blast radius. No actionable comments were generated in the recent review. 🎉 ℹ️ Recent review info⚙️ Run configurationConfiguration used: Organization UI Review profile: ASSERTIVE Plan: Advanced Run ID: ⛔ Files ignored due to path filters (4)
📒 Files selected for processing (9)
Included review availability: This review used your included allowance. Your plan provides up to 1 included review per hour; 0 remain after this review. 📜 Recent review details⏰ Context from checks skipped due to timeout. (7)
🧰 Additional context used🪛 LanguageTooldocs/adapters/opencode2-core.md[grammar] ~147-~147: Ensure spelling is correct (QB_NEW_EN_ORTHOGRAPHY_ERROR_IDS_1) 🔇 Additional comments (9)
📝 SummarySummary by CodeRabbit
WalkthroughOpenCode 2 now keeps a selected model when an agent-level variant is unavailable, omits that variant, and reports ChangesOpenCode 2 variant handling
Priority: ➖ Normal Estimated code review effort: 3 (Moderate) | ~20 minutes Change: Bug fix · Severity of issue fixed: Medium Sequence Diagram(s)sequenceDiagram
participant CatalogCandidate
participant resolveOpenCode2Model
participant Status
CatalogCandidate->>resolveOpenCode2Model: Resolve the selected model and variant
resolveOpenCode2Model-->>CatalogCandidate: Return the model and any droppedVariant
CatalogCandidate->>Status: Record variant_unavailable for a dropped variant
Suggested reviewers: Merge Risk: ⚪ Minimal · up to No actionable issue remains in the supplied evidence; the PR is mergeable after normal checks. Security Architecture ReviewSecurity architecture risk: 🔵 Low · up to A configured choice is now preserved when an optional setting is unavailable, and the mismatch is reported. In large configurations, the additional warnings could obscure other problems. No direct new access path was established. Retained concerns
Security review detailsSecurity Blast Radius
Security Findings and Attack Paths
Trust Boundaries and Controls
Resilience and Maintainability Implications
Hardening Proposals
🚥 Pre-merge checks | ✅ 4✅ Passed checks (4 passed)
✨ Finishing Touches✨ Simplify code
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. A rabbit checks the model list, Comment |
There was a problem hiding this comment.
Copilot review overview
🟢 Approval recommended
No blocking issues remain; the public-docs update is a minor documentation nit.
Review effort: Lite
Findings: 1
What changed in this PR
Fixes OpenCode 2 model selection so unsupported agent-level variants no longer replace the configured model.
Changes:
- Preserves models when agent-level variants are unavailable.
- Adds
variant_unavailablehealth and status reporting. - Adds regression tests and updates documentation, API reports, and changelog.
| File | Reviewed changes |
|---|---|
tests/adapters/opencode2.scenario.test.ts |
Adds regression scenarios. |
packages/adapters/opencode2/src/v2/model-resolution.ts |
Preserves models with unsupported variants. |
packages/adapters/opencode2/src/v2/health.ts |
Adds the health issue code. |
packages/adapters/opencode2/src/v2/catalog.ts |
Records unavailable variants. |
packages/adapters/opencode2/src/rpc.ts |
Extends status reporting. |
packages/adapters/opencode2/etc/weave-adapter-opencode2-rpc.api.md |
Updates the API report. |
packages/adapters/opencode2/CHANGELOG.md |
Documents the fix. |
docs/model-resolution.md |
Documents resolution behavior. |
docs/adapters/opencode2-core.md |
Documents adapter semantics. |
.codesight/middleware.md |
Updates generated metadata. |
.codesight/coverage.md |
Updates generated metadata. |
.codesight/config.md |
Updates generated metadata. |
.codesight/CODESIGHT.md |
Updates generated metadata. |
💡 Add a code-review agent skill or configure MCP servers for context-aware, tailored reviews. Learn more in the docs.
| An entry-level `#variant` must exist in the live model entry, or the entry is | ||
| not viable. The descriptor-level `variant` applies to whichever entry is | ||
| selected: when that model does not offer it, the agent keeps the model, runs | ||
| without a variant, and health reports a bounded `variant_unavailable` issue. If |
Bumps @weaveio/weave-adapter-opencode2 to 0.2.0-next.5 to release the agent-variant fix (#266): an agent-level variant the selected model does not offer no longer costs the agent its model. Refs #265 Claude-Session: https://claude.ai/code/session_01SFsPx8V3UJ3xP4E9qZDpKw Co-authored-by: Claude Opus 5.5 <noreply@anthropic.com>

Fixes #265.
Problem
An agent-level
variantthat the selected model does not offer rejected the whole model entry.variant noneon a Claude model made every entry fail, because Copilot's Claude models offer nononevariant while GPT models do. The agent then fell to a builtin fallback, or to no model at all, and an OpenCode 2 subagent with no model runs on its parent's model. A user saw Shuttle (configured for Sonnet 5) run on Loom's Opus 5.5.Change
resolveVariant(v2/model-resolution.ts) now separates the two forms:#varianton an entry is part of that entry: if the model doesn't offer it, the entry is still skipped, as the existing scenario decides.variantapplies to whichever entry is selected, so a model that doesn't offer it keeps the agent and runs without a variant. The resolution returnsdroppedVariant.variant_unavailableissue for that agent, and health and thestatusRPC gain the code (RPC API report updated), so the change stays visible.docs/model-resolution.mdanddocs/adapters/opencode2-core.md. The model-resolution doc also still said an agent with no viable model is omitted, which has been out of date since fix(opencode2): keep agents whose declared model cannot resolve #215; now corrected. CHANGELOG entry under Unreleased.Tests
statusnamesvariant_unavailableand notmodel_unavailable;shuttle) keeps the user's model even when a builtin fallback does offer the variant.bun run typecheck,bun run lintandbun run testpass (5916 pass, 0 fail).variant none. FromGET /api/agent:claude-sonnet-5)gpt-6-sol#none/gpt-6-luna#none(builtin fallback)claude-sonnet-5claude-haiku-4.5)gpt-6-luna#noneclaude-haiku-4.5claude-opus-5.5)claude-opus-5.5gpt-6-sol, offersnone)gpt-6-sol#nonegpt-6-sol#none(unchanged)gpt-6-solclaude-sonnet-5🤖 Generated with Claude Code
https://claude.ai/code/session_01SFsPx8V3UJ3xP4E9qZDpKw