Repository navigation
fix(opencode2): keep agents whose declared model cannot resolve - #215
Conversation
|
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 selected for processing (3)
Included review availability: 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] ~119-~119: Ensure spelling is correct (QB_NEW_EN_ORTHOGRAPHY_ERROR_IDS_1) [grammar] ~121-~121: Ensure spelling is correct (QB_NEW_EN_ORTHOGRAPHY_ERROR_IDS_1) 📝 SummarySummary by CodeRabbit
WalkthroughThe OpenCode 2 adapter now registers agents when declared models cannot be resolved. These agents receive no model reference, OpenCode selects the model, and ChangesOpenCode model fallback
Priority: ➖ Normal Estimated code review effort: 2 (Simple) | ~15 minutes Change: Bug fix · Severity of issue fixed: Medium Merge Risk: ⚪ Minimal · up to No merge-blocking risk is established; the fallback behavior is covered by source inspection and scenario assertions. 🚥 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 models in the moonlit glow Comment |
All eight builtins declare the bare model `claude-sonnet-4-5`. The adapter dropped any agent whose declared model did not resolve against the live catalog, so on a host that does not carry that model every builtin disappeared. `/weave:start` went with them, because command readiness requires an owned Tapestry. The only record was a `status` RPC a user has no reason to open, so a plausible host configuration produced an install that looked like it had done nothing. An unresolvable declared model now costs the agent its model, not its existence. The agent is registered without a model ref — the same `inherit` shape an agent that declares no model already produces — and OpenCode applies its own native model selection. One `model_unavailable` issue per affected agent is still recorded, so `status` names every agent whose declared model did not resolve. This is a trade, not a free win: the agent runs on a model the user did not name, and `status` is the only record of that. It replaces a failure that removed the whole product from the host with one that keeps it working on the host's own default. Declaring a model that does not resolve is not read as a request to have no agent. Scope is the V2 adapter only. `packages/config/src/builtins.ts` keeps its `claude-sonnet-4-5` declarations, so other harnesses are unaffected. Verified against the real opencode2 beta-19151 CLI, with a fixture whose agents use the builtin default model and a catalog carrying none of it: before, `ctx.agent.list()` reported 7 host builtins and zero Weave agents; after, all eight are present and Weave-owned. Six scenarios pinned the old behaviour and now state the new promises, including two that were incidentally relying on the builtins being dropped to isolate their own subject. Refs #209 Co-Authored-By: Claude Opus 5 <noreply@anthropic.com>
There was a problem hiding this comment.
Copilot review overview
🟡 Changes recommended
Documentation updates are needed to cover the public behavior, bounded diagnostics, and contradictory references.
Get a fresh assessment by requesting another Copilot review.
Review effort: Lite
Findings: 1
Open (1)
What changed in this PR
Keeps OpenCode 2 agents available when declared models cannot resolve, using host-native model selection while recording diagnostics.
Changes:
- Preserves agents with unresolved, ambiguous, or invalid model selections.
- Updates scenario coverage for fallback registration and command readiness.
- Documents fallback behavior and refreshes Codesight metadata.
| File | Summary | Final review comments |
|---|---|---|
tests/adapters/opencode2.scenario.test.ts |
Updates fallback and readiness scenarios. | — |
packages/adapters/opencode2/src/v2/catalog.ts |
Retains agents without resolved model references and records issues. | — |
docs/adapters/opencode2-core.md |
Documents model-selection fallback semantics. | Nit (2 votes): Update public documentation. Nit (1 vote): Document the 64-issue status limit. Nit (1 vote): Reconcile contradictory model-resolution references. |
.codesight/CODESIGHT.md |
Refreshes scan metadata. | — |
💡 Add a code-review agent skill or configure MCP servers for context-aware, tailored reviews. Learn more in the docs.
| When an agent declares models and none are valid or available, the agent is | ||
| still registered — without a model ref, the same shape an agent that declares | ||
| no model produces — and OpenCode applies its own native model selection. The | ||
| adapter reports one `model_unavailable` issue per affected agent, so `status` | ||
| names every agent whose declared model did not resolve. |
bd3b467 to
0a424fa
Compare
| When an agent declares models and none are valid or available, the agent is | ||
| still registered — without a model ref, the same shape an agent that declares | ||
| no model produces — and OpenCode applies its own native model selection. The |
| adapter reports one `model_unavailable` issue per affected agent, so `status` | ||
| names every agent whose declared model did not resolve. |
…ve adapter (#216) npm has exactly one version of `@weaveio/weave-adapter-opencode2`: 0.1.0, cut at 29393cf. `package.json` has since said 0.1.1 and 0.1.2, but neither was ever tagged, so neither was published. At 29393cf there was no `src/v2/` directory. The published package's exports confirm what it predates — only `.` and `./server`, no `./rpc` and no `./tui`. Unreleased since then: agent materialization in plugin setup (#163), real-CLI verification (#164), the whole native core integration (#167) with its catalog-backed agents, `/weave:start`, plan RPC, TUI, config refresh and native delegation, and #214/#215. Every capability documented in docs/adapters/opencode2-core.md describes code that has never been on npm. A user running `weave init --harness opencode2` gets the bare package name, which resolves to 0.1.0. This bumps the package to 0.2.0-next.0. The `-next.N` suffix publishes to the `next` dist-tag, so `latest` stays on 0.1.0 and no existing install is upgraded; the release is opt-in until it has been used against a real host. Also adds the changeset #215 landed without, and lists the OpenCode 2 adapter in RELEASING.md's tag table. The publish workflow has accepted `opencode2@*` tags since it was written; only the documentation omitted it, which is the likeliest reason this package was never released. No source change. The tag is not pushed here. Co-authored-by: Claude Opus 5 <noreply@anthropic.com>

Related: #209 (item 3)
The problem, reproduced
All eight builtins declare the bare model
claude-sonnet-4-5(packages/config/src/builtins.ts:74and seven more). The adapter dropped any agent whose declared model didn't resolve against the live catalog.So on a host that doesn't carry that model, every builtin vanished. I ran this against the real
opencode2beta-19151 CLI — a fixture declaring the eight builtins with no model override, against a catalog containing onlyproof/proof-model:Seven host builtins. Zero Weave agents.
/weave:startgone too, since command readiness requires an owned Tapestry. No log line — the only record was amodel_unavailableissue in thestatusRPC, which a user has no reason to open.Every verification fixture pins its agents to
proof/proof-model, for good hermetic reasons, which is exactly why nothing caught this: the default path is the one path no fixture takes.The change
An unresolvable declared model now costs the agent its model, not its existence. The agent is registered without a model ref — the same
inheritshape an agent declaring no model already produces — so OpenCode applies its native model selection. Onemodel_unavailableissue per affected agent is still recorded.Same fixture, after:
The trade
This is not a free win, and the docs say so plainly. The agent runs on a model the user did not name, and
statusis the only record. Two related behaviours change with it:What it replaces is a failure mode that removed the entire product from the host. Declaring a model that doesn't resolve isn't a request to have no agent.
Alternatives considered and not taken: removing
modelsfrom the builtins so Weave stops dictating a model at all (correct, but changes defaults for every adapter), and logging a warning without changing behaviour (diagnosable, but the install is still empty).Scope
V2 adapter only.
packages/config/src/builtins.tsis untouched, so no other harness changes behaviour. The same trap still exists for any other adapter whose catalog lacksclaude-sonnet-4-5— worth a follow-up, deliberately not bundled here.Tests
Six scenarios pinned the old behaviour and now state the new promises. Two of them — the foreign-agent collision case and the lazy-transform case — were incidentally relying on the builtins being dropped in order to isolate their own subject, and now say what they actually mean.
Full suite green: 5072 pass, 13 skip, 0 fail. Typecheck, lint and doc links clean.
🤖 Generated with Claude Code