Skip to content

fix(agents): upgrade opencode to 2.2.6 - #2849

Closed
github-actions[bot] wants to merge 1 commit into
mainfrom
gardener/upstream/opencode-2.2.6
Closed

github-actions[bot] wants to merge 1 commit into
mainfrom
gardener/upstream/opencode-2.2.6

Conversation

@github-actions

@github-actions github-actions Bot commented Nov 9, 2026 •

Copy link
Copy Markdown
Contributor

Summary

Moves agents/harness/opencode and agents/models/opencode from opencode 2.0.24 to 2.2.6, and switches the Cloudflare provider to OpenCode's sdk hook.

Package From To
@opencode/sdk (dev, example) 2.0.24 2.2.6
@opencode/plugin (dev, example) 2.0.24 2.2.6
@opencode/sdk peer range ^2.0.24 ^2.2.3
@opencode/plugin peer range ^2.0.24 ^2.2.3

opencode 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.24 peer range, but on 2.2.1 and later every agents/models/opencode turn 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 plugin sdk hooks, 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

  • high · breaking: "chore(core): remove bundled cohere, vercel and perplexity AI SDK packages (#59771)" (fc6922f, @opencode/core 2.2.1, a dependency of @opencode/sdk). packages/agents/src/models/opencode/index.ts:60 named aisdk:@ai-sdk/vercel as the provider's package. That made OpenCode's sdk step load a package in-process, and our language hook 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 31 harness-opencode tests fail with Npm.add is unavailable in the workerd profile. The fix uses the next item.
  • high · workaround: "fix(core): run dynamic provider npm fallback after external sdk hooks (#60380)" (b5c2231, @opencode/core 2.2.3). Our plugin now answers the sdk hook for its own provider (index.ts:141), so it no longer needs a carrier package or the unreachable Vercel base URL:
    -const CARRIER_PACKAGE = "aisdk:@ai-sdk/vercel";
    -const UNREACHABLE_BASE_URL = "https://workers-ai.binding.invalid/v1";
    +const CARRIER_PACKAGE = "aisdk:agents/models/opencode";
    ...
    -            package: CARRIER_PACKAGE,
    -            settings: { baseURL: UNREACHABLE_BASE_URL, apiKey: "binding" }
    +            package: CARRIER_PACKAGE
    ...
    +      const sdk = await ctx.aisdk.hook(
    +        "sdk",
    +        (event) => {
    +          event.sdk = { provider: CLOUDFLARE_PROVIDER_ID };
    +        },
    +        { providerID }
    +      );
    The existing language hook (index.ts:149) still builds the model from agents/models/ai-sdk. The sdk hook is disposed along with the other hooks (index.ts:162).
  • medium · breaking: "refactor(client): group experimental SDK methods under client.experimental (#59072)" (9a9386e, 2.2.1). In 2.2.6 sessions.wait and sessions.log are still marked @deprecated Use `client.experimental.session.wait`. Removed in the next minor. The harness called them at packages/agents/src/harness/opencode/harness.ts:536, :670 and :1242, and OpenCodeLogEvent is derived from sessions.log (types.ts:45). All four now use the new names:
    -              opencode.sessions.wait(
    +              opencode.experimental.session.wait(
    ...
    -      yield* opencode.sessions.log(
    +      yield* opencode.experimental.session.log(
    ...
    -  ReturnType<OpenCode["sessions"]["log"]> extends AsyncIterable<infer E>
    +  ReturnType<OpenCode["experimental"]["session"]["log"]> extends AsyncIterable<
    None of the other sessions.* methods the harness calls are deprecated in 2.2.6.
  • medium · breaking (tests and example build): "chore: upgrade Effect to rc.118 (#50231)" (1aae67e, 2.0.27). effect/unstable/httpapi moved to effect/http-api (2.2.6 resolves effect 4.1.0), so the Vite stub for Scalar's UI no longer matched anything. Fixed in packages/agents/src/harness/opencode/tests/vitest.config.ts:16 and examples/next/harnesses/opencode/vite.config.ts:16:
    -        id.includes("/effect/dist/unstable/httpapi/internal/httpApiScalar.js")
    +        id.includes("/effect/dist/http-api/internal/httpApiScalar.js")
  • medium · breaking (tests): @opencode/core 2.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:20 adds an empty-models-dev-snapshot transform that substitutes an empty catalog. These tests already set models: { fetch: false } and use only the Cloudflare provider.
  • low · new feature: "feat(core): add experimental artifacts with pluggable providers (#60351)" (8f0fc21, 2.2.4). Adds ctx.experimental.artifact to the plugin Context and exports Artifact from @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):

  • "release: v2.2.6" (dc2ffcf): version bump only.
  • "fix(app): show Open in only in file and review headers (#62174)" (e23d54c): plugin/src/gui, GUI plugins only.
  • "fix(app): show failed and offline review diffs instead of a clean tree (#61862)" (6469454): GUI plugins only.
  • "refactor(ai): flatten generation knobs on requests and defaults (#60971)" (9a3f03e): touches one sdk test and @opencode/ai, which we don't import. Our model goes through the AI SDK language hook.
  • "feat(app): group settings navigation and distinguish pairing and changelog icons (#61687)" (3343941): GUI icon names.
  • "fix(desktop): restart plugins when an update handoff fails (#61649)" (4a6067d): desktop GUI plugins.
  • "fix(app): give plugin startup an explicit gate that always opens (#61580)" (605e912): GUI plugin host.
  • "fix(app): derive server controllers from an explicit lifecycle machine (#61595)" (9a7f22a): GUI plugin host APIs.
  • "feat(app): let GUI plugins render and add actions to code blocks (#61533)" (27dd925): GUI plugins only.
  • "feat(plugin): add settings rows, selects and menu rows to ctx.ui (#61527)" (3fcdcb3): GUI plugin ctx.ui; our server plugins don't use it.
  • "feat(app): let GUI plugin panels size the side region (#61509)" (69ef55f): GUI plugins only.
  • "feat(app): let GUI plugins add color themes (#61485)" (4dd7b26): GUI plugins only.
  • "chore(tui): bump OpenTUI to 0.8.1 (#60913)" (8db3d85): TUI peer dependency floor only.
  • "release: v2.2.5 (#60744)" (4878a0e): version bump only.

2.0.24 → 2.2.5 (re-checked against this diff; same verdicts as #2786):

  • "release: v2.2.5" (9bbb8ce), "release: v2.2.4 (#60664)" (872f694), "release: v2.2.3 (#60564)" (b44b716), "release: v2.2.2 (#60337)" (4efad23), "release: v2.2.1 (#60113)" (f74b141), "release: v2.2.0 (#59558)" (8697644): version bumps only.
  • "sync release versions for v2.1.4 / v2.1.3 / v2.1.2 / v2.1.1 / v2.1.0 / v2.0.32 / v2.0.31 / v2.0.30 / v2.0.29 / v2.0.28 / v2.0.27 / v2.0.26 / v2.0.25 / v2.0.24 [skip ci]" (2a3e7c0, e965774, 4b50f5c, 133b1eb, d30e990, 4e95dac, 83c5abb, f40dc43, 34d8ded, c5aabae, 03cb9b9, 8059cdc, 62e087f, bd55d48): versions only (14 commits).
  • "feat(core): add Claude Agent provider (#58782)" (f29e281): plugin session types for a provider we don't use.
  • "feat(app): fit the session header at narrow timeline widths (#59512)" (8fdf2e5): GUI.
  • "chore(tui): use OpenTUI 0.8.0 (#60385)" (13e8186): TUI peer dependency.
  • "fix(app): match own server loopback port before treating http servers as local (#60460)" (a88d3ca): desktop app.
  • "refactor(ai): one tool() for both clients (#60407)" (7a82f3a): touches only sdk tests.
  • "feat(app): unify quote comments and browser annotations (#60164)" (2fc3716): GUI plugin surface.
  • "feat(core): add image_generate tool (#59939)" (89f3ac1): plugin session types for a tool we neither offer nor remove.
  • "feat(core): add /goal with a client-side done check (#59437)" (8de0323): adds an experimental.idle hook; we don't register one.
  • "chore(plugin): remove unused @tsconfig/node22 (#59718)" (1dab9ae): dev dependency.
  • "feat(app): refine artifact previews and file actions (#59657)" (b3de41a): GUI.
  • "feat(app): add session location menu actions (#59607)" (4ba064f): GUI.
  • "feat(protocol): define experimental image and decision generation endpoints (#59190)" (2a0639a): additive API; we call none of it.
  • "feat(app): manage desktop plugins in Extensions › Plugins (#59489)" (5792c3e): desktop app.
  • "fix(app): list What's new with About in settings (#59471)" (19d87a7): desktop app.
  • "feat(plugin): add toasts, dialogs, notifications, UI, tabs and composer APIs to GUI plugins (#59469)" (758cf5a): GUI plugins only.
  • "feat(plugin): add OpenCode Desktop GUI plugins (#55246)" (dae4077): GUI plugins only.
  • "fix(tui): identify config-defined providers (#57007)" (cc4faf4) and its revert (cd15a6a): TUI; net zero.
  • "fix(release): add repository to ai, plugin and cli package.json (#59422)" (fa5b4bd): package metadata.
  • "ci: separate release builds from signing and publishing (#59046)" (6996bbc): CI.
  • "chore: upgrade opentui v0.7.0 (#59295)" (ab4d1f3), "chore: upgrade opentui v0.6.8 (#58380)" (c9c1dc0), "chore: OpenTUI 0.6.5 (#55339)" (c7ddff7), "chore(tui): revert OpenTUI 0.6 upgrade (#55300)" (def5d94), "chore(tui): upgrade OpenTUI to 0.6.2 (#55083)" (65f8907), "chore: upgrade opentui v0.5.17 (#53904)" (da40b8f), "chore: upgrade opentui v0.5.16 (#53805)" (fcad131): TUI only.
  • "feat(plugin): filter event subscriptions by type (#58864)" (1434464): optional filter on the plugin event.subscribe. The harness subscribes through the SDK client, without a filter.
  • "chore: merge beta into dev" (be315b1), "chore: merge dev into beta" (4b83402, fd0efe3, bcd713e, 316a688), "Merge remote-tracking branch 'origin/dev' into beta" (15d4afd), "Merge branch 'dev' into beta" (3a58a0c): merges that bring in versions, metadata and additive plugin API.
  • "fix(server): stop form polling from booting idle locations (#59083)" (c8cf3a5), "fix(app,server): stop subagent form polling from stalling sends (#57684)" (946c331): affect the instances option, which we don't use.
  • "refactor(ai): make Promise the root entry and move Effect to @opencode/ai/effect (#58847)" (dad29a8): we import nothing from @opencode/ai.
  • "refactor(core): keep Go allowance out of messages and sessions (#58765)" (de284dc), "feat(core): record reported cost and Go allowance (#58562)" (4cba1b7): TUI context.
  • "refactor: remove redundant casts and duplicate helpers across sdk, plugin, codemode, and schema (#57996)" (7a62a46): internal; typecheck passes.
  • "chore: use bun check for local typechecks and TypeScript 7.1 in CI (#58253)" (84578e1), "chore: upgrade typecheck to TypeScript 7.0.2 (#56300)" (23359e9), "chore(ci): speed up and stabilize the test workflow (#55866)" (17229d2): tooling.
  • "feat(plugin): expose session instruction entries to plugins (#56550)" (6c74e11), "feat(plugin): expose session list (#56264)" (bc5fa1c), "feat(plugin): let plugins assert permissions (#54930)" (6a7cedc), "feat(plugin): expose credential.activate to server plugins (#52797)" (d782675), "feat(integration): add declarative external connection method (#53672)" (70c6c8c): additive plugin API.
  • "fix(app): show untracked folders as one review row (#57527)" (21ed6e4), "feat(app): add generative UI to the GUI (#54747)" (f232362), "feat(tui): report pending session status to the terminal (#55172)" (d0a2ce3): GUI/TUI.
  • "refactor: v2.1 minor breaking changes (#57260)" (acdcdb8): renames SessionCompactionResult.providerState to native. We register no compaction hook.
  • "fix(plugin): keep each Promise hook rejection on its own tool call (#55263)" (7351718): our hooks don't reject.
  • "fix(plugin): return Promise tool throws as tool failures (#54913)" (1438073): the example's workspace tools throw on 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.
  • "chore: upgrade Effect to 4.0.1 (#54198)" (41b03de): plugin README wording; we don't import effect.
  • "feat(sdk): seed host plugins before recovery and harden workerd defaults (#54219)" (55dde88): OpenCodeWorkerd.create({ plugins }) now registers plugins before suspended sessions resume. None of our code works around the old order.
  • "fix(core): route file overrides through Workspace.connect (#54089)" (c50e39b): Effect-entry exports we don't import.
  • "fix(cli): give plugins the host's Effect (#53422)" (c28e9ec): CLI plugin loader; we pass plugin objects in-process.
  • "fix(sdk): release completed embedded request signals (#53613)" (9ee97d8): internal fix, no API change.
  • "chore: remove unused dependencies from V2 packages (#53482)" (50ae4bd): drops zod and @standard-schema/spec from @opencode/plugin. We don't get either through it.

Decisions

  • Answer the sdk hook instead of finding another bundled carrier. fix(agents): upgrade opencode to 2.2.1 #2767 carried the provider in gitlab-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's sdk hook runs before the npm fallback. The provider now names aisdk:agents/models/opencode, a package that doesn't exist, and our hook supplies a placeholder SDK. The model still comes from the existing language hook. The package name is the one proposed in fix(agents): upgrade opencode to 2.2.1 #2776.
  • Peer floor ^2.2.3, pins 2.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 claim agents/models/opencode before 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.
  • Move off sessions.wait and sessions.log now. They still work on 2.2.6 but are marked "Removed in the next minor". The new floor guarantees the replacements exist.
  • Changeset: 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.
  • Stub the models.dev snapshot only in the harness test config. The Worker build and the example are unchanged. The stub exists only because of vitest-pool-workers' limit on module transfer size.

Needs a maintainer

  • No rollback below 2.2.0 or 2.2.4 for existing Durable Objects. opencode 2.2.0 stores file attachments and file tool results as media:<hash> refs in a new blob table (migration 20261025123711_blob). 2.2.4 moves background job markers from kv into a new job table (20261030054400_job) and deletes them from kv. Older releases can't read either. 2.2.6 adds no further migrations; the newest in @opencode/core 2.2.6 is still 20261030054400_job. Options: accept this (users on ^2.0.24 can 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 @experimental and the migrations are upstream's.

Affected open PRs

Other changes

  • packages/agents/package.json: dev pins 2.0.24 → 2.2.6 and peer ranges ^2.0.24 → ^2.2.3 for @opencode/sdk and @opencode/plugin.
  • examples/next/harnesses/opencode/package.json: pins 2.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 the empty-models-dev-snapshot transform above.
  • packages/agents/src/harness/opencode/harness.ts, packages/agents/src/harness/opencode/types.ts: the move to experimental.session above.
  • packages/agents/src/models/opencode/index.ts: the sdk hook, the new carrier name and the removed Vercel settings above. The comment on CARRIER_PACKAGE now explains why the name is safe.
  • .changeset/opencode-2-2-6.md: agents patch. It states the new floor, the reason for it, and that the door is one-way.
  • pnpm-lock.yaml: regenerated by pnpm install. Both importers resolve only @opencode/*@2.2.6, with no 2.0.24 left, plus the transitive moves that come with it (effect 4.0.0 → 4.1.0, @opentui/core 0.5.14 → 0.8.1, @opencode/pty 0.4.0). No docs name the old peer range.

Evidence

  • Before: on 2.0.24, harness-opencode 31/31 and workers src/tests/models/opencode 5/5. On 2.2.6 with the old provider code (and the new test config), harness-opencode 17/31: 14 fail with Npm.add is unavailable in the workerd profile.
  • After: harness-opencode 31/31, workers src/tests/models/opencode (provider.test.ts, language-v3.test.ts) 5/5. pnpm run build and pnpm run check pass (sherif, exports check, oxfmt, oxlint, typecheck of all 133 projects). The example's vite build passes, and pnpm install --frozen-lockfile reports the lockfile is up to date.

Merge Danger

Door: one-way

Blast Radius: OpenCode harness users

Anyone on @opencode/sdk or @opencode/plugin below 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/opencode fails 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 the blob table. Once 2.2.4 or later has run, background job markers live in the job table. Pinning back below those releases leaves that data unreadable.


Opened by Gardener's opencode-upgrade task. 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's pr-review-fix task.


Devin Review

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
@github-actions github-actions Bot added the dependencies Pull requests that update a dependency file label Nov 9, 2026
@changeset-bot

changeset-bot Bot commented Nov 9, 2026

Copy link
Copy Markdown

🦋 Changeset detected

Latest commit: 1ab8673

The changes in this PR will be included in the next version bump.

This PR includes changesets to release 2 packages
Name Type
agents Patch
@cloudflare/agent-think Patch

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

@devin-ai-integration devin-ai-integration Bot left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

✅ Devin Review: No Issues Found

Devin Review analyzed this PR and found no bugs or issues to report.

Devin Review

@github-actions

Copy link
Copy Markdown
Contributor Author

Superseded by #2857, which carries the same changes on opencode 2.2.7.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

dependencies Pull requests that update a dependency file

Projects

None yet

Development

Successfully merging this pull request may close these issues.

0 participants