Repository navigation
fix(agents): upgrade opencode to 2.4.1 - #3102
github-actions[bot] wants to merge 2 commits into
Conversation
Move @opencode/sdk and @opencode/plugin to 2.4.1, 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 #3040 (2.4.0). Gardener-Operation: op_9454129a5e8c91a7fae167b9caf5cd4aaad5add54846225fcaa0cafb9b4ee25f:d7635d9e06ca3d2aa1f4afcfa3730fcb2021a772b5d030ed912f1864178ce476
🦋 Changeset detectedLatest commit: 4b40c83 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.1", | ||
| "@opencode/sdk": "2.4.1", |
There was a problem hiding this comment.
There was a problem hiding this comment.
Declined for this round. The migrations added since 2.0.24 (session_allowance through machine-key, including blob, session_part, job and automation) are straight-line SQL with no branches on existing data. Every fresh harness test database runs each statement through prefixTables, and SQLite resolves table names when it prepares a statement, so a missed rewrite would already fail on an empty database. A real 2.0.24 fixture would need a second OpenCode version installed, or a checked-in database dump. This thread stays open in case a maintainer still wants that test.
| transitivePeerDependencies: | ||
| - '@ai-sdk/provider-utils' |
There was a problem hiding this comment.
There was a problem hiding this comment.
Declined. @number0/iroh is an optionalDependencies entry of @opencode/core, which comes in only through the @opencode/* dev pins and peer range. It is not a dependency of agents, and no Worker code imports it. The rule in AGENTS.md covers dependencies that code running in Workers relies on. The lockfile already has native optional binaries of the same kind (@opencode/pty-*, @cloudflare/workerd-*, @esbuild/*), and pnpm run build and pnpm run check pass. We can't drop it from our side without forking OpenCode.
- The rollback warning now says assistant replies move into session_part, leaving inline content empty. Gardener-Operation: op_9c8bca6a3aaf429106957d20574c96a5580879e1ddd9a35b9c0565990a6579c9:127d539d72555a92cdc085c06315a599b406d4d249696b2e9be54fd140a8fa48
|
Review round 1: fixed 1 of 3 Devin Review findings and declined 2.
The review body only gives a count of findings, so it needed no separate answer. Tests: the only change is to the changeset, so no package tests apply. |
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
|
Superseded by #3246, which carries over these changes on current |
Summary
Moves
agents/harness/opencodeandagents/models/opencodefrom opencode 2.0.24 to 2.4.1, 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.1 since our pin. All of them fall inside our
^2.0.24peer range, so users can already install them. From 2.2.1 on,agents/models/opencodedoesn't work for them: every prompt comes backunanswered. This PR carries over the source, config and docs changes from #3040 (2.4.0), which onlygithub-actions[bot]committed to, and moves on to 2.4.1. Nothing from 2.4.0 to 2.4.1 needed a code change. 2.4.1 installs because@opencode/*is inminimumReleaseAgeExclude.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). With that, OpenCode loaded a bundled package in-process and ourlanguagehook swapped in the model. Now that the package isn't bundled, OpenCode hands the provider to its npm installer, which can't run in workerd. At 2.4.1 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:CARRIER_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.1 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). Its release build fetches the catalog 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.1,wrangler deploy --dry-runon the example'svite buildoutput reportsTotal Upload: 27760.77 KiB / gzip: 4492.03 KiB.No effect on us: 2.4.0 → 2.4.1 (4)
dev):package.jsonversions only.@opencode/plugin. We don't use@opencode/plugin/tui.ctx.experimental.automationto the plugin context. Additive. Our plugin inagents/models/opencodeand the harness never create automations.No effect on us: 2.3.2 → 2.4.0 (17, as reviewed in #3040)
package.jsonversions only.packages/plugin/src/gui: "feat(desktop): drag files from the file tree into other Windows apps" (176db8d456), "fix(browser): keep the pane's tabs unless the person or the agent closes them" (34411562e4), "feat(app): send browser, file and review comments to the session with Mod+Enter" (3bc82a19b3), "feat(browser): open a link's new tab beside the tab it came from" (80d7c17d8e), "feat(desktop): signed-in browser pane with extensions, previews, prompts and agent safeguards" (cd0d037d68), "feat(app): consolidated navigation experiment" (723e0a9105), "feat(app): redesign the goal pill" (d412042beb), "feat(plugin): let GUI plugins declare their own icons" (22377659a8), "feat(app): wrap long lines in timeline code blocks" (363217b2c4). We don't use@opencode/plugin/gui*.plugin/src/tuiand its optional@opentui/*peers. We don't use@opencode/plugin/tui.revoketo integration OAuth methods. We register no integrations.videokind to the idle hook's background list. We don't register the idle hook.tool.addgains Code Mode type parameters with defaults, and tool hook events gaininfoandcodemode. We register no tool hooks. The example'sworkspace.tstool.transformstill typechecks.No effect on us: 2.0.24 → 2.3.2 (118, as reviewed in #2907 and #3040)
package.jsonversions only): c0ad18b402, a554d70499, 8aa00e805e, 5f76acb125, 4878a0e30f, 872f694b05, b44b7164ba, 4efad23dd8, f74b1416a8, 86976449c4, 2a3e7c0f34, e965774fa0, 4b50f5cc6c, 133b1ebfaf, d30e990c69, 4e95dacd81, 83c5abbbe3, f40dc433cb, 34d8ded0c5, c5aabae288, 03cb9b9946, 8059cdcbdf, 62e087ff7b, bd55d4895f (24).@opencode/plugin's optional TUI peers: 8db3d852cc, 13e8186410, ab4d1f3ab1, c9c1dc04f7, c7ddff776c, def5d948ef, d0a2ce32de, 65f8907708, da40b8fbe3, fcad1319bf, c4bf172532 (11). We don't use@opencode/plugin/tui.packages/plugin/src/gui: dae4077a96, 758cf5adbe, 19d87a72e6, 5792c3e63b, 4ba064f653, b3de41a572, 2fc371657b, a88d3ca0bc, 8fdf2e5875, 4dd7b2662c, 69ef55f02b, 3fcdcb35e8, 27dd925604, 9a7f22a776, 605e912fda, 4a6067d85c, 3343941f16, 6469454d35, e23d54ca75, ffcaeec36c, b268a4e8b0, 1cb0633c8b (22). GUI only, and the optional peers aren't installed.plugin/src/tuionly.ctx.experimental.generatedropsvideo. Not used.sessions.forkis unchanged.ctx.generatedeprecated. Not used.ctx.event.subscribegainstypes. The harness subscribes through the client, which still delivers every event.DeepMutablehas the same shape, and we don't name it.providerStaterenamednativeon a session hook event. We don't register session hooks, and the shapes the harness reads typecheck and pass the tests.OpenCodeWorkerd.create({ plugins })registers our plugin before restart recovery. Same API, and the crash-recovery tests pass.@opencode/sdk/effectonly.close()still aborts in-flight requests.I checked every commit in
git log v2.0.24..v2.4.0 -- packages/sdk packages/plugin(136) against the hashes above, and none is missing.Decisions
main, and 2.4.0 → 2.4.1 changes only the plugin context type (additive) and an optional peer floor inpackages/sdkandpackages/plugin. I regenerated the lockfile for 2.4.1, re-measured the example's Worker size, and wrote a new changeset. fix(agents): upgrade opencode to 2.4.0 #3040 is closed as superseded.^2.2.3, not^2.4.1. 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.Needs a maintainer
None.
Affected open PRs
github-actions[bot]committed to it, so it gets a "Superseded by" comment and is closed.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 will conflict textually. It should keep the new call when rebased.packages/agents/src/harness/opencode/tests/vitest.config.tsandpnpm-lock.yaml, which this PR also changes. Whichever lands second must keep thehttp-apipath inempty-httpapi-scalarand theempty-models-dev-snapshottransform, orharness-opencodecrashes at module load.No other open PR changes
@opencode/*versions. I read thepackages/agents/package.jsonpatches of #2511, #2421, #2416, #2273, #2250 and #2203.Other changes
packages/agents/package.json: dev pins2.0.24→2.4.1and peer range^2.0.24→^2.2.3for both packages.examples/next/harnesses/opencode/package.json: pins2.0.24→2.4.1.pnpm-lock.yaml: regenerated withpnpm install. It now resolves only@opencode/*2.4.1. 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.4,@opencode-ai/pty0.2.0 →@opencode/pty0.6.0,@ai-sdk/vercel/cohere/perplexityremoved, and@number0/iroh1.2.0 added. Through pnpm's peer resolution,ws8.21.3 → 8.23.0 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-1.md:agentspatch describing the new peer floor, the provider and harness changes, and the one-way door.Evidence
main:harness-opencode31/31, andworkerssrc/tests/models/opencode5/5. At 2.4.1 with the oldagents/models/opencode(other fixes in place):harness-opencode14 of 35 fail withstatus: "unanswered".harness-opencode35/35 (31 existing plus the 4 newmodels-dev-snapshot.test.tstests).workerssrc/tests/models/opencode5/5.pnpm run buildandpnpm run checkpass: sherif, the exports check, the public API 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.1 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.machinetable, and itsautomationmigration drops run-limited schedules. Our harness never creates schedules.An older opencode release can't read those sessions. 2.4.1 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.