Repository navigation
chore: merge release/0.34 (agents 0.34.1) back into main - #3223
Conversation
Lets a fix ship from an earlier release's code while main carries unfinished work. A push runs the workflow file from the pushed branch, so this commit only has to be on the release branch.
…0.34 (#3171) * chore(agents): bump Pi to 1.6.1 Pi packages to ~1.6.1 (pi-tui 1.6.1 exact) in agents, the Pi examples and experimental/pi-recovery, and the pi-agent-core>pi-ai override to ~1.6.1. Pi 1.6.1 is a patch, but it ships everything on Pi main since 1.6.0, including tagged tool parks, so a fresh install of a released agents already picks it up. It stores pi.tool v4 and pi.generation v3 as 1.6.0 does, so rolling back to 1.6.0 stays safe. * fix(agents): word an error finish reason as pi-ai does on the chat-completions wire A chat-completions stream that ends with `finish_reason: "error"` now fails with pi-ai's own message, "Provider finish_reason: <reason>", instead of our "The model stopped with finish_reason ...". pi-ai's retry classifier matches "provider finish_reason: error" since earendil-works/pi@a00a504, so PiHarness retries such a mid-stream vendor failure, as Pi 1.6.1 does with its own openai-completions API. * docs(agents): park Pi tools and read signals with Pi's tagged forms earendil-works/pi@32c71a6 tags tool parks ({ kind: "sleep", ... }, flat) and SignalState ({ kind: "value" } or { kind: "expired" }). Every result field is optional, so the old { sleep: { ... } } still type-checks and Pi takes it as an empty result: the harness's parked-tool tests failed that way. The test tools and the pi.md samples now use the tagged forms; a beforeTool gate keeps { sleep: { ... } }. * test(agents): use a Groq model pi-ai still lists in the chat-completions tests Pi main drops Groq models that models.dev marks deprecated, including llama-3.1-8b-instant, so the fixture lookup threw. openai/gpt-oss-20b is listed with the same compat in Pi 1.6.0 and on Pi main. * fix(agents): record OpenRouter's native finish reason as pi-ai does on the chat-completions wire Pi main's openai-completions records OpenRouter's native_finish_reason (the upstream provider's own reason) in rawStopReason, e.g. error.MALFORMED_FUNCTION_CALL, and appends it to error messages after pi-ai's "Provider finish_reason:" prefix, so retry matching is unchanged. Our wire assembles the message itself, so it now sets rawStopReason and uses pi-ai's own OpenRouter helpers for the native reason. Needs the Pi release that ships utils/openrouter-finish-reason. * fix(agents): report every response to onResponse, failures included, as pi-ai does earendil-works/pi@8a57d42 makes pi-ai's onResponse fire for HTTP error responses and each retried attempt. pi-ai's Anthropic implementation now reports a vendor's error response through the gateway too, but AI Gateway's own failures (a gateway envelope, or any non-2xx from /run) threw before onResponse on all three wires. sendGateway now awaits the callback before it throws, the chat-completions and Responses wires report through it, and the Anthropic wire reports a response the SDK never sees because sendGateway threw. * fix(agents): read a large streamed SSE event in linear time earendil-works/pi@da7e26c fixes pi-ai's SSE readers rescanning an incomplete event on every chunk. sseDataStream, which the pi-ai chat-completions and Responses wires and the AI SDK provider read streams with, had the same cost: it ran its line regex over the whole buffer on each chunk, so an 8 MB event in 512-byte chunks took about 6 s. It now scans only the new text and joins an incomplete line once, when it ends. * test(agents): send no disabled thinking to a catalog Claude that cannot turn it off earendil-works/pi@433c1fd marks "off" unsupported on Claude Opus 5.5 and Sonnet 5.5 in pi's Cloudflare AI Gateway catalog, which reject thinking: { type: "disabled" } with a 400. The Anthropic wire reads the catalog's thinkingLevelMap through pi-ai, so the fix reaches it unchanged; this pins that a streamSimple call without reasoning sends no disabled thinking to anthropic/claude-opus-5.5 and still disables it on Haiku 5.5. On Pi 1.6.0's catalog the Opus call sends disabled. * chore(changeset): name Pi 1.6.1 and link its changelog * test(agents): run a Pi wake's alarm once it is armed instead of racing it Backports the harness.test.ts part of #3098 (e44ff29) onto release/0.34. On agents 0.34.0 the restarted-root test read the alarm while the wake its startup pushed was still pending, and failed about 2 runs in 5. It now runs that wake's alarm itself and waits for the fallback alarm to clear.
Co-authored-by: github-actions[bot] <41898282+github-actions[bot]@users.noreply.github.com>
Brings the Pi 1.6.1 support from #3171, the 0.34.1 version and CHANGELOG from #3204, and the release/** trigger in release.yml onto main, so main's next release builds on 0.34.1 and doesn't reuse its version or changeset. The one conflict, the restarted-root test in packages/agents/src/harness/pi/tests/harness.test.ts, takes release/0.34's version, which runs the wake's alarm instead of racing it.
|
agents
@cloudflare/ai-chat
@cloudflare/codemode
hono-agents
@cloudflare/shell
@cloudflare/think
@cloudflare/voice
@cloudflare/worker-bundler
commit: |
|
✅ agents import sizes: no significant changes ( |
| branches: | ||
| - main | ||
| # Maintenance releases, cut from an earlier release's code. | ||
| - "release/**" |
There was a problem hiding this comment.
🔴 Maintenance releases replace npm’s latest version
After a newer release ships, a maintenance release still publishes with latest through changeset publish. Unversioned installs of Agents then resolve to the older release line.
Learn more
The Release workflow runs the same publish script on main and maintenance branches. Changesets 2.31.0 checks whether the exact package version already exists, not whether the version is newer than the one tagged latest. For a normal release without an explicit alternative tag, it invokes pnpm with --tag latest. That makes the backport replace the tag used by the default install instructions.
Example: After main publishes Agents 0.35.0, an operator publishes 0.34.2 from release/0.34. A fresh npm install agents now selects 0.34.2 instead of 0.35.0.
Recommended fix: Give the release workflow an explicit publishing policy for maintenance branches. Pass a maintenance dist-tag to Changesets for backports, and only advance latest when the candidate is newer than the current default release.
Was this helpful? React with 👍 or 👎 to provide feedback.
| branches: | ||
| - main | ||
| # Maintenance releases, cut from an earlier release's code. | ||
| - "release/**" |
There was a problem hiding this comment.
🔴 Main pushes drop queued maintenance releases
A push to main replaces a queued maintenance publish in the shared concurrency group. The replacement checks out main, leaving the maintenance version unpublished.
Learn more
The Release workflow groups runs by workflow name, so main and maintenance share one group. GitHub Actions keeps one pending run per group by default and replaces that run when another arrives. cancel-in-progress: false protects only the running job. The surviving run's checkout step uses its own push, not the canceled push's maintenance commit.
Example: While a main release check is still running, merge the maintenance version PR so its publish run queues. Merge another PR to main before that check finishes. The new main run replaces the pending maintenance run; nothing publishes the maintenance commit without another push or a manual rerun.
Recommended fix: Keep publish runs queued without eviction if global serialization is required, or isolate the concurrency key by ref and protect shared npm publishing separately. Check that a main push cannot evict a pending maintenance publish.
Was this helpful? React with 👍 or 👎 to provide feedback.
| if (raw !== undefined) { | ||
| await options.onResponse?.(responseInfo(raw), model); | ||
| } |
There was a problem hiding this comment.
🟡 Anthropic response callbacks lose cancellation
When onResponse throws AbortError on a failed Anthropic response, transportError masks it with the provider failure. Fallback then sends the prompt to the next configured model instead of stopping.
Learn more
The Anthropic wire saves a typed vendor error before pi-ai calls the response hook on a non-2xx status. It also saves a gateway error before calling the hook itself. If the hook throws, the stream wrapper still emits the saved transport error. failStream classifies a thrown AbortError as aborted, but it never receives that error here. Fallback moves on after error, not after aborted.
Example: Configure a Claude model with a Workers AI fallback, and throw new DOMException("Stop", "AbortError") from onResponse on a 429. With no separate signal abort, the wire emits the 429 as an ordinary error and starts the Workers AI request.
Recommended fix: Track response-hook failures separately for both Anthropic response paths, and prefer them over saved transport errors when settling the stream. Test both a gateway rejection and a vendor 429 with a hook that throws AbortError, asserting that the stream aborts and no fallback request is sent.
Was this helpful? React with 👍 or 👎 to provide feedback.
| `cloudflare-error` diagnostic (`status`, `code`, `logId`). `onResponse` fires with the raw status | ||
| and headers of every response, as it does in pi-ai: a vendor's error response and the gateway's own | ||
| failure included, so a caller can read headers such as `retry-after` off a failed request. |
There was a problem hiding this comment.
🔍 Response hooks omit stream replay
onResponse reports the initial model response, but stream replay handles reconnect responses internally. The promise to report every response also reads as covering those reconnects.
Was this helpful? React with 👍 or 👎 to provide feedback.
…thropic request (#3306) * fix(agents): end the Anthropic wire aborted when onResponse throws an AbortError On a failed response the wire kept the transport's error and reported it over whatever the caller's onResponse threw, on both the gateway-failure path and pi-ai's vendor-error path. An AbortError from the hook became an ordinary error, so a fallback chain tried its next leg. The hook's error now wins. Six tests (gateway failure and vendor 429 on all three wires, and a fallback that must not run); the three Anthropic ones fail without the fix. From the #3223 review. * docs(agents): say onResponse reports each request once, not a resumed stream's reconnects
…lease branch (#3479) * ci: keep npm's latest on the newest release when publishing from a release branch From the #3223 review. Changesets tags every publish latest, so a maintenance release from release/<line> after a newer release would move latest back to the older line. It now keeps latest only when every package it publishes is newer than that package's latest, and otherwise publishes under release-<line>. The Release workflow's concurrency group is also per branch now: a single group let a push to main replace a maintenance release still waiting to run. * ci: check every workspace package and queue release runs in one group From the Devin review of #3479. The tag check read only packages/*, but Changesets also publishes voice-providers/*; it now lists the pnpm workspace. And per-branch groups let main publish between a maintenance run's latest check and its publish, so the Release workflow is back to one group, with queue: max so a push to main waits instead of replacing a pending maintenance run.
…lease branch (#3479) (#3510) * ci: keep npm's latest on the newest release when publishing from a release branch From the #3223 review. Changesets tags every publish latest, so a maintenance release from release/<line> after a newer release would move latest back to the older line. It now keeps latest only when every package it publishes is newer than that package's latest, and otherwise publishes under release-<line>. The Release workflow's concurrency group is also per branch now: a single group let a push to main replace a maintenance release still waiting to run. * ci: check every workspace package and queue release runs in one group From the Devin review of #3479. The tag check read only packages/*, but Changesets also publishes voice-providers/*; it now lists the pnpm workspace. And per-branch groups let main publish between a maintenance run's latest check and its publish, so the Release workflow is back to one group, with queue: max so a push to main waits instead of replacing a pending maintenance run. (cherry picked from commit 5876f38)
agents 0.34.1 shipped from
release/0.34so it wouldn't pick upmain's unfinished work. This merges that branch back, somain's next release starts from 0.34.1 instead of reusing its version or shipping its changeset again.Summary
gitGraph commit id: "[email protected]" branch release/0.34 commit id: "ci: release/** trigger" commit id: "#3171 Pi 1.6.1" commit id: "#3204 [email protected]" checkout main commit id: "main's unreleased work" merge release/0.34 id: "this PR"What
maingets:~1.6.1and parking tools use the tagged form.packages/agentsat version 0.34.1 with its CHANGELOG entry..changeset/pi-next.mdis already consumed.release/**inrelease.yml's push branches, for the next maintenance release.There was one conflict, in the restarted-root test in
packages/agents/src/harness/pi/tests/harness.test.ts. This takesrelease/0.34's version, which runs the wake's alarm instead of waiting for the runtime to fire it and then waits for the alarm to clear. That fixes the race Devin flagged on #3171.Evidence
mainon Pi 1.6.1 fails 6 harness-pi tests, because tools that park with the old{ sleep: { ... } }shape end with an empty result instead of parking. It also fails 18 models tests on the Groq fixture pi-ai no longer lists.After: on the merge commit,
pnpm install --frozen-lockfile,pnpm run buildandpnpm run checkpass. harness-pi passes 115/115, models/web/browser 459 (plus 2 todo), channels 145/145, and the Pi example 18/18.Merge Danger
Door: two-way
Use a merge commit, not a squash, so
release/0.34's commits stay inmain's history.Blast Radius: Pi users
main's next release carries Pi 1.6.1 support, which 0.34.1 already shipped.