Repository navigation
fix(agents): upgrade opencode to 2.4.2 - #3246
github-actions[bot] wants to merge 1 commit into
Conversation
Move @opencode/sdk and @opencode/plugin to 2.4.2, with a peer range of ^2.2.3. OpenCode 2.2.1 stopped bundling @ai-sdk/vercel, which agents/models/opencode named as its carrier package, so every prompt came back unanswered. Since 2.2.3 OpenCode runs its npm loader after plugin sdk hooks, so the provider now answers the sdk hook itself. Move the harness off the deprecated sessions.wait and sessions.log to experimental.session, update the test and example Vite configs for effect's new http-api path, stub the 8 MB models.dev snapshot in the harness tests (failing loudly if its shape changes), and correct the example's Worker size. Carries over the changes from #3102 (2.4.1), rebased on the current harness test config. Gardener-Operation: op_9d1d38ebdd927411a2f09ed1b844538b53770bc4e994f77e9094aa2417616500:3a43ca8202b50d66d9888941b2cf1e6f1b9ec4a5878b5eae4dab35aa8336cff6
🦋 Changeset detectedLatest commit: edd8990 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 |
| "@opencode/plugin": "2.0.24", | ||
| "@opencode/sdk": "2.0.24", | ||
| "@opencode/plugin": "2.4.2", | ||
| "@opencode/sdk": "2.4.2", |
There was a problem hiding this comment.
🔍 Existing session upgrades lack coverage
The test worker creates and reopens databases with 2.4.2. Add a 2.0.24 fixture to verify that the one-way migration preserves transcripts and queued prompts under opencode_.
Was this helpful? React with 👍 or 👎 to provide feedback.
| "@opencode/plugin": "^2.2.3", | ||
| "@opencode/sdk": "^2.2.3", |
There was a problem hiding this comment.
🔍 Advertised peer floor lacks coverage
The tests pin 2.4.2. Run a Workers AI prompt on 2.2.3 to exercise the two-hook provider at the advertised minimum.
Was this helpful? React with 👍 or 👎 to provide feedback.
| zod: 4.1.8 | ||
| zod: 4.6.7 | ||
| optionalDependencies: | ||
| '@number0/iroh': 1.2.0 |
There was a problem hiding this comment.
🔍 New optional native dependency
OpenCode adds the @number0/iroh Node-API package and its platform binaries to the install graph. Resolve the conflict with the native dependency rule before merging.
Was this helpful? React with 👍 or 👎 to provide feedback.
Summary
Moves
agents/harness/opencodeandagents/models/opencodefrom opencode 2.0.24 to 2.4.2, and raises the peer floor to 2.2.3.@opencode/sdk(dev,packages/agents)@opencode/plugin(dev,packages/agents)@opencode/sdk/@opencode/plugin(examples/next/harnesses/opencode)@opencode/sdk/@opencode/pluginpeer range^2.0.24^2.2.3OpenCode has shipped 2.0.25 through 2.4.2 since our pin. All of them fall inside our
^2.0.24peer range, so users can already install them, and from 2.2.1 onagents/models/opencodedoesn't work for them: every prompt comes backunanswered. This PR carries over the source, config and docs changes from #3102 (2.4.1), which onlygithub-actions[bot]committed to, applies them to currentmain(whereharness-opencodenow runs on@cloudflare/vitest-plugin), and moves on to 2.4.2. Nothing from 2.4.1 to 2.4.2 needed a code change. 2.4.2 installed without aminimumReleaseAgehold.What changed upstream that affects us
@opencode/core2.2.1, a dependency of@opencode/sdk).agents/models/opencodetold OpenCode its provider usedaisdk:@ai-sdk/vercel(packages/agents/src/models/opencode/index.ts:60onmain). OpenCode loaded that bundled package in-process and ourlanguagehook swapped in the model. Now the package isn't bundled, so OpenCode hands the provider to its npm installer, which can't run in workerd. At 2.4.2 with the old carrier, 14 of the 35harness-opencodetests fail withstatus: "unanswered". The fix relies on "fix(core): run dynamic provider npm fallback after external sdk hooks (#60380)" (b5c223182c, 2.2.3), which runs a plugin'saisdk.hook("sdk")before that loader. Our plugin now answers thesdkstep itself, under a package name that doesn't exist, and keeps itslanguagehook:index.ts:165-166). The doc comment aboveCARRIER_PACKAGE(index.ts:50-58) now explains thesdkhook.opencode.sessions.waitandopencode.sessions.logbecame aliases marked@deprecated Use `client.experimental.session.wait`. Removed in the next minor.(logcarries the same note). The harness calls them atpackages/agents/src/harness/opencode/harness.ts:536,:670and:1242, andOpenCodeLogEventis derived fromsessions.logatpackages/agents/src/harness/opencode/types.ts:45. Our caret range admits the release that removes them.effect/unstable/httpapitoeffect/http-api, and 2.4.2 depends oneffect4.1.0, so theempty-httpapi-scalarstub atpackages/agents/src/harness/opencode/tests/vitest.config.ts:17andexamples/next/harnesses/opencode/vite.config.ts:16no longer matched any file.@opencode/corenow inlines models.dev's catalog as one 8 MB string literal (marked// src/models-dev/snapshot.txt), which its release build fetches at publish time: "feat(build): fetch the models.dev catalog once per release and verify the bundled copy (#59173)" (d5bb993278, 2.2.0). The module is too large for the test runtime's module transfer, soharness.test.tscrashes with WebSocket 1009 "Message is too large". The tests setmodels: { fetch: false }and use only the Cloudflare provider, sopackages/agents/src/harness/opencode/tests/vitest.config.ts:21-25gains anempty-models-dev-snapshottransform, implemented in the newtests/models-dev-snapshot.ts, that replaces the literal with'{}'. It throws a named error if the marker is present but the literal changed shape, or if an@opencode/coremodule over 1 MB has no marker. The newtests/models-dev-snapshot.test.ts(4 tests) covers these cases. The example's production build keeps the catalog.examples/next/harnesses/opencode/README.md:83("OpenCode adds about 3.7 MB (gzip) to the Worker") out of date. At 2.4.2,wrangler deploy --dry-runon the example'svite buildoutput reportsTotal Upload: 28051.95 KiB / gzip: 4567.84 KiB.OpenCodeWorkerd.Interface(ourOpenCodetype,packages/agents/src/harness/opencode/types.ts:11) gainsalarm(), which runsworkspace.suspendIdle()for remote workspaces, and the workerd profile now schedules idle deadlines throughstorage.setAlarm. That only happens once a remote workspace connection opens. The PromiseOpenCodeWorkerd.createtakes noworkspaceProviders, and the harness and example create no OpenCode workspaces (the example's/workspaceis an@cloudflare/computerplugin tool), so OpenCode never arms an alarm in our objects andalarm()has nothing to suspend. Not adopted: nothing to forward today, and if OpenCode remote workspaces are ever supported, itssetAlarmcalls would have to go throughLifecycle, which owns the object's single alarm (docs/agents/agent-class.md:83); possible follow-up.No effect on us: 2.4.1 → 2.4.2 (14)
dev):package.jsonversions only.testscript only.packages/sdk.git diff v2.4.1 v2.4.2 -- packages/sdk/src/internal/instances.tsis empty.{ signal }. Additive; our plugin passes none.OpenCode.create's second (embed) argument in favour ofcreateWithHost. We only callOpenCodeWorkerd.create, whose options are unchanged.packages/plugin/src/gui: "fix(app): redesign the add extension dialog (#66355)" (5050225a09), "docs(plugin): describe the new quote text in ComposerQuote (#66248)" (a4bea47aa5), "feat(app): move the file tree to the right from its context menu (#66012)" (f25b09005e), "feat(app): pin inbox sessions and list archived ones in the sidebar (#65961)" (b5948e5229). We don't use@opencode/plugin/gui*.No effect on us: 2.0.24 → 2.4.1 (as reviewed in #2907, #3040 and #3102)
I checked every commit in
git log v2.0.24..v2.4.1 -- packages/sdk packages/plugin(139) against the hashes below and in the entries above, and none is missing.package.jsonversions only.@opencode/plugin/tui.ctx.experimental.automation. Additive; we create no automations.packages/plugin/src/gui: 176db8d456, 34411562e4, 3bc82a19b3, 80d7c17d8e, cd0d037d68, 723e0a9105, d412042beb, 22377659a8, 363217b2c4. We don't use@opencode/plugin/gui*.plugin/src/tuiand its optional peers.revokeon integration OAuth methods. We register no integrations.videokind in the idle hook's background list. We don't register the idle hook.tool.addgains defaulted type parameters, tool hook events gaininfoandcodemode. We register no tool hooks; the example'sworkspace.tstool.transformstill typechecks.@opencode/plugin's optional TUI peers: 8db3d852cc, 13e8186410, ab4d1f3ab1, c9c1dc04f7, c7ddff776c, def5d948ef, d0a2ce32de, 65f8907708, da40b8fbe3, fcad1319bf, c4bf172532.plugin/src/tuionly: de284dc1bc, 4cba1b7f5d.ctx.experimental.generatedropsvideo), b81c5f3465 (Effect entry pointTool), 2f886a2a5e (session request hook metadata), 2ef38b2172 (provider sign-in), e56eff2bc0 (fork field on session hooks;sessions.forkunchanged), 53f2d631df (freeform tool input), 64bd35afa9 and 05d347d750 (Promise tool signals), 37729b1df1 and b88b867b6e (experimental.model.resolve), 8f0fc21e71, f29e281322, 89f3ac108f, 8de0323975 (new artifact, provider, tool and goal domains), 2a0639a11f (ctx.generatedeprecated), 1438073271 and 73517183b3 (Promise tool hook errors), 6c74e11e95, bc5fa1ccf3, 6a7cedcbf1, d78267503d, 70c6c8cbc5 (new plugin methods), 21ed6e4103 (VCS type field).ctx.event.subscribegainstypes; the harness subscribes through the client, which still delivers every event.@opencode/ai/effect): import paths inside the plugin package.DeepMutablekeeps its shape and we don't name it.providerStaterenamednativeon a session hook event. We don't register session hooks; the shapes the harness reads typecheck and pass the tests.OpenCodeWorkerd.create({ plugins })registers our plugin before restart recovery. Same API; the crash-recovery tests pass.@opencode/sdk/effectfile overrides), c28e9ec311 (Bun CLI plugin runtime): not used.close()still aborts in-flight requests.Decisions
main; the only overlap ispackages/agents/src/harness/opencode/tests/vitest.config.ts, wheremainnow importscloudflareTestfrom@cloudflare/vitest-plugin, and thehttp-apipath andempty-models-dev-snapshottransform sit alongside it. I regenerated the lockfile for 2.4.2, re-measured the example's Worker size, and wrote a new changeset that says "tested with 2.4.2". fix(agents): upgrade opencode to 2.4.1 #3102 is closed as superseded.^2.2.3, not^2.4.2. Thesdk-hook carrier needs 2.2.3, the first release that runs pluginsdkhooks before the npm loader.experimental.session.wait/logexist from 2.2.1. Nothing we use needs a newer release. Releases before 2.2.3 can't work with the new carrier: 2.2.1 and 2.2.2 lack@ai-sdk/vercel, and on 2.2.0 and earlier the carrier would reach the npm loader first.patchchangeset. The peer floor moves within major 2, and the source change fixes a provider that's broken on in-range releases.sdkhook rather than borrow another bundled package. fix(agents): upgrade opencode to 2.2.1 #2776 usedgitlab-ai-provideras a stand-in carrier. Since 2.2.3 a plugin'ssdkhook answers before the loader, so we no longer depend on which AI SDK packages OpenCode bundles. Thesdkvalue is a placeholder object, because ourlanguagehook always supplies the model.models: { fetch: false }). Shipped code and the example's production build are unchanged.alarm()to OpenCode. See the new-feature entry above: with no remote workspaces it is a no-op, and wiring it would mean letting OpenCode share the alarmLifecycleowns.Needs a maintainer
None.
Affected open PRs
github-actions[bot]committed to it, so it gets a "Superseded by" comment and is closed. Its two open review threads (no 2.0.24-database upgrade test;@number0/irohas an optional native dependency of@opencode/core) apply here unchanged.gitlab-ai-providercarrier, and this PR uses thesdk-hook route that 2.2.3 added.opencode.sessions.wait(atharness.ts:536, which this PR changes toopencode.experimental.session.wait(, so the two conflict textually. It should keep the new call when rebased.No other open PR changes
@opencode/*versions: I readpackages/agents/package.jsonon the heads of #3223, #3057, #2929, #2511, #2421, #2416, #2273, #2250 and #2203.Other changes
packages/agents/package.json: dev pins2.0.24→2.4.2and peer range^2.0.24→^2.2.3for both packages.examples/next/harnesses/opencode/package.json: pins2.0.24→2.4.2.pnpm-lock.yaml: regenerated withpnpm install. It now resolves only@opencode/*2.4.2. The other entries that changed belong to OpenCode's dependency tree, for exampleeffectand@effect/*4.0.0-rc.112 → 4.1.0,@opentui/core0.5.14 → 0.9.9,@opencode-ai/pty0.2.0 →@opencode/pty0.6.0,gitlab-ai-provider6.19.0 → 6.24.0,@ai-sdk/vercel/cohere/perplexityremoved, and@number0/iroh1.2.0 added. Through pnpm's peer resolution,ws8.21.3 → 8.23.0 andzod4.1.8 → 4.6.7 appear in the peer suffixes of a few unrelated packages (OpenCode's@effect/platform-node-shared4.1.0 needsws ^8.22.0)..changeset/opencode-2-4-2.md:agentspatch describing the new peer floor, the provider and harness changes, and the one-way door.Evidence
main:harness-opencode31/31,workerssrc/tests/models/opencode5/5. At 2.4.2 withmain'sagents/models/opencode(all other changes in place):harness-opencode14 of 35 fail withstatus: "unanswered".harness-opencode35/35 (31 existing plus the 4models-dev-snapshot.test.tstests).workerssrc/tests/models/opencode5/5.pnpm run buildandpnpm run checkpass: sherif, the exports check, the public API check, the instance-names check, oxfmt, oxlint, and typecheck (134 projects). The example'svite buildsucceeds.Merge Danger
Door: one-way
Blast Radius: OpenCode harness users
Users of
agents/harness/opencodeoragents/models/opencodeon opencode below 2.2.3 get a peer-dependency warning and need to upgrade@opencode/sdkand@opencode/pluginto 2.2.3 or later (2.4.2 tested). Users on 2.2.1–2.2.2 are already broken. Once a Durable Object has run opencode 2.2.0 or later, OpenCode's migrations can't be rolled back:media:<hash>references into a newblobtable.kvinto a newjobtable, and thekvrows are deleted.session_parttable with the message row's inline content left empty, which older releases don't read.machinetable, and itsautomationmigration drops run-limited schedules. Our harness never creates schedules.An older opencode release can't read those sessions. 2.4.2 adds no migrations. Our own code stores nothing new.
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.