Skip to content

fix(agents): upgrade opencode to 2.2.7 - #2857

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

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

Conversation

@github-actions

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

Copy link
Copy Markdown
Contributor

Summary

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

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

opencode has published 20 v2 releases since 2.0.24 (2.0.25 to 2.2.7). 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. This PR carries the same code changes as #2849 (2.2.6), moved to 2.2.7, and replaces it. Nothing in 2.2.7 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 named aisdk:@ai-sdk/vercel as the provider's package, so OpenCode's sdk step loaded it in-process and our language hook replaced the model. On 2.2.x that package goes to OpenCode's npm installer, which can't run in workerd. With 2.2.7 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 (packages/agents/src/models/opencode/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 with the other hooks (index.ts:163). The comment on CARRIER_PACKAGE (index.ts:50) now explains why the name is safe.
  • medium · breaking: "refactor(client): group experimental SDK methods under client.experimental (#59072)" (9a9386e, 2.2.1). sessions.wait and sessions.log are 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<
  • 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.7 resolves effect 4.1.0), so the Vite stub for Scalar's UI matched nothing. 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), too large for the message that carries a module into the vitest-pool-workers runtime. vitest.config.ts:25 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. Not adopted: we have no artifact store to offer; possible follow-up.
No effect on us (102)

New in 2.2.6 → 2.2.7 (each diff read for this PR):

  • "fix(server): stop waiting for plugins in request handlers (#62796)" (bcaf561): model.*, agent.list, skill.*, generate.*, provider.*, rpc.call and similar handlers no longer wait for plugins to load. The harness calls none of them (only sessions.*, experimental.session.*, message.list, permission.list, events.subscribe, close), and harness-opencode passes 31/31 on 2.2.7. The sdk side is test-only.
  • "feat(core): add GitHub Copilot Auto and a model resolve hook (#62997)" (37729b1) and "refactor(plugin): edit the model in place in experimental.model.resolve (#63015)" (b88b867): add the session hook experimental.model.resolve; we register none.
  • "fix(ui): list types before import in packed exports and export select.css (#62914)" (33ba535): sdk packaging script only.
  • "fix: flaky CI tests and the app races behind them (#62597)" (0f1ddb4): sdk test only.
  • "release: v2.2.7" (fedc6f2), "release: v2.2.6 (#62450)" (5f76acb): version bumps only.
  • @opencode/core 2.2.7 adds no database migration; the newest is still 20261030054400_job.

2.0.24 → 2.2.6: reviewed one by one in #2849. Our opencode code on main is unchanged since, and this PR carries the same code, so the verdicts stand:

  • "release: v2.2.6" (dc2ffcf), "release: v2.2.5 (#60744)" (4878a0e), "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.0.24 [skip ci]" (14 commits: 2a3e7c0, e965774, 4b50f5c, 133b1eb, d30e990, 4e95dac, 83c5abb, f40dc43, 34d8ded, c5aabae, 03cb9b9, 8059cdc, 62e087f, bd55d48): versions only.
  • GUI/desktop plugin and app changes: #62174 (e23d54c), #61862 (6469454), #61687 (3343941), #61649 (4a6067d), #61580 (605e912), #61595 (9a7f22a), #61533 (27dd925), #61527 (3fcdcb3), #61509 (69ef55f), #61485 (4dd7b26), #59512 (8fdf2e5), #60460 (a88d3ca), #60164 (2fc3716), #59657 (b3de41a), #59607 (4ba064f), #59489 (5792c3e), #59471 (19d87a7), #59469 (758cf5a), #55246 (dae4077), #57527 (21ed6e4), #54747 (f232362): GUI plugins, desktop app or ctx.ui; our server plugins use none of it.
  • TUI and OpenTUI: #60913 (8db3d85), #60385 (13e8186), #59295 (ab4d1f3), #58380 (c9c1dc0), #55339 (c7ddff7), #55300 (def5d94), #55083 (65f8907), #53904 (da40b8f), #53805 (fcad131), #57007 (cc4faf4) and its revert #59439 (cd15a6a), #55172 (d0a2ce3), #58765 (de284dc), #58562 (4cba1b7): TUI only.
  • "refactor(ai): flatten generation knobs on requests and defaults (#60971)" (9a3f03e), "refactor(ai): one tool() for both clients (#60407)" (7a82f3a), "refactor(ai): make Promise the root entry and move Effect to @opencode/ai/effect (#58847)" (dad29a8): @opencode/ai and sdk tests; we import nothing from @opencode/ai.
  • "feat(core): add Claude Agent provider (#58782)" (f29e281), "feat(core): add image_generate tool (#59939)" (89f3ac1), "feat(protocol): define experimental image and decision generation endpoints (#59190)" (2a0639a): additive; we use none of it.
  • "feat(core): add /goal with a client-side done check (#59437)" (8de0323): adds an experimental.idle hook; we register none.
  • "feat(plugin): filter event subscriptions by type (#58864)" (1434464): optional filter on plugin event.subscribe; the harness subscribes through the SDK client.
  • "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.
  • "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): makes the comment at examples/next/harnesses/opencode/src/workspace.ts:143 accurate; no change needed.
  • "feat(sdk): seed host plugins before recovery and harden workerd defaults (#54219)" (55dde88): plugins now register before suspended sessions resume; none of our code works around the old order.
  • "fix(server): stop form polling from booting idle locations (#59083)" (c8cf3a5), "fix(app,server): stop subagent form polling from stalling sends (#57684)" (946c331): the instances option, which we don't use.
  • "fix(core): route file overrides through Workspace.connect (#54089)" (c50e39b), "fix(cli): give plugins the host's Effect (#53422)" (c28e9ec), "chore: upgrade Effect to 4.0.1 (#54198)" (41b03de): Effect entry points and the CLI loader; we pass plugin objects in-process and import no effect.
  • "fix(sdk): release completed embedded request signals (#53613)" (9ee97d8), "refactor: remove redundant casts and duplicate helpers across sdk, plugin, codemode, and schema (#57996)" (7a62a46): internal; typecheck passes.
  • "chore: remove unused dependencies from V2 packages (#53482)" (50ae4bd): drops zod and @standard-schema/spec from @opencode/plugin; we get neither through it.
  • Tooling and metadata: #59718 (1dab9ae), #59422 (fa5b4bd), #59046 (6996bbc), #58253 (84578e1), #56300 (23359e9), #55866 (17229d2).
  • Merges between dev and beta (be315b1, 4b83402, fd0efe3, bcd713e, 316a688, 15d4afd, 3a58a0c): bring in versions, metadata and additive plugin API.

Decisions

  • Answer the sdk hook instead of finding another bundled carrier. fix(agents): upgrade opencode to 2.2.1 #2776 carries the provider in gitlab-ai-provider and is on hold because that depends on OpenCode internals. Since 2.2.3 a plugin's sdk hook runs before the npm fallback, so the provider names aisdk:agents/models/opencode, a package that doesn't exist, and our hook supplies the SDK. The model still comes from the existing language hook.
  • Peer floor ^2.2.3, pins 2.2.7. The 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. Nothing needs 2.2.4 to 2.2.7, so the floor stays at 2.2.3. Dev and example pins are exact at 2.2.7, the version tested here.
  • Move off sessions.wait and sessions.log now. They still work on 2.2.7 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' module transfer limit.

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 in a new blob table (migration 20261025123711_blob), and 2.2.4 moves background job markers from kv into a new job table (20261030054400_job). Older releases can't read either; 2.2.7 adds no further migrations. 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.7 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.7.
  • 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, the removed Vercel settings and the updated CARRIER_PACKAGE comment above.
  • .changeset/opencode-2-2-7.md: agents patch, stating the new floor, the reason, and that the door is one-way.
  • pnpm-lock.yaml: regenerated by pnpm install. Both importers resolve only @opencode/*@2.2.7, with no 2.0.24 left, plus the transitive moves that come with it (effect 4.0.0-rc.112 → 4.1.0, @opentui/core 0.5.14 → 0.8.1, new @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.7 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), and the example's vite build passes. pnpm install raised no minimumReleaseAge block (@opencode/* and @opentui/* are excluded).

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 to 2.2.3 or later; otherwise agents/models/opencode fails to initialize its model (on 2.2.1 and 2.2.2 it already fails today). 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, and 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.7, 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_8e4ed46db651073a89730dfe01d0c0ef8e61f60edf2de3b83d05a9f0b44f93ef:2eea5a1351af9fb843f007a7f38209556e3732d9d5119f61197502b611828817
@github-actions github-actions Bot added the dependencies Pull requests that update a dependency file label Nov 10, 2026
@changeset-bot

changeset-bot Bot commented Nov 10, 2026

Copy link
Copy Markdown

🦋 Changeset detected

Latest commit: 9b40079

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 #2884

@github-actions github-actions Bot closed this Nov 13, 2026
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