Repository navigation
fix(agents): upgrade opencode to 2.2.6 - #2849
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.6, 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. 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, and update the test and example Vite configs for OpenCode's new effect paths and its 8 MB models.dev snapshot. Gardener-Operation: op_bbcce0211a8f0e48c61c19c39c1c402f3e6190a4658e9202fbb8311b1a82e495:ef199cfcaf96ad658f7d69c109042274e38b90538587e5f3eff606a0ce979031
🦋 Changeset detectedLatest commit: 1ab8673 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 was referenced Nov 10, 2026
Contributor
Author
|
Superseded by #2857, which carries the same changes on opencode 2.2.7. |
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.6, and switches the Cloudflare provider to OpenCode'ssdkhook.@opencode/sdk(dev, example)2.0.242.2.6@opencode/plugin(dev, example)2.0.242.2.6@opencode/sdkpeer range^2.0.24^2.2.3@opencode/pluginpeer range^2.0.24^2.2.3opencode has published 19 v2 releases since 2.0.24 (2.0.25 to 2.2.6). Users can already install all of them under our
^2.0.24peer range, but on 2.2.1 and later everyagents/models/opencodeturn fails, because OpenCode no longer bundles@ai-sdk/vercel, the package our provider borrowed (see #2776). 2.2.3 is the first release that runs OpenCode's npm loader after pluginsdkhooks, which lets a plugin supply the AI SDK provider itself. This PR does that, raises the peer floor to 2.2.3 and pins 2.2.6. The code changes are the same as #2786 (2.2.5). This PR replaces #2786 and closes it. Nothing in 2.2.6 needed 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. That made OpenCode'ssdkstep load a package in-process, and ourlanguagehook then replaced the model. On 2.2.x that package goes to OpenCode's npm installer instead, which can't run in workerd. With 2.2.6 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). Our plugin now 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:149) still builds the model fromagents/models/ai-sdk. Thesdkhook is disposed along with the other hooks (index.ts:162).sessions.waitandsessions.logare still marked@deprecated Use `client.experimental.session.wait`. Removed in the next minor.The harness called them atpackages/agents/src/harness/opencode/harness.ts:536,:670and:1242, andOpenCodeLogEventis derived fromsessions.log(types.ts:45). All four now use the new names:sessions.*methods the harness calls are deprecated in 2.2.6.effect/unstable/httpapimoved toeffect/http-api(2.2.6 resolves effect 4.1.0), 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 (// src/models-dev/snapshot.txt, still the same in 2.2.6). That string is too large for the WebSocket message that carries a module into the vitest-pool-workers runtime.vitest.config.ts:20adds anempty-models-dev-snapshottransform that substitutes an empty catalog. These tests already setmodels: { fetch: false }and use only the Cloudflare provider.ctx.experimental.artifactto the pluginContextand exportsArtifactfrom@opencode/plugin. The change is additive. Not adopted: we have no artifact store to offer; possible follow-up.No effect on us (95)
New since #2786 (2.2.5 → 2.2.6):
plugin/src/gui, GUI plugins only.@opencode/ai, which we don't import. Our model goes through the AI SDKlanguagehook.ctx.ui; our server plugins don't use it.2.0.24 → 2.2.5 (re-checked against this diff; same verdicts as #2786):
experimental.idlehook; we don't register one.event.subscribe. The harness subscribes through the SDK client, without a filter.instancesoption, which we don't use.@opencode/ai.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 the comment accurate; no code change needed.effect.OpenCodeWorkerd.create({ plugins })now registers plugins before suspended sessions resume. None of our code works around the old order.zodand@standard-schema/specfrom@opencode/plugin. We don't get either through it.Decisions
sdkhook instead of finding another bundled carrier. fix(agents): upgrade opencode to 2.2.1 #2767 carried the provider ingitlab-ai-provider, and fix(agents): upgrade opencode to 2.2.1 #2776 is on hold because that approach depends on OpenCode internals. Since 2.2.3 a plugin'ssdkhook runs before the npm fallback. The provider now 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 proposed in fix(agents): upgrade opencode to 2.2.1 #2776.^2.2.3, pins2.2.6. The new provider needs the hook order from 2.2.3: on 2.0.24 to 2.2.2, OpenCode's npm loader would claimagents/models/opencodebefore our hook runs.experimental.session.*exists from 2.2.1. None of our code needs 2.2.4 to 2.2.6, so the floor stays at 2.2.3. The dev and example pins are exact at 2.2.6, the version this run tested.sessions.waitandsessions.lognow. They still work on 2.2.6 but are marked "Removed in the next minor". The new floor guarantees the replacements exist.patch. Only source changed, and the peer floor moves within major 2. The changeset states the new floor and that the door is one-way.Needs a maintainer
media:<hash>refs in a newblobtable (migration20261025123711_blob). 2.2.4 moves background job markers fromkvinto a newjobtable (20261030054400_job) and deletes them fromkv. Older releases can't read either. 2.2.6 adds no further migrations; the newest in@opencode/core2.2.6 is still20261030054400_job. Options: accept this (users on^2.0.24can already install 2.2.x), or add a rollback caveat to 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 that fix(agents): upgrade opencode to 2.2.1 #2776 was waiting for (#60380, 2.2.3).packages/agents/src/harness/opencode/harness.tsaround:536, where fix(opencode): stop pausing wait() and prompt() after every run #2785 keepsopencode.sessions.wait(. Whichever lands second should keep both itsidleflag andexperimental.session.wait. Its new use ofopencode.sessions.active()is not deprecated in 2.2.6.Other changes
packages/agents/package.json: dev pins2.0.24→2.2.6and peer ranges^2.0.24→^2.2.3for@opencode/sdkand@opencode/plugin.examples/next/harnesses/opencode/package.json: pins2.0.24→2.2.6.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: the move toexperimental.sessionabove.packages/agents/src/models/opencode/index.ts: thesdkhook, the new carrier name and the removed Vercel settings above. The comment onCARRIER_PACKAGEnow explains why the name is safe..changeset/opencode-2-2-6.md:agentspatch. It states the new floor, the reason for it, and that the door is one-way.pnpm-lock.yaml: regenerated bypnpm install. Both importers resolve only@opencode/*@2.2.6, with no2.0.24left, plus the transitive moves that come with it (effect4.0.0 → 4.1.0,@opentui/core0.5.14 → 0.8.1,@opencode/pty0.4.0). No docs name the old peer range.Evidence
harness-opencode31/31 andworkerssrc/tests/models/opencode5/5. On 2.2.6 with the old provider code (and the 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 buildandpnpm run checkpass (sherif, exports check, oxfmt, oxlint, typecheck of all 133 projects). The example'svite buildpasses, andpnpm install --frozen-lockfilereports the lockfile is 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 packages 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 fails). 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. Once 2.2.4 or later has run, background job markers live in thejobtable. Pinning back below those releases leaves that data 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.