Repository navigation
fix(agents): upgrade opencode to 2.4.0 - #3040
github-actions[bot] wants to merge 2 commits into
Conversation
Move @opencode/sdk and @opencode/plugin to 2.4.0, 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 and the 8 MB models.dev snapshot, and correct the example's Worker size. Gardener-Operation: op_491276f2df18de2c74b140a534d534eea59ffd16ebbe3e469bb080978b6aa3bc:b0f8ca17e5463b5a44c4106c6a2ab347e48836094f873aa05a9d1b3474bee833
🦋 Changeset detectedLatest commit: 4144fe1 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.0", | ||
| "@opencode/sdk": "2.4.0", |
There was a problem hiding this comment.
🔴 Upgrade deletes active run-limited schedules
On upgrade, @opencode/sdk 2.4.0 skips active schedules that still have a fixed number of runs left. The migration then drops the old schedule table, so those prompts never run.
Learn more
OpenCode 2.2.3 was already allowed by the previous peer range. Its experimental schedule API stores a repeat limit supplied as ends.times in schedule.remaining_runs. On startup, the harness opens OpenCode against the existing Durable Object database through the harness factory. OpenCode 2.4.0 includes 20261116043204_automation, which copies schedules only when remaining_runs IS NULL and then drops the old table. A schedule with a positive remaining run count is therefore lost even when it is active and has a next due time.
Example: Create an hourly prompt with a three-run limit on OpenCode 2.2.3. Upgrade while two runs remain. Neither remaining run is migrated or fires.
Recommended fix: Preserve these schedules and their remaining run counts in a compatible migration before adopting 2.4.0. If the new engine cannot represent them, block the upgrade for affected objects until operators can export or replace them. Add an upgrade test that opens storage containing an active run-limited schedule, not just a fresh database.
Was this helpful? React with 👍 or 👎 to provide feedback.
There was a problem hiding this comment.
Declined for this PR. The upstream behaviour is real: @opencode/core 2.4.0's 20261116043204_automation copies only rows with remaining_runs IS NULL, then drops schedule. But that migration is OpenCode's, and neither agents/harness/opencode nor agents/models/opencode creates OpenCode schedules (nothing in either calls the schedule API). Only apps that call experimental.schedule with ends.times themselves are affected. Running our own migration ahead of OpenCode's would mean owning OpenCode's schema, which this upgrade won't take on. Leaving this open so a maintainer can decide whether to report it upstream or list it under Merge Danger.
| @@ -47,10 +47,10 @@ importers: | |||
| version: 1.32.2(@cfworker/[email protected])([email protected])([email protected]) | |||
| '@openai/agents': | |||
| specifier: ^0.12.0 | |||
| version: 0.12.0(@aws-sdk/[email protected])(@cfworker/[email protected])(@smithy/[email protected])([email protected])(ws@8.21.3)([email protected]) | |||
| version: 0.12.0(@aws-sdk/[email protected])(@cfworker/[email protected])(@smithy/[email protected])([email protected])(ws@8.23.0)([email protected]) | |||
There was a problem hiding this comment.
Declined: this is expected and comes from the OpenCode upgrade. OpenCode 2.4.0 brings in effect 4.1.0, and @effect/[email protected] depends on ws: ^8.22.0, which adds [email protected] to the lockfile. With autoInstallPeers: true, pnpm then resolves the optional ws peer of openai / @openai/agents to that version. It's a semver-minor bump within ws 8. pnpm install --frozen-lockfile, pnpm run build and pnpm run check pass on this lockfile.
…ule loses its marker - Move the empty-models-dev-snapshot transform into tests/models-dev-snapshot.ts - Throw for an @opencode/core module over 1 MB that has no snapshot marker - Add models-dev-snapshot.test.ts Gardener-Operation: op_742bba7d6a53511e2d39ab4cec73726303dec1b398ae97fa85a593e10926a77e:ec02428e70815e43bebca67ccda102da5c62e89da54417dfe2632d6be117475f
|
Review round 1: fixed one finding and declined two.
The review body only gave a count of the findings. Tests: |
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
|
Superseded by #3102, which carries these changes over and moves to opencode 2.4.1. |
Summary
Moves
agents/harness/opencodeandagents/models/opencodefrom opencode 2.0.24 to 2.4.0, 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.0 since our pin. All of them are 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 fixes from #2907 (2.3.2), which onlygithub-actions[bot]committed to, and moves on to 2.4.0. Nothing from 2.3.2 to 2.4.0 needed a code change. 2.4.0 was published today and 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:59). That way OpenCode loaded a package in-process and ourlanguagehook swapped in the model. Without the bundled package, OpenCode hands the provider to its npm installer, which can't run in workerd. With 2.4.0 and the old code, 14 of the 31harness-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. The plugin now answers thesdkstep itself, under a package name that doesn't exist, and keeps itslanguagehook:CARRIER_PACKAGEnow explains thesdkhook.opencode.sessions.waitandopencode.sessions.logbecame aliases marked@deprecated Use `client.experimental.session.wait`. Removed in the next minor.(loghas 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.0 depends oneffect4.1.0. Because of this, theempty-httpapi-scalarstub inpackages/agents/src/harness/opencode/tests/vitest.config.ts:16andexamples/next/harnesses/opencode/vite.config.ts:16matched no file.@opencode/corenow inlines models.dev's catalog as one 8 MB string literal (// src/models-dev/snapshot.txtindist/chunks/generate-*.js). 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, andharness.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.tsgains anempty-models-dev-snapshottransform that replaces the literal with'{}'. If the pattern stops matching, the transform throws a named error. 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.wrangler deploy --dry-runon the example'svite buildoutput at 2.4.0 reportsTotal Upload: 27734.85 KiB / gzip: 4486.55 KiB.No effect on us: 2.3.2 → 2.4.0 (17)
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)
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.Decisions
main, and 2.3.2 → 2.4.0 needed nothing more except the Worker size in the README. I regenerated the lockfile for 2.4.0 and wrote a new changeset. fix(agents): upgrade opencode to 2.3.2 #2907 gets closed as superseded.^2.2.3, not^2.4.0. 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 anything newer. 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 this PR supersedes and closes it.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.Other changes
packages/agents/package.json: dev pins2.0.24→2.4.0and peer range^2.0.24→^2.2.3for both packages.examples/next/harnesses/opencode/package.json: pins2.0.24→2.4.0.pnpm-lock.yaml: regenerated withpnpm install. It now resolves only@opencode/*2.4.0. Every other entry that changed belongs to OpenCode's dependency tree, for exampleeffect4.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, andgitlab-ai-provider6.24.0 and@number0/iroh1.2.0 added..changeset/opencode-2-4-0.md:agentspatch describing the new peer floor, the provider and harness changes, and the one-way door.Evidence
harness-opencode31/31 andworkerssrc/tests/models/opencode5/5. With 2.4.0 and the oldagents/models/opencode(the other fixes in place),harness-opencodefails 14/31 withstatus: "unanswered".harness-opencode31/31,workerssrc/tests/models/opencode5/5. Build (pnpm run build), typecheck (134 projects), lint (oxlint, 0 warnings, 0 errors), format (oxfmt), sherif, the public API check and the exports check pass (pnpm run check). 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.0 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. From 2.2.0, session media is stored asmedia:<hash>references into a newblobtable. From 2.2.4, background job markers move out ofkvinto a newjobtable and thekvrows are deleted. An older opencode release can't read those sessions. 2.4.0 adds amachinetable (20261119211416_machine,20261120004954_machine-key). 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.