Skip to content

fix(agents): support Pi 1.5.2 - #2862

Merged
ben-reitz merged 2 commits into
mainfrom
gardener/upstream/pi-1.5.2
Nov 16, 2026
Merged

ben-reitz merged 2 commits into
mainfrom
gardener/upstream/pi-1.5.2

Conversation

@github-actions

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

Copy link
Copy Markdown
Contributor

Summary

Moves agents/models/pi-ai, agents/harness/pi and the pi tool adapters from Pi 1.5.0 to Pi 1.5.2.

Package From To
@earendil-works/pi-ai, pi-durable, chord, pi-schema, pi-codemode (lockfile; dev and peer ranges stay ~1.5.0) 1.5.0 1.5.2
@earendil-works/pi-tui (dev, exact) 1.5.0 1.5.2
@earendil-works/pi-telemetry, pi-agent-core (examples, experimental; lockfile) 1.5.0 1.5.2

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.0 peer 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

  • high · breaking (1.5.1): "Added compat.requiresNonNullAssistantContent for OpenAI-compatible endpoints…" and "openai-completions no longer sends \"tools\": []… set compat.requiresToolsWithToolHistory: true" (release). Both fields are now required on the resolved openai-completions compat type, so STRICT_OPENAI_COMPAT (packages/agents/src/models/pi-ai/wires/chat-completions.ts:58) no longer compiles. Both are set to false, pi-ai's own default, so the requests we send don't change:
       requiresAssistantAfterToolResult: false,
    +  requiresNonNullAssistantContent: false,
       requiresReasoningContentOnAssistantMessages: false,
       requiresThinkingAsText: false,
       requiresToolResultName: false,
    +  requiresToolsWithToolHistory: false,
  • medium · breaking + docs (1.5.1): "Anthropic requests with a sessionId (and cacheRetention not \"none\") now use message threads… pi sends only the new messages" (release, #11545). pi-ai turns threads on when the model's baseUrl contains api.anthropic.com. It leaves them off for gateways, because "Gateways that drop unknown request fields would silently turn a continue into a request without the earlier conversation". Our Anthropic wire (packages/agents/src/models/pi-ai/wires/anthropic.ts) passes a model from pi-ai's anthropic registry through AI Gateway unchanged. pi-ai sees api.anthropic.com and adds thread. On 1.5.2 with the old code, the new test fails with expected { 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:237 now explains this and names the two ways to opt in.
  • low · new feature (1.5.1): StreamOptions.disableContinuation (used above), prompt cache warming helpers, the pi-ai/lazy-oauth and pi-ai/lazy-bedrock-provider subpaths, Provider.refreshModelsAuth, compat.promptCacheKeyMode, new models; pi-durable's Tx.submission(id), per-conversation configure({ compaction }) and read-only JSONL storage; pi-schema's unsafe(), recursive(), Validator.validate(), equal(), bigint(); pi-codemode's resolveSchemaRef(); pi-telemetry's telemetryNow(); pi-agent-core's disableContinuation in streamProxy(). Not adopted: nothing requires them, and users can reach them through harness.pi() or the packages directly. A possible follow-up is exposing per-conversation compaction on PiSession.
No effect on us (36)

1.5.2 (I read git diff v1.5.1 v1.5.2 for every pi package we use):

  • "Fork sessions whose folder is gone" and "interactive mode now offers Continue, Fork, or Cancel" (#11975): coding-agent only; we don't depend on pi-coding-agent.
  • "Fixed /import of a session whose working directory no longer exists leaving a copy…" (#11975): coding-agent only.
  • "Fixed Anthropic OAuth requests reporting an outdated Claude Code version" (a05e3a07): it changes the claudeCodeVersion constant used by pi-ai's OAuth stealth mode. We don't use OAuth. Apart from the version string, this is the only packages/ai/src change in 1.5.2.
  • chord "documents and table rows can belong to a host" (8a5da3ce, not in the notes). It adds Chord store schema 3, an 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's storage/store uses. We open pi-durable/storage/sqlite/cloudflare (packages/agents/src/harness/pi/session-store.ts:2). That only uses chord/sqlite, which is unchanged, and its own schema.ts/migrations.ts are byte-identical from 1.5.0 to 1.5.2.
  • chord "workers without --enable-source-maps…" (602b8d1c, not in the notes): Node worker runtime. We import only chord/context and chord/delta, which are unchanged.
  • pi-durable, pi-schema, pi-codemode, pi-telemetry, pi-tui, pi-agent-core in 1.5.2: version bumps only, plus pi-durable design docs (docs/suspendable/). No src changes.

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):

  • chord "Chord v2 is the package's root… Chord v1… removed", plus startWorker, createWorkers, host.reload: we import only chord/context and chord/delta, which are unchanged.
  • chord's other additions and fixes (sync layer, HTTP/workers/plugins/app kit, live queries, telemetry, worker and WebSocket fixes, terminal sandbox): Chord v2 runtime surfaces we don't import.
  • pi-durable "SqliteStorage.commit() costs a few SQL statements per call…": same rows written, no schema change; harness-pi passes.
  • pi-durable "Fixed a task staying waiting, or completing…" (#11892): scheduler fix inside pi; harness tests pass.
  • pi-durable tool_search local $ref and code mode URI malformed fixes (#11803): pi-internal.
  • pi-schema "A number or integer no longer accepts NaN, Infinity…": JSON tool arguments can't carry these.
  • pi-schema "A required property set to undefined is valid when its schema takes undefined": none of our tool schemas has such a property.
  • pi-schema relative $id fix (#11697), THIRD_PARTY_NOTICES/ rename, faster checks: internal.
  • pi-codemode URIError and console.* NaN fixes (#11901): internal to the runtime behind pi-codemode/cloudflare.
  • pi-telemetry "renderTrace escapes control characters": output formatting only.
  • pi-tui HTML comments, Kitty images, paste/cursor markers, Alacritty hyperlinks: channels passes 144/144.
  • pi-ai "openai-completions no longer sends \"tools\": []" (the behaviour, apart from the type change above): our wire builds its own body and sends tools only when there are any (chat-completions.ts:549).
  • pi-ai "Fixed OpenAI Responses requests sending session_id…" (#11639): our Responses wire builds its own request.
  • pi-ai "Fixed Claude Sonnet 5 requests sending an unsupported temperature parameter" (#7961): this is catalog compat that pi's Anthropic implementation reads, so we get the fix with no change. Otherwise the catalogs we import are unchanged.
  • pi-ai Anthropic/Bedrock strict: "prefer" fix (#11626) and root $defs fix (#9557): pi does this request shaping and our wire runs it unchanged.
  • pi-ai "Fixed dropped provider streams… not triggering automatic retries" (#11879): pi's retry classifier; our retry tests pass.
  • pi-ai Type.BigInt()/Type.Undefined() arguments and $ref with relative root $id: our schemas use neither.
  • pi-ai lazy provider loading, lazy OAuth/Bedrock import fixes: not used.
  • pi-ai "Fixed provider connection errors hiding their underlying cause": our transport reports its own gateway errors.
  • pi-ai default-model changes (Claude Opus 5.5, Kimi K2.7 Code…): we never use pi's default models.
  • pi-ai Azure, OpenRouter, OpenCode Go, OpenAI Codex, GLM fixes: providers we don't wrap.
  • "Custom GrepOperations.readFile callbacks are no longer called for context lines": a coding-agent tool.
  • pi-agent-core: only the streamProxy() option above; experimental/pi-recovery passes.
  • Coding agent CLI and extensions (pi auth, pi update, cache warming, Mermaid, /login, highlighting): not a dependency.
  • Coding-agent tool, session/UI, MCP/OAuth/runtime and installer fixes: not a dependency.
  • Headlines "GitHub Copilot classifiers" and "Package update summaries": coding-agent features.

Decisions

  • Ranges stay ~1.5.0; only the exact pi-tui pin 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 ignores disableContinuation as an unknown field, and the two compat fields live in a private constant, so agents still works there.
  • Threads are turned off with pi-ai's 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 explicit disableContinuation from the caller and a model's compat.supportsMessageThreads: true both still take precedence.
  • The two new compat fields are false. That is pi-ai's default, and it matches the strict OpenAI profile the constant describes.
  • Two tests added in packages/agents/src/tests/models/pi-ai/anthropic.test.ts: a sessionId request through the gateway carries no thread, and compat.supportsMessageThreads: true still gets thread: { type: "create" }.
  • Changeset patch. The published agents source changes, and no peer range moves.
  • fix(agents): support Pi 1.5.1 #2855 is superseded. It is the Gardener PR for 1.5.1, and only 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

  • Should Anthropic message threads run through AI Gateway by default? (Carried over from fix(agents): support Pi 1.5.1 #2855.) Options: keep them off unless a model or caller opts in (this PR), or let pi-ai's api.anthropic.com rule 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 forwards thread. If a gateway dropped it, the model would get only the new messages.

Affected open PRs

Other changes

  • packages/agents/package.json: dev @earendil-works/pi-tui goes from 1.5.0 to 1.5.2.
  • pnpm-lock.yaml: updated with pnpm update -r --no-save "@earendil-works/*". Every @earendil-works/* package now resolves only 1.5.2. Chord's entries gain a react@19.2.8 peer suffix, from chord's new optional react peer. No other package changed. pnpm install --frozen-lockfile is 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: agents patch.

Evidence

  • Before (1.5.0, unchanged code): harness-pi 89/89, workers src/tests/models/pi-ai src/tests/web src/tests/browser 637/637, channels 144/144.
  • Before (1.5.2, old anthropic.ts): the gateway-threads test fails with expected { type: 'create' } to be undefined.
  • After (1.5.2): harness-pi 89/89, workers src/tests/models/pi-ai src/tests/web src/tests/browser 639/639 (2 new), channels 144/144, examples/next/harnesses/pi 17/17, experimental/pi-recovery 32/32. packages/agents builds. pnpm run typecheck passes for all 133 projects. sherif, oxfmt --check ., oxlint . and check: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/sqlite has 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, which agents doesn't open. Users on ~1.5.0 get no new peer warning from agents. pnpm may warn that chord's optional react peer doesn't match their React, which only matters for chord's React bindings. Users who pass a pi-ai anthropic model with a sessionId keep sending whole conversations, as on 1.5.0.


Opened by Gardener's pi-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 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
@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: d83eac7

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.

Note

Newer findings are available below. Devin Review posted a newer report on this PR, in addition to the findings presented here.

Devin Review found 1 potential issue.

Devin Review

Comment thread docs/agents/models-pi-ai.md Resolved
@pkg-pr-new

pkg-pr-new Bot commented Nov 16, 2026 •

Copy link
Copy Markdown

Open in StackBlitz

agents

npm i https://pkg.pr.new/agents@2862

@cloudflare/ai-chat

npm i https://pkg.pr.new/@cloudflare/ai-chat@2862

@cloudflare/codemode

npm i https://pkg.pr.new/@cloudflare/codemode@2862

hono-agents

npm i https://pkg.pr.new/hono-agents@2862

@cloudflare/shell

npm i https://pkg.pr.new/@cloudflare/shell@2862

@cloudflare/think

npm i https://pkg.pr.new/@cloudflare/think@2862

@cloudflare/voice

npm i https://pkg.pr.new/@cloudflare/voice@2862

@cloudflare/worker-bundler

npm i https://pkg.pr.new/@cloudflare/worker-bundler@2862

commit: d83eac7

@agent-think

agent-think Bot commented Nov 16, 2026 •

Copy link
Copy Markdown
Contributor

🔴 agents import sizes: 1 entry point over threshold

Entry point Exports Largest gzip change Size now
🔴 agents/harness/pi 2 resized up to +1.5 KiB (+17.98%) 9.6 KiB
🟡 agents/mcp 15 resized up to +1.7 KiB (+0.47%) 363.9 KiB
🟡 agents/chat-sdk 3 resized up to +1.6 KiB (+0.59%) 276.8 KiB
🟡 agents 5 resized up to +1.6 KiB (+0.58%) 274.4 KiB
🟡 agents/models/pi-ai 1 resized +1.4 KiB (+0.85%) 164.5 KiB
🟡 agents/lifecycle 1 resized +312 B (+3.55%) 8.9 KiB
🟡 agents/queue 1 resized +257 B (+7.98%) 3.4 KiB
Changed exports (28)
Import Gzip change Size now
🔴 agents/harness/pi#openPiSessionStore +1.5 KiB (+17.98%) 9.6 KiB
🔴 agents/harness/pi#PiHarness +1.4 KiB (+11.22%) 13.6 KiB
🟡 agents/mcp#normalizeServerId +1.7 KiB (+0.47%) 363.9 KiB
🟡 agents/mcp#RPCClientTransport +1.7 KiB (+0.47%) 363.9 KiB
🟡 agents/mcp#RPC_DO_PREFIX +1.7 KiB (+0.46%) 363.9 KiB
🟡 agents/mcp#ElicitRequestSchema +1.7 KiB (+0.46%) 363.9 KiB
🟡 agents/mcp#DurableObjectEventStore +1.7 KiB (+0.46%) 363.8 KiB
🟡 agents/mcp#RPCServerTransport +1.7 KiB (+0.46%) 363.9 KiB
🟡 agents/mcp#getMcpAuthContext +1.7 KiB (+0.46%) 363.9 KiB
🟡 agents/mcp#MCP_SERVER_ID_MAX_LENGTH +1.6 KiB (+0.46%) 363.8 KiB
🟡 agents/mcp#McpAgent +1.6 KiB (+0.46%) 363.8 KiB
🟡 agents/mcp#SSEEdgeClientTransport +1.6 KiB (+0.45%) 363.9 KiB
🟡 agents/mcp#StreamableHTTPEdgeClientTransport +1.6 KiB (+0.45%) 363.9 KiB
🟡 agents/chat-sdk#createChatSdkState +1.6 KiB (+0.59%) 276.8 KiB
🟡 agents/chat-sdk#ChatSdkStateAdapter +1.6 KiB (+0.59%) 276.8 KiB
🟡 agents/mcp#WorkerTransport +1.6 KiB (+0.43%) 367.6 KiB
🟡 agents/chat-sdk#ChatSdkStateAgent +1.6 KiB (+0.58%) 275.9 KiB
🟡 agents#routeAgentEmail +1.6 KiB (+0.58%) 274.4 KiB
🟡 agents#DEFAULT_AGENT_STATIC_OPTIONS +1.6 KiB (+0.57%) 274.2 KiB
🟡 agents#getCurrentAgent +1.6 KiB (+0.57%) 274.1 KiB
🟡 agents/mcp#createLegacyMcpHandler +1.6 KiB (+0.39%) 398 KiB
🟡 agents#StreamingResponse +1.6 KiB (+0.57%) 274.1 KiB
🟡 agents/mcp#createMcpHandler +1.6 KiB (+0.38%) 411 KiB
🟡 agents#Agent +1.5 KiB (+0.57%) 274.1 KiB
🟡 agents/mcp#experimental_createMcpHandler +1.5 KiB (+0.38%) 398.2 KiB
🟡 agents/models/pi-ai#createAI +1.4 KiB (+0.85%) 164.5 KiB
🟡 agents/lifecycle#Lifecycle +312 B (+3.55%) 8.9 KiB
🟡 agents/queue#Queue +257 B (+7.98%) 3.4 KiB
How this works

Each 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 cff5dd1c → d83eac73 · workflow run · reported by agent-think[bot]

@ben-reitz ben-reitz 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.

@ask-gardener

"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
@github-actions

Copy link
Copy Markdown
Contributor Author

This round applies the review's decision on message threads in d83eac7. One review thread was declined.

  • Review body (threads through AI Gateway): fixed. The Anthropic wire no longer overrides disableContinuation, so pi-ai's api.anthropic.com default applies through the gateway. Tests in anthropic.test.ts cover this: a sessionId request now carries thread: { type: "create" }, and disableContinuation: true or compat.supportsMessageThreads: false sends no thread. The docs paragraph and the changeset are updated to match.
  • cloudflare-docs sync: declined. That port is a manual step in another repository. The thread stays open.

Tests: vitest --project workers src/tests/models/pi-ai passed 101/101. pnpm run build passed, and pnpm run check passed (133 projects typecheck).

@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 found 2 potential issues.

Devin Review

Comment thread docs/agents/models-pi-ai.md Resolved
Comment thread docs/agents/models-pi-ai.md Resolved
@github-actions

Copy link
Copy Markdown
Contributor Author

This round answered two new review threads. It changes no code and adds no commit.

  • Gateway thread forwarding unverified: declined. A maintainer confirmed in review 5919701532 that AI Gateway passes thread through. The code and docs follow that decision. The PR description's "threads stay off" text predates it.
  • cloudflare-docs sync: declined. Porting to cloudflare-docs is a manual step in that repository, and the earlier open thread already tracks it.

Review body: it only gives the finding count, so there was nothing more to address.

Tests: none run, because no code changed.

@ben-reitz
ben-reitz merged commit ec57858 into main Nov 16, 2026
41 of 43 checks passed
@ben-reitz
ben-reitz deleted the gardener/upstream/pi-1.5.2 branch November 16, 2026 14:34
@github-actions github-actions Bot mentioned this pull request Nov 16, 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.

1 participant