Repository navigation
fix(agents): upgrade opencode to 2.2.3 - #2779
Open
github-actions[bot] wants to merge 1 commit into
Open
github-actions[bot] wants to merge 1 commit into
github-actions[bot] wants to merge 1 commit into
Conversation
Move @opencode/sdk and @opencode/plugin to 2.2.3 (peer range ^2.2.3). OpenCode 2.2.1 stopped bundling @ai-sdk/vercel, which agents/models/opencode named as its carrier package; 2.2.3 runs OpenCode's npm loader after plugin sdk hooks, so the provider now answers the sdk hook itself. Move the harness off the deprecated sessions.wait/sessions.log to experimental.session, and adapt the test and example Vite configs to OpenCode's new effect paths and its 8 MB models.dev snapshot. Gardener-Operation: op_08d8b01a60d488c0d0dab49550a501301bb3571c3d7ba31a7751f667ff2a7d7d:f6e1e8ca99b3b04db9231838a0897c2d0e0de8f444525634e905fc6df1d1e77d
🦋 Changeset detectedLatest commit: 0c6ada2 The changes in this PR will be included in the next version bump. This PR includes changesets to release 2 packages
Not sure what this means? Click here to learn what changesets are. Click here if you're a maintainer who wants to add another changeset to this PR |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Summary
Moves
agents/harness/opencodeandagents/models/opencodefrom opencode 2.0.24 to 2.2.3, and switches the Cloudflare provider to OpenCode'ssdkhook.@opencode/sdk(dev, example)2.0.242.2.3@opencode/plugin(dev, example)2.0.242.2.3@opencode/sdkpeer range^2.0.24^2.2.3@opencode/pluginpeer range^2.0.24^2.2.3There have been 16 opencode v2 releases since 2.0.24 (2.0.25 to 2.2.3). All of them already install under our
^2.0.24peer range, and on 2.2.1 and 2.2.2agents/models/opencodeis broken: every turn fails, because OpenCode no longer bundles@ai-sdk/vercel, the package our provider borrowed (see #2776 and #2777). 2.2.3 is the first release with what #2777 asks for: OpenCode now runs its npm loader after pluginsdkhooks, so a plugin can supply the AI SDK provider itself. This PR does that and moves the floor to 2.2.3.What changed upstream that affects us
@opencode/core2.2.1, a dependency of@opencode/sdk).packages/agents/src/models/opencode/index.ts:60namedaisdk:@ai-sdk/vercelas the provider's package so that OpenCode'ssdkstep would load something in-process before ourlanguagehook replaced the model. On 2.2.x that package goes to OpenCode's npm installer, which cannot run in workerd. With 2.2.3 and the old code, 14 of 31 harness tests fail withCannot initialize cloudflare/@cf/moonshotai/kimi-k2.7-code: Npm.add is unavailable in the workerd profile. The fix uses the next item.@opencode/core2.2.3).DynamicProviderPluginnow registers after external plugins and returns early whenevt.sdkis already set. Our plugin now answers thesdkhook for its own provider, so it doesn't need a carrier package or the unreachable Vercel base URL any more. This is the approach proposed in fix(agents): upgrade opencode to 2.2.1 #2776.languagehook (index.ts:149) still builds the model fromagents/models/ai-sdk, and thesdkhook's registration is disposed with the others.sessions.waitandsessions.logare now@deprecated Use client.experimental.session.wait/log. Removed in the next minor.The harness calls them atpackages/agents/src/harness/opencode/harness.ts:536,:670and:1242, andOpenCodeLogEventis derived fromsessions.log(types.ts:45). Both have moved to the new names:effect/unstable/httpapimoved toeffect/http-api, so the Vite stub for Scalar's UI no longer matched anything. It's fixed inpackages/agents/src/harness/opencode/tests/vitest.config.ts:16andexamples/next/harnesses/opencode/vite.config.ts:16:@opencode/core2.2.3 inlines models.dev's catalog as one 8.2 MB string (dist/chunks/usage-limits-*.js; in 2.0.24 the largest chunk was 5.3 MB). It is too large for the WebSocket message that carries a module into the vitest-pool-workers runtime (WebSocket protocol error; statusCode = 1009; Message is too large), and theharness-opencodepool crashed after 5 of 14 tests.vitest.config.ts:20adds theempty-models-dev-snapshottransform from fix(agents): upgrade opencode to 2.2.1 #2767, which swaps in an empty catalog. These tests already setmodels: { fetch: false }and use only the Cloudflare provider.No effect on us (76)
experimental.idlesession hook; we don't register one.event.subscribe; the harness subscribes through the SDK client, unfiltered.instancesoption, which we don't use.@opencode/ai/effectimport move.@opencode/ai.instancesoption, which we don't use.SessionCompactionResult.providerStatetonative; we register no compaction hook.isError(examples/next/harnesses/opencode/src/workspace.ts:143) and its comment already says that becomes a tool error. This change makes that true; no code change.effect.OpenCodeWorkerd.create({ plugins })now registers plugins before suspended sessions resume, so a resumed turn finds our provider; we have no code working around the old order.zodand@standard-schema/specfrom@opencode/plugin; we don't rely on them through it.Decisions
sdkhook instead of finding another bundled carrier. fix(agents): upgrade opencode to 2.2.1 #2767 usedgitlab-ai-provideras the carrier, and fix(agents): upgrade opencode to 2.2.1 #2776 held off because that depends on OpenCode internals. With 2.2.3 a plugin'ssdkhook runs before the npm fallback (dynamic.ts:if (evt.sdk) return), so the provider namesaisdk:agents/models/opencode, a package that doesn't exist, and our hook supplies a placeholder SDK. The model still comes from the existinglanguagehook, soagents/models/ai-sdkbuilds it as before. The package name is the one fix(agents): upgrade opencode to 2.2.1 #2776 proposed.^2.2.3. The new provider needs 2.2.3's hook order. On 2.0.24 to 2.2.2 OpenCode's npm loader would claimagents/models/opencodebefore our hook runs. On 2.2.1 and 2.2.2 the old carrier was already broken anyway. The harness also now callsexperimental.session.*, which exists from 2.2.1.sessions.waitandsessions.lognow. They still work on 2.2.3 but are marked "Removed in the next minor". The floor already guarantees the replacements, so moving now means the next minor needs no harness change.patch. Only source changed, and the peer floor moves within major 2. The changeset states the new floor and the one-way door.Needs a maintainer
blobtable and stores file attachments and file tool results asmedia:<hash>refs (70c69f0, migration20261025123711_blob). opencode before 2.2.0 can't read those messages. Options: accept it (users on^2.0.24could already have installed 2.2.x), or document a rollback caveat in the harness example. Recommendation: accept it and rely on the changeset note, because the harness is@experimentaland the migration is upstream's.Affected open PRs
sdk-hook provider that fix(agents): upgrade opencode to 2.2.1 #2776 planned to ship once OpenCode ran its npm loader after plugin hooks, which 2.2.3 does (#60380). Tests pass without removingDynamicProviderPlugin.Other changes
packages/agents/package.json: dev pins2.0.24→2.2.3and peer ranges^2.0.24→^2.2.3for@opencode/sdkand@opencode/plugin.examples/next/harnesses/opencode/package.json: pins2.0.24→2.2.3.examples/next/harnesses/opencode/vite.config.ts: the effect path fix above.packages/agents/src/harness/opencode/tests/vitest.config.ts: the effect path fix and theempty-models-dev-snapshottransform above.packages/agents/src/harness/opencode/harness.ts,packages/agents/src/harness/opencode/types.ts: theexperimental.sessionmove above.packages/agents/src/models/opencode/index.ts: thesdkhook, the new carrier name, and the removed Vercel settings above; the comment onCARRIER_PACKAGEnow says why the name is safe..changeset/opencode-2-2-3.md:agentspatch: the new floor, why, and the one-way door.pnpm-lock.yaml: regenerated bypnpm install; both importers resolve only@opencode/*@2.2.3(no2.0.24left), plus the transitive moves that come with it (for example OpenTUI 0.8.0, effect 4.0.6).Evidence
harness-opencodepassed 31/31 and theworkersproject'smodels/opencodetests passed 5/5. On 2.2.3 with the old code, theharness-opencodepool crashed (Message is too large, 5 of 14 tests run). With only the test config fixed, 14 of 31 tests failed (Npm.add is unavailable in the workerd profile).harness-opencode31/31,workersmodels/opencode(provider.test.ts,language-v3.test.ts) 5/5.pnpm run buildpasses, and so doespnpm run check(sherif, exports check, oxfmt, oxlint, typecheck of all 133 projects).Merge Danger
Door: one-way
Blast Radius: OpenCode harness users
Anyone on
@opencode/sdkor@opencode/pluginbelow 2.2.3 gets a peer-dependency warning and should upgrade both to 2.2.3. If they don't,agents/models/opencodefails to initialize its model (on 2.2.1 and 2.2.2 it already does). The door is one-way because of OpenCode itself: once 2.2.0 or later has run on a Durable Object, OpenCode keeps file attachments and file tool results in its newblobtable, and pinning back below 2.2.0 makes those messages unreadable. Everything else OpenCode migrated between 2.0.24 and 2.2.3 is additive, and the droppedsession_pendingtable was unused.Opened by Gardener's
opencode-upgradetask. Commits pushed by Gardener don't start CI: close and reopen this pull request, or push to it, to run it. Review comments are handled by Gardener'spr-review-fixtask.