Repository navigation
fix(agents): support Pi 1.5.2 - #2862
Conversation
Move the workspace's pi packages from 1.5.0 to 1.5.2 (pi-tui dev pin and lockfile; ranges stay ~1.5.0). Add pi-ai 1.5.1's two required openai-completions compat fields to STRICT_OPENAI_COMPAT, and keep Anthropic message threads off for models sent through AI Gateway unless the model's compat or the caller opts in. Gardener-Operation: op_be057c3d45bb762e0e796dc90f26c17d2190319dccec798d44ef86abb93b051b:743b8b2aca91503b586d4d4b84a8eaf3b6b4e2ca33da6e239c0a939710b9258a
🦋 Changeset detectedLatest commit: d83eac7 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 |
agents
@cloudflare/ai-chat
@cloudflare/codemode
hono-agents
@cloudflare/shell
@cloudflare/think
@cloudflare/voice
@cloudflare/worker-bundler
commit: |
🔴 agents import sizes: 1 entry point over threshold
Changed exports (28)
How this worksEach runtime export is bundled on its own, minified, and gzipped. Changes smaller than 100 B, or smaller than 1% and 1 KiB, are ignored. Growth over 10% or 5 KiB is marked 🔴. This report is informational and does not fail CI. The workflow artifact contains every measurement. Compared |
ben-reitz
left a comment
There was a problem hiding this comment.
"Should Anthropic message threads run through AI Gateway by default?"
We can leave hte default pi behaviour as it is - I've confirmed they are passed correctly through AI Gateway
- Drop the disableContinuation override in the Anthropic wire, so pi-ai's default applies. - Tests: threads by default, none with disableContinuation or compat.supportsMessageThreads: false. - Update the docs paragraph and the changeset. Gardener-Operation: op_fad52824c2898b80478cb3cbc47932768cc0334322d59d2909378c629f2a5456:9b8b429ece7924ce91c6f51f74f8bda76f10f0b73064fa79f92337f0887c8adc
|
This round applies the review's decision on message threads in d83eac7. One review thread was declined.
Tests: |
|
This round answered two new review threads. It changes no code and adds no commit.
Review body: it only gives the finding count, so there was nothing more to address. Tests: none run, because no code changed. |
Summary
Moves
agents/models/pi-ai,agents/harness/piand the pi tool adapters from Pi 1.5.0 to Pi 1.5.2.@earendil-works/pi-ai,pi-durable,chord,pi-schema,pi-codemode(lockfile; dev and peer ranges stay~1.5.0)@earendil-works/pi-tui(dev, exact)@earendil-works/pi-telemetry,pi-agent-core(examples, experimental; lockfile)Two releases came out since 1.5.0: Pi 1.5.1 (2026-11-09) and Pi 1.5.2 (2026-11-10). Both are patches, so users on our
~1.5.0peer range can already install them. 1.5.1 needs two fixes from us: a typecheck break, and a change to what our gateway wire sends to Anthropic. 1.5.2 needs none. This PR replaces #2855 (the Gardener PR for 1.5.1), carries its two fixes over unchanged, and adds 1.5.2.What changed upstream that affects us
compat.requiresNonNullAssistantContentfor OpenAI-compatible endpoints…" and "openai-completionsno longer sends\"tools\": []… setcompat.requiresToolsWithToolHistory: true" (release). Both fields are now required on the resolved openai-completions compat type, soSTRICT_OPENAI_COMPAT(packages/agents/src/models/pi-ai/wires/chat-completions.ts:58) no longer compiles. Both are set tofalse, pi-ai's own default, so the requests we send don't change:sessionId(andcacheRetentionnot\"none\") now use message threads… pi sends only the new messages" (release, #11545). pi-ai turns threads on when the model'sbaseUrlcontainsapi.anthropic.com. It leaves them off for gateways, because "Gateways that drop unknown request fields would silently turn acontinueinto a request without the earlier conversation". Our Anthropic wire (packages/agents/src/models/pi-ai/wires/anthropic.ts) passes a model from pi-ai'santhropicregistry through AI Gateway unchanged. pi-ai seesapi.anthropic.comand addsthread. On 1.5.2 with the old code, the new test fails withexpected { type: 'create' } to be undefined. Now threads stay off through the gateway unless the model's compat or the caller asks for them (anthropic.ts:100,anthropic.ts:169):...options, ...(request.simple ? thinkingOptions(model, options) : {}), + disableContinuation: + options.disableContinuation ?? !messageThreadsRequested(model), client,docs/agents/models-pi-ai.md:237now explains this and names the two ways to opt in.StreamOptions.disableContinuation(used above), prompt cache warming helpers, thepi-ai/lazy-oauthandpi-ai/lazy-bedrock-providersubpaths,Provider.refreshModelsAuth,compat.promptCacheKeyMode, new models; pi-durable'sTx.submission(id), per-conversationconfigure({ compaction })and read-only JSONL storage; pi-schema'sunsafe(),recursive(),Validator.validate(),equal(),bigint(); pi-codemode'sresolveSchemaRef(); pi-telemetry'stelemetryNow(); pi-agent-core'sdisableContinuationinstreamProxy(). Not adopted: nothing requires them, and users can reach them throughharness.pi()or the packages directly. A possible follow-up is exposing per-conversation compaction onPiSession.No effect on us (36)
1.5.2 (I read
git diff v1.5.1 v1.5.2for every pi package we use):Continue,Fork, orCancel" (#11975): coding-agent only; we don't depend onpi-coding-agent./importof a session whose working directory no longer exists leaving a copy…" (#11975): coding-agent only.claudeCodeVersionconstant used by pi-ai's OAuth stealth mode. We don't use OAuth. Apart from the version string, this is the onlypackages/ai/srcchange in 1.5.2.ALTER TABLE chord_documents ADD COLUMN host, and older chord throws "schema version 3 is newer than supported version 2". That schema belongs to Chord's own store (chord/dist/store), which pi-durable'sstorage/storeuses. We openpi-durable/storage/sqlite/cloudflare(packages/agents/src/harness/pi/session-store.ts:2). That only useschord/sqlite, which is unchanged, and its ownschema.ts/migrations.tsare byte-identical from 1.5.0 to 1.5.2.chord/contextandchord/delta, which are unchanged.docs/suspendable/). Nosrcchanges.1.5.1 (carried over from #2855's item-by-item review; its two affecting items were re-checked here by typecheck and the new test):
startWorker,createWorkers,host.reload: we import onlychord/contextandchord/delta, which are unchanged.SqliteStorage.commit()costs a few SQL statements per call…": same rows written, no schema change;harness-pipasses.waiting, orcompleting…" (#11892): scheduler fix inside pi; harness tests pass.tool_searchlocal$refand code modeURI malformedfixes (#11803): pi-internal.numberorintegerno longer acceptsNaN,Infinity…": JSON tool arguments can't carry these.undefinedis valid when its schema takesundefined": none of our tool schemas has such a property.$idfix (#11697),THIRD_PARTY_NOTICES/rename, faster checks: internal.URIErrorandconsole.*NaNfixes (#11901): internal to the runtime behindpi-codemode/cloudflare.renderTraceescapes control characters": output formatting only.channelspasses 144/144.openai-completionsno longer sends\"tools\": []" (the behaviour, apart from the type change above): our wire builds its own body and sendstoolsonly when there are any (chat-completions.ts:549).session_id…" (#11639): our Responses wire builds its own request.strict: "prefer"fix (#11626) and root$defsfix (#9557): pi does this request shaping and our wire runs it unchanged.Type.BigInt()/Type.Undefined()arguments and$refwith relative root$id: our schemas use neither.GrepOperations.readFilecallbacks are no longer called for context lines": a coding-agent tool.streamProxy()option above;experimental/pi-recoverypasses.pi auth,pi update, cache warming, Mermaid,/login, highlighting): not a dependency.Decisions
~1.5.0; only the exactpi-tuipin and the lockfile move. Under the pin policy, peer and dev ranges are~X.Y.0, and that range already covers 1.5.2. The peer floor stays where it is. On 1.5.0, pi ignoresdisableContinuationas an unknown field, and the two compat fields live in a private constant, soagentsstill works there.disableContinuation, not by rewriting the model's compat. The wire's rule (anthropic.ts:11) is that the model object reaches pi-ai unchanged. An explicitdisableContinuationfrom the caller and a model'scompat.supportsMessageThreads: trueboth still take precedence.false. That is pi-ai's default, and it matches the strict OpenAI profile the constant describes.packages/agents/src/tests/models/pi-ai/anthropic.test.ts: asessionIdrequest through the gateway carries nothread, andcompat.supportsMessageThreads: truestill getsthread: { type: "create" }.patch. The publishedagentssource changes, and no peer range moves.github-actions[bot]has committed to it. Its changes are included here unchanged, apart from the version in the pin, the changeset name and the changeset text.Needs a maintainer
api.anthropic.comrule apply through the gateway. Recommendation: keep them off. pi-ai's own gateway catalog doesn't enable them, and nobody has checked that AI Gateway forwardsthread. If a gateway dropped it, the model would get only the new messages.Affected open PRs
pnpm-lock.yaml(and fix(agents): upgrade opencode to 2.2.7 #2857 and fix(think): drain recovered messenger queues on chat 4.39+ and bump chat to 4.41.1 #2416 inpackages/agents/package.json, on different lines). Whichever merges second regenerates the lockfile withpnpm install..changeset/pi-1-5-2.md.harness/piandexamples/next/harnesses/pi, which this PR doesn't change, and 1.5.2 changes no pi API.experimental/pi-recoverytypechecks and its tests pass on 1.5.2.Other changes
packages/agents/package.json: dev@earendil-works/pi-tuigoes from1.5.0to1.5.2.pnpm-lock.yaml: updated withpnpm update -r --no-save "@earendil-works/*". Every@earendil-works/*package now resolves only 1.5.2. Chord's entries gain areact@19.2.8peer suffix, from chord's new optionalreactpeer. No other package changed.pnpm install --frozen-lockfileis clean.docs/agents/models-pi-ai.md:237: the message-threads paragraph described above.packages/agents/src/models/pi-ai/wires/anthropic.ts,wires/chat-completions.ts,src/tests/models/pi-ai/anthropic.test.ts: as described above..changeset/pi-1-5-2.md:agentspatch.Evidence
src/tests/models/pi-ai src/tests/web src/tests/browser637/637, channels 144/144.anthropic.ts): the gateway-threads test fails withexpected { type: 'create' } to be undefined.src/tests/models/pi-ai src/tests/web src/tests/browser639/639 (2 new), channels 144/144,examples/next/harnesses/pi17/17,experimental/pi-recovery32/32.packages/agentsbuilds.pnpm run typecheckpasses for all 133 projects.sherif,oxfmt --check .,oxlint .andcheck:exports(all 9 packages) pass.Merge Danger
Door: two-way
Blast Radius: Pi users
The storage we use doesn't change format.
pi-durable/storage/sqlitehas the same schema and migrations from 1.5.0 to 1.5.2, so rolling back is safe. Chord 1.5.2's store schema 3 applies only to Chord's own store, whichagentsdoesn't open. Users on~1.5.0get no new peer warning fromagents. pnpm may warn that chord's optionalreactpeer doesn't match their React, which only matters for chord's React bindings. Users who pass a pi-aianthropicmodel with asessionIdkeep sending whole conversations, as on 1.5.0.Opened by Gardener's
pi-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.