Repository navigation
fix(agents): upgrade opencode to 2.2.5 - #2786
Closed
github-actions[bot] wants to merge 1 commit into
Closed
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.5 (peer range ^2.2.3). OpenCode 2.2.1 stopped bundling @ai-sdk/vercel, which agents/models/opencode named as its carrier package; 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/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_6682d6557cc777114c16c3c454699c61264df21f6d7b23e29dfa5a3bac803fd2:da5e60b1460f9b91725dfead751cda5158f46bcef0304d90cd32814ebe21f748
🦋 Changeset detectedLatest commit: 4c81255 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 |
Contributor
Author
|
Superseded by #2849 |
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.5, and switches the Cloudflare provider to OpenCode'ssdkhook.@opencode/sdk(dev, example)2.0.242.2.5@opencode/plugin(dev, example)2.0.242.2.5@opencode/sdkpeer range^2.0.24^2.2.3@opencode/pluginpeer range^2.0.24^2.2.3There have been 18 opencode v2 releases since 2.0.24 (2.0.25 to 2.2.5). All of them already install under our
^2.0.24peer range, and on 2.2.1 and later our currentagents/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 that runs OpenCode's npm loader after pluginsdkhooks, so a plugin can supply the AI SDK provider itself. This PR does that, moves the floor to 2.2.3, and pins 2.2.5. It supersedes #2779 (the same change for 2.2.3); 2.2.4 and 2.2.5 needed no further code changes.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 loaded 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.5 and the old provider code, 14 of 31harness-opencodetests fail withNpm.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 answers thesdkhook for its own provider (index.ts:141), so it no longer needs a carrier package or the unreachable Vercel base URL:languagehook (index.ts:148) still builds the model fromagents/models/ai-sdk, and thesdkhook's registration is disposed with the others.sessions.waitandsessions.logare@deprecated Use client.experimental.session.wait/log. Removed in the next minor.(still so in 2.2.5). The harness called them atpackages/agents/src/harness/opencode/harness.ts:536,:670and:1242, andOpenCodeLogEventis derived fromsessions.log(types.ts:45). All moved to the new names:effect/unstable/httpapimoved toeffect/http-api(2.2.5 resolves effect 4.0.6), so the Vite stub for Scalar's UI no longer matched anything. Fixed inpackages/agents/src/harness/opencode/tests/vitest.config.ts:16andexamples/next/harnesses/opencode/vite.config.ts:16:@opencode/core2.2.x inlines models.dev's catalog as one ~8 MB string, too large for the WebSocket message that carries a module into the vitest-pool-workers runtime (Message is too large); fix(agents): upgrade opencode to 2.2.3 #2779 saw theharness-opencodepool crash on it.vitest.config.ts:25adds anempty-models-dev-snapshottransform that swaps in an empty catalog. These tests already setmodels: { fetch: false }and use only the Cloudflare provider.ctx.experimental.artifact(an artifact-provider registry) to the pluginContextand exportsArtifactfrom@opencode/plugin. Additive; nothing of ours implements or constructs a pluginContext. Not adopted: we have no artifact store to offer; possible follow-up.No effect on us (82)
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. Since 2.2.3 a plugin'ssdkhook runs before the npm fallback, 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. The package name is the one fix(agents): upgrade opencode to 2.2.1 #2776 proposed.^2.2.3, pins2.2.5. 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), andexperimental.session.*exists from 2.2.1. Nothing in our code needs 2.2.4 or 2.2.5, so the floor stays at 2.2.3, as fix(agents): upgrade opencode to 2.2.3 #2779 tested; dev and example pins are exact at 2.2.5, which this run tested.sessions.waitandsessions.lognow. They still work on 2.2.5 but are marked "Removed in the next minor". The floor already guarantees the replacements.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
media:<hash>refs in a newblobtable (70c69f0, migration20261025123711_blob), and 2.2.4 moves background job markers fromkvinto a newjobtable and deletes them fromkv(664c8f0, migration20261030054400_job). Older releases can't read either. Options: accept it (users on^2.0.24can already install 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 migrations are upstream's.Affected open PRs
sdk-hook provider fix(agents): upgrade opencode to 2.2.1 #2776 planned once OpenCode ran its npm loader after plugin hooks (#60380, 2.2.3).packages/agents/src/harness/opencode/harness.tsaround:536; fix(opencode): stop pausing wait() and prompt() after every run #2785 keepsopencode.sessions.wait(there (our change applies to its version only with fuzz), so whichever lands second should keep both itsidleflag andexperimental.session.wait. Its new use ofopencode.sessions.active()is not deprecated in 2.2.5.Other changes
packages/agents/package.json: dev pins2.0.24→2.2.5, peer ranges^2.0.24→^2.2.3for@opencode/sdkand@opencode/plugin.examples/next/harnesses/opencode/package.json: pins2.0.24→2.2.5.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-5.md:agentspatch: the new floor, why, and the one-way door.pnpm-lock.yaml: regenerated bypnpm install; both importers resolve only@opencode/*@2.2.5(no2.0.24left), plus the transitive moves that come with it (for example@opentui/core0.8.0,effect4.0.6,@opencode/pty0.4.0).Evidence
harness-opencode31/31 andworkerssrc/tests/models/opencode5/5. On 2.2.5 with the old provider code (new test config),harness-opencode17/31: 14 fail withNpm.add is unavailable in the workerd profile.harness-opencode31/31,workerssrc/tests/models/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). The example'svite buildpasses.pnpm install --frozen-lockfilereports the lockfile up to date.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 or later. 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, file attachments and file tool results live in theblobtable, and once 2.2.4 or later has run, background job markers live in thejobtable; pinning back below those releases leaves them unreadable.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.