Repository navigation
fix(agents): upgrade opencode to 2.2.1 - #2767
Merged
Merged
Conversation
Move the @opencode/sdk and @opencode/plugin dev and example pins from 2.0.24 to 2.2.1 and regenerate pnpm-lock.yaml. @opencode/core 2.2.1 no longer bundles @ai-sdk/vercel, the package agents/models/opencode named so OpenCode loads it in-process; every turn failed with provider.no-route. The provider now names gitlab-ai-provider, which OpenCode 2.0.24 to 2.2.1 all load in-process. Peer range unchanged. The Effect 4.0.1 Scalar stub path moves in the test config and example, and the test config swaps OpenCode's 8 MB models.dev catalog for an empty one so the test runtime can load it. Supersedes #2725. Gardener-Operation: op_01cd0a42d8cacef705791a2563f399f6f2ecfd9e224ab4bd67b0ca9942cc803e:90fbc03809c64d97ed870f4c44c25e8147b472a47fb479caa9877d85e9ebfa36
🦋 Changeset detectedLatest commit: af146bf 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 |
…angeset Gardener-Operation: op_1437d3ebe8d4d6923fc425988e7a04f125ee356ea2fef9384556708b30267bee:0f48d6f725a39c5bec490ab674abd418b4e3df574a103736d9e1c5b30863386a
Contributor
Author
|
Review round 1: fixed the one open thread in af146bf.
Review body: it only reports that one finding, so it needs no separate answer. Checks: |
agents
@cloudflare/ai-chat
@cloudflare/codemode
hono-agents
@cloudflare/shell
@cloudflare/think
@cloudflare/voice
@cloudflare/worker-bundler
commit: |
This was referenced Oct 29, 2026
Member
Merged
mattzcarey
added a commit
that referenced
this pull request
Oct 29, 2026
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/opencode,agents/models/opencodeand the OpenCode example from opencode 2.0.24 to 2.2.1, and fixesagents/models/opencode, which fails every turn on 2.2.1.@opencode/sdk(dev pin, example)@opencode/plugin(dev pin, example)^2.0.24^2.0.24(unchanged)Since our pin, opencode has shipped 2.0.25–2.0.32, 2.1.0–2.1.4, 2.2.0 and 2.2.1. Our caret peer range already lets users install all of them. On 2.2.1,
agents/models/opencodeis broken for those users today: every run fails withprovider.no-route(details below). This PR fixes that and moves our pins. It supersedes #2725 (2.2.0), which onlygithub-actions[bot]committed to.What changed upstream that affects us
@opencode/corecommit, not one inpackages/sdkorpackages/plugin. The test failure led me to it.@opencode/core2.2.1, which@opencode/sdk2.2.1 depends on, drops@ai-sdk/verceland itsVercelPluginsdkhook.agents/models/opencodenamesaisdk:@ai-sdk/vercelas its provider package so that OpenCode'ssdkstep loads it in-process, and then ourlanguagehook swaps in our model (packages/agents/src/models/opencode/index.ts:50-62). Now no built-in hook claims that package, soDynamicProviderPluginpasses it to its npm installer. An external plugin'ssdkhook only runs after that. I checked: adding our ownsdkhook did not help. The installer can't run in workerd. Every run ended withsession.execution.failed,provider.no-route: "Cannot initialize cloudflare/@cf/moonshotai/kimi-k2.7-code: Cannot destructure property 'LRUCache' of 'require(...)' as it is undefined." The provider now namesgitlab-ai-provider. In every tag from v2.0.24 to v2.2.1,GitLabPluginis registered and itssdkhook checks onlyevt.package !== "gitlab-ai-provider", then imports the bundled package. Itslanguagehook and provider transforms only act on thegitlabprovider id, so ours still makes the model:effect/dist/http-api/internal/httpApiScalar.js. Our stubs matched the oldunstable/httpapipath (packages/agents/src/harness/opencode/tests/vitest.config.ts:16,examples/next/harnesses/opencode/vite.config.ts:16). Same change in both files, as in chore(deps): upgrade opencode to 2.2.0 #2725:packages/sdkorpackages/plugincommit.@opencode/core2.2.x inlines the models.dev catalog as one string literal (// src/models-dev/snapshot.txt/var snapshot_default = '…'). In 2.2.1 that isdist/chunks/credential-yap2aqf7.js, 8,220,567 bytes. With only the pins moved, workerd closed the module-runner socket ("WebSocket protocol error; statusCode = 1009; Message is too large") andharness-opencoderan 5/14. The test Workers setmodels: { fetch: false }and use only our Cloudflare provider (packages/agents/src/harness/opencode/tests/worker.ts:67-74), so the test config swaps in an empty catalog (vitest.config.ts:20-35). This is chore(deps): upgrade opencode to 2.2.0 #2725's plugin, unchanged:sessions.wait,sessions.logandsessions.instructionsmove toclient.experimental.session.*. The old paths stay as aliases, marked "@deprecated … Removed in the next minor". The harness callsopencode.sessions.wait(packages/agents/src/harness/opencode/harness.ts:536,:670) andopencode.sessions.log(harness.ts:1242), and the publicOpenCodeLogEventtype is derived fromOpenCode["sessions"]["log"](types.ts:44-45). All of these still work and typecheck on 2.2.1. Not adopted:client.experimental.session.*doesn't exist before 2.2.1, so using it would raise the peer floor to^2.2.1. See Needs a maintainer.SessionCompactionResult.providerStatetonative. Neithermodels/opencodenor the harness implements compaction, and thesession.compaction.*cases (events.ts:264-276) read onlyreasonanderror.message. The same commit changes the stored session schema in@opencode/schema(session-message.ts,session-event.ts) and adds asession-legacy.tsdecoder, so 2.1+ reads older sessions. I did not check field by field whether 2.0.x can read sessions 2.1+ writes. It only matters for rolling back a deployment (see Merge Danger).No effect on us (68)
imagekind to the plugin'sSessionIdleBackground. We don't use that hook, and the harness ignores event types it doesn't map (events.ts:299).experimental.idlesession hook and GUI registries. We don't use them.ctx.experimental.generate. Our plugins don't callgenerate.@opencode/plugin/gui*subpaths. We import only the package root, and we pass plugins as objects.typesfilter. The harness subscribes throughopencode.events.subscribeunfiltered, and the event-stream tests pass.livecheck in the SDK's instance map.Model.Info.default,Model.ID.makeandProvider.ID.make(models/opencode/index.ts:121-124) are unchanged.@opencode/sdk/workerdAPI.zodnor@standard-schema/specthrough the plugin.Decisions
Carrier package:
gitlab-ai-provider. I chose it over:sdkhook. It runs afterDynamicProviderPlugin's installer, and the test still failed.@ai-sdk/github-copilot. Itssdkhook also requiresproviderID === "github-copilot".@opencode/ai/providers/*path. That bypasses thelanguagehook the provider is built on.gitlab-ai-provideris a dependency of@opencode/corein every release in our peer range. Its hook is the same in all of them, so the fix needs no floor change. One side effect: OpenCode keys per-request provider options by package, and for this package it uses the provider id. So anything OpenCode puts there now lands inproviderOptions.cloudflare, which our models read, instead ofproviderOptions.vercel. Today that is nothing. Our models areModel.Info.defaultwithvariants: [], and OpenCode strips the only provider settings we set (baseURL,apiKey) from request options.Peer range stays
^2.0.24. The fix works on every release in the range. Raising the floor would push users onto 2.1+'s session format for no code reason.Changeset:
patch(.changeset/opencode-2-2-1-carrier.md). Published source inagents/models/opencodechanges, and the peer range doesn't.Keep
sessions.wait/sessions.log(deprecated in 2.2.1) instead ofexperimental.session.*, for the floor reason above.The empty-catalog stub is test-only, as in chore(deps): upgrade opencode to 2.2.0 #2725. The OpenCode example's
vite buildpasses without it.Supersede chore(deps): upgrade opencode to 2.2.0 #2725. It includes the Scalar and catalog fixes, but on 2.2.0. Moving it to 2.2.1 would also need the carrier fix.
Needs a maintainer
opencode 2.3 removes
sessions.wait/sessions.log, and^2.0.24admits 2.3. Options:<2.3.0now;experimental.session.*and raise the floor to^2.2.1;Recommendation: the second, in the run that upgrades to 2.3. It keeps 2.0.x users working until then, and the next run's review flags the removal.
Whether the example's
vite devhits the 8 MB module limit (carried over from chore(deps): upgrade opencode to 2.2.0 #2725). I couldn't run it: its remoteAIbinding needsCLOUDFLARE_API_TOKEN. Recommendation: runpnpm startinexamples/next/harnesses/opencodeonce. If it fails with "Message is too large", add theempty-models-dev-snapshotplugin there withapply: "serve".The carrier fix ran only on 2.2.1. I checked the
GitLabPluginregistration and thesdkhook guard in every tag from v2.0.24 to v2.2.1, but ran tests only on 2.2.1. Recommendation: none needed, unless you want a run on 2.0.24 before release.Affected open PRs
packages/agents/package.json(@tanstack/ailines only). No@opencode/*change; it merges cleanly or conflicts on context lines only.packages/agents/package.json(version) andpnpm-lock.yaml. Whichever merges second regenerates the lockfile.packages/agents/package.json(test(mcp): integration tests for MCP re-authorization against an msw server #2751, perf(agents): mark the package side-effect free so Workers drop unused modules #2737, feat(agents): portable harness extensions (agents/harness/extensions) #2511, feat(agents): agents/tools/testing toolbox + deployed pi harness OOM/CPU/wall-time e2e #2421, fix(think): drain recovered messenger queues on chat 4.39+ and bump chat to 4.41.1 #2416, feat(payments): wrap functions and MCP tools with x402 #2273, feat(agents): dynamic agents as a real Lifecycle capability #2250, feat(context): bound what a tool result contributes to a request #2203) don't change@opencode/*pins, the opencode harness ormodels/opencode.Other changes
packages/agents/package.json:55-56: dev pins@opencode/pluginand@opencode/sdk2.0.24→2.2.1.examples/next/harnesses/opencode/package.json:17-18: the same two pins..changeset/opencode-2-2-1-carrier.md: new,agents: patch, one line on the carrier change.pnpm-lock.yaml: regenerated withpnpm install. Every@opencode/*package resolves to 2.2.1, with no 2.0.24 left. The transitive changes come from opencode's tree:effect(and@effect/opentelemetry,platform-node*) 4.0.0-rc.112 → 4.0.1;@ai-sdk/provider-utils4.0.21/4.0.23 → 4.0.62 and@ai-sdk/provider3.0.19 (opencode 01abece);zod4.1.8 dropped for the existing 4.6.7;@opentui/core0.5.14 → 0.7.0;@opencode-ai/pty0.2.0 → 0.3.1;bun-pty0.4.9 → 0.4.11;gitlab-ai-provider6.19.0 → 6.23.1;@modelcontextprotocol/client/core2.0.0 → 2.3.1.ws@8.22.0,proper-lockfile,retry.@ai-sdk/vercel,@ai-sdk/cohere,@ai-sdk/perplexity,@ai-sdk/openai-compatible@2.0.37,msgpackr,msgpackr-extract,fast-check,pure-rand,mime@4.1.0,http-cache-semantics,undici@8.10.2,strip-ansi@7.1.2,node-gyp-build-optional-packages.Evidence
harness-opencode31/31, workerssrc/tests/models/opencode5/5.harness-opencode5/14 ("Message is too large").harness.test.ts, where operations endunanswered; the session log shows theprovider.no-routefailure quoted above.harness-opencode31/31, workerssrc/tests/models/opencode5/5.pnpm run buildpasses for 23 projects, including the OpenCode example'svite build.pnpm run checkpasses: sherif, exports (9 packages), oxfmt, oxlint (0 warnings), and typecheck of 134 projects.Merge Danger
Door: two-way for the published package. The carrier package is runtime provider config from the plugin's
provider.transform. Sessions store only{ providerID, id }, as thesession.createdevent in the log shows, so going back to the previousagentsrelease restores the old carrier with nothing persisted. The exception is deployingexamples/next/harnesses/opencodefrom this commit. That puts its Durable Objects on opencode 2.2, and per acdcdb8, sessions written under 2.1+ may not decode on 2.0.x. Treat that deployment as one-way.Blast Radius: OpenCode harness users: anyone using
agents/models/opencode, usually throughagents/harness/opencode.No one gets a new peer-dependency warning, because the peer range is unchanged. Users already on opencode 2.2.1 get working Cloudflare models once this ships. Users on 2.0.24–2.2.0 see no change in behaviour.
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.