Skip to content

fix(agents): support Pi 1.5.1 - #2855

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

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

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.1.

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.1
@earendil-works/pi-tui (dev, exact) 1.5.0 1.5.1
@earendil-works/pi-telemetry, pi-agent-core (examples, experimental; lockfile) 1.5.0 1.5.1

Pi 1.5.1 came out on 2026-11-09. It is the only release since 1.5.0. It is a patch, so users on our ~1.5.0 peer range already get it. Two things change for us. pi-ai's resolved openai-completions compat type has two new required fields, which breaks our typecheck. pi-ai also now threads Anthropic requests, which would change what our gateway wire sends. Both are fixed here.

What changed upstream that affects us

  • high · breaking: "Added compat.requiresNonNullAssistantContent for OpenAI-compatible endpoints…" and "openai-completions no longer sends \"tools\": []… set compat.requiresToolsWithToolHistory: true" (release). convertMessages' compat parameter now requires both fields, so STRICT_OPENAI_COMPAT (packages/agents/src/models/pi-ai/wires/chat-completions.ts:58) no longer compiles. 3 of the 9 packages/agents tsconfigs fail. Both are set to false, pi-ai's own default, which keeps the requests we send unchanged:
       requiresAssistantAfterToolResult: false,
    +  requiresNonNullAssistantContent: false,
       requiresReasoningContentOnAssistantMessages: false,
       requiresThinkingAsText: false,
       requiresToolResultName: false,
    +  requiresToolsWithToolHistory: false,
  • medium · breaking + docs: "Anthropic requests with a sessionId (and cacheRetention not \"none\") now use message threads… the server continues from the previous reply and pi sends only the new messages" (release, #11545). pi-ai enables threads when model.provider === "anthropic" && model.baseUrl.includes("api.anthropic.com"). It keeps 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) sends a model object from pi-ai's anthropic registry (form 3 in docs/agents/models-pi-ai.md) through AI Gateway without changing the model. pi-ai therefore saw api.anthropic.com and started sending thread: { type: "create" | "continue" } with only the new messages through the gateway. The new test shows it: with 1.5.1 and our old code, the body carried thread: { type: 'create' }. Threads now stay off through the gateway, as for pi-ai's own cloudflare-ai-gateway catalog models, 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 says this, and names the two opt-ins.
  • low · new feature: StreamOptions.disableContinuation (used above), the prompt cache warming helpers, the pi-ai/lazy-oauth and pi-ai/lazy-bedrock-provider subpaths, Provider.refreshModelsAuth, compat.promptCacheKeyMode, Claude Fable 5.2, qwen-token-plan-individual-cn, Microsoft-Decision-1; pi-durable's Tx.submission(id), per-conversation configure({ compaction }) and read-only JSONL storage; pi-schema's unsafe(), recursive(), Validator.validate(), equal() and bigint(); pi-codemode's resolveSchemaRef(); pi-telemetry's telemetryNow(); pi-agent-core's disableContinuation in streamProxy(). Not adopted: these are new APIs and nothing makes us use them. Users can reach them through harness.pi() or the packages themselves. Possible follow-up: expose per-conversation compaction settings on PiSession.
No effect on us (31)
  • chord "Chord v2 is the package's root… Chord v1 moved… removed", plus startWorker, createWorkers and host.reload: we import only chord/context and chord/delta. git diff v1.5.0 v1.5.1 -- packages/chord/src/context packages/chord/src/delta is empty.
  • chord's other additions, changes and fixes (sync layer, HTTP/workers/plugins/app kit/surfaces, remoteAddress, readSignedCookie, invalid/forbidden, usePageState, onError reports, live queries, messages, telemetry, TuiScope.optimistic, deny-by-default HTTP, not_ready before load, reload ordering, calls across loading, group commit, answer after state, worker lock/heartbeat/link fixes, WebSocket 1009, terminal sandbox): Chord v2 runtime surfaces we don't import.
  • pi-durable "SqliteStorage.commit() costs a few SQL statements per call…": we use pi-durable's own SQLite storage, and its conformance suite still passes in harness-pi.
  • pi-durable "Fixed a task staying waiting, or completing…" (#11892): scheduler fix inside pi; harness tests pass.
  • pi-durable "Fixed tool_search not finding a deferred tool… behind a local $ref" and the code mode URI malformed fix (#11803): pi-internal tool rendering and search.
  • 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": our tool schemas have no such 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 we import through pi-codemode/cloudflare.
  • pi-telemetry "renderTrace escapes control characters": output formatting only.
  • pi-tui HTML comments, Orca Kitty images, paste markers, cursor markers, Alacritty hyperlinks: the TUI channel's tests pass (channels 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 already sends tools only when there are some (chat-completions.ts:549).
  • pi-ai "Fixed OpenAI Responses requests sending session_id…" (#11639): our Responses wire builds its own request, with prompt_cache_key and x-session-affinity.
  • pi-ai "Fixed Claude Sonnet 5 requests sending an unsupported temperature parameter" (#7961): the gateway catalog's claude-sonnet-5 gains compat.supportsTemperature: false, which pi-ai's Anthropic implementation reads, so our wire gets the fix as it is. Otherwise the catalogs we import are unchanged: the same 19 Workers AI ids and 59 gateway ids.
  • pi-ai "Fixed Anthropic and Bedrock sending strict: \"prefer\" tools strict again…" (#11626): inside pi's Anthropic implementation, which our wire runs unchanged.
  • pi-ai "Fixed Anthropic non-strict tool schemas dropping root $defs…" (#9557): same; request shaping is pi's.
  • pi-ai "Fixed dropped provider streams… not triggering automatic retries" (#11879): pi's retry classifier; retryable-errors tests pass.
  • pi-ai "Fixed tool arguments for Type.BigInt() and Type.Undefined()": our tools use pi-schema builders without these types.
  • pi-ai "Fixed valid tool arguments being rejected when their schema combined local $refs with a relative root $id": none of our schemas has an $id.
  • pi-ai "Fixed cancellation during lazy provider loading…" and "Fixed lazy OAuth and Bedrock imports resolving relative to a bundle's location": we don't use pi's lazy provider loading or OAuth.
  • pi-ai "Fixed provider connection errors hiding their underlying cause": our transport reports its own gateway errors.
  • pi-ai "The default model for the anthropic provider is now Claude Opus 5.5" and the other default-model moves (including Kimi K2.7 Code for cloudflare-workers-ai and cloudflare-ai-gateway): we never use pi's default models; our examples name their model ids explicitly.
  • pi-ai Azure long-context pricing and context window, OpenRouter output limit, OpenCode Go thinking binding, OpenAI Codex SSE listeners, "OpenAI Codex (legacy)" rename, GLM 5.3 allowlist: providers we don't wrap.
  • "Custom GrepOperations.readFile callbacks are no longer called for context lines": coding-agent grep tool, which we don't use.
  • pi-agent-core: only the streamProxy() option above; experimental/pi-recovery typechecks.
  • Coding agent, CLI and extensions (we don't depend on pi-coding-agent): pi auth login/logout, pi update summaries, cacheWarming default "idle" and the combined Cache warmed line, Mermaid rendering and registerMarkdownTransformer({ messageTypes }), ctx.ui.custom() blocked, /login ordering, Dart/Nix/Groovy/Gradle highlighting.
  • Coding-agent tool fixes: grep glob relative to path, grep context from ripgrep, find/ls limits, find on Windows and its untracked fd, read streaming, edit line endings, bash timeout exit code, powershell 5.1 exit code, tool_search/codemode $ref summaries.
  • Coding-agent session and UI fixes: prompt template apostrophes, steering image resizing, image-only steering queue, ctrl+o for !/!!, ! truncation notice, /tree thinking level, paste markers, Ctrl+P scope, model selector jumps, extension overlays on /reload, selection dialog height, pi config keybindings, Ctrl+V on Windows/WSL, edit diff indentation, session-tree cursor, prompts overlapping navigation.
  • Coding-agent MCP, OAuth and runtime fixes: MCP sign-in, refresh and pi mcp list, MCP stdio/HTTP/SSE size and shutdown fixes, OAuth refresh on exit, symlinked auth.json locks, pi update --models OAuth, RPC ctx.shutdown() and shutdown cleanup, SDK/RPC reload during a response, runtime disposal order, changelog prerelease versions, image resize worker abort on macOS.
  • Coding-agent installer and examples: Windows installer under PowerShell 5.1, symlinked extension paths, subagent and plan-mode example fixes, llama.cpp connection errors.
  • Release note headline "GitHub Copilot classifiers" and "Package update summaries": coding-agent features (listed above).

Decisions

  • Ranges stay ~1.5.0; only the exact pi-tui pin and the lockfile move. The pin policy is ~X.Y.0 for peer and dev ranges, and ~1.5.0 already covers 1.5.1. The peer floor is not raised either. On 1.5.0 the new disableContinuation option is an unknown field pi ignores, and the two compat fields live in a private constant, so agents still works there.
  • Threads are switched 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. disableContinuation is the option upstream added for requests that must not use threads. A caller's explicit disableContinuation and a model's compat.supportsMessageThreads: true both still win. pi-ai keeps sending the message-threads-2026-08-12 beta header for such a session, and per pi "With the threads beta, a request without thread is a normal request".
  • The two new compat fields are false. That is pi-ai's own default for both, and it matches the strict OpenAI profile this constant describes: null content on tool-only assistant messages, and no tools: [].
  • Two tests added in packages/agents/src/tests/models/pi-ai/anthropic.test.ts. One checks that a sessionId request through the gateway has no thread field. The other checks that compat.supportsMessageThreads: true still gets thread: { type: "create" }.
  • Changeset patch. Source of the published agents package changes; no peer range moves.
  • fix(agents): upgrade Pi to 1.5.0 #2794 is superseded. It is the Gardener pull request for 1.5.0, only github-actions[bot] committed to it, and main is already on 1.5.0.

Needs a maintainer

  • Whether Anthropic message threads should run through AI Gateway by default. Options: keep them off unless opted 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 the thread field or returns thread rejections in the shape pi-ai's resend logic expects. If threads were on and a gateway dropped thread, the model would get only the new messages.

Affected open PRs

Other changes

  • packages/agents/package.json: dev @earendil-works/pi-tui 1.5.0 → 1.5.1.
  • pnpm-lock.yaml: updated with pnpm update -r --no-save "@earendil-works/*" (no specifier changes). Every @earendil-works/* package now resolves only 1.5.1. Chord's entries gain a react peer suffix, because chord 1.5.1 declares an optional react@19.3.0 peer. No other package changed.
  • docs/agents/models-pi-ai.md:237: the message-threads paragraph above.
  • packages/agents/src/models/pi-ai/wires/anthropic.ts, wires/chat-completions.ts, src/tests/models/pi-ai/anthropic.test.ts: as above.
  • .changeset/pi-1-5-1.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.1, unchanged code): 3 of 9 packages/agents tsconfigs failed with TS2322 at chat-completions.ts:58 ("missing … requiresNonNullAssistantContent, requiresToolsWithToolHistory"). The new gateway-threads test failed with expected { type: 'create' } to be undefined.
  • After: 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. packages/agents builds. All 9 packages/agents tsconfigs typecheck, and so do examples/next/{channels,models,harnesses/pi,tools/browser} and experimental/pi-recovery. oxfmt --check ., oxlint . and sherif pass. check:exports reports agents - all exports valid; it then stops at hono-agents, which this run didn't build.

Merge Danger

Door: two-way

Blast Radius: Pi users

1.5.1 changes no stored format: pi-durable's SQLite commit path writes the same rows with fewer statements, and no schema or transcript version moves, so rolling back to 1.5.0 is safe. Users on ~1.5.0 get no new peer warning from agents. pnpm may warn that chord 1.5.1's optional react@19.3.0 peer doesn't match their React; it only matters for chord's React bindings, which we don't use. Users who pass a pi-ai anthropic model object 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 pi-tui pin and the lockfile to Pi 1.5.1. Set pi-ai's two new
openai-completions compat fields in the strict profile. Keep Anthropic
message threads off for models routed through AI Gateway unless the model
or the caller opts in.

Gardener-Operation: op_7dd0beba0a96d266d1378795a9294a618524b3048bcbc0865f8466b6176d2d0b:63178bb40b15db8d47127cd2e8dc6e3da152e84d2473c56101813c60673e6e0e
@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: da24816

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 found 1 potential issue.

Devin Review

Comment on lines +237 to +240
`sessionId` does not start Anthropic message threads here. pi-ai turns them on only for a model
whose `baseUrl` is `api.anthropic.com`, and this package sends that model through AI Gateway, so
each request carries the whole conversation. To thread anyway, set
`compat.supportsMessageThreads: true` on the model or `disableContinuation: false` on the call.

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.

🔍 Confirm the documentation sync

The docs rules require a matching cloudflare-docs .mdx update. Confirm the new threading guidance was ported to that separate repository.

Devin Review


Was this helpful? React with 👍 or 👎 to provide feedback.

@github-actions

Copy link
Copy Markdown
Contributor Author

Superseded by #2862. Pi 1.5.2 is out, and that pull request carries this one's fixes over unchanged and moves to 1.5.2.

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