Skip to content

Tests: move to @cloudflare/vitest-plugin - #3098

Merged
mattzcarey merged 8 commits into
mainfrom
slim/vitest-plugin
Nov 24, 2026
Merged

mattzcarey merged 8 commits into
mainfrom
slim/vitest-plugin

Conversation

@mattzcarey

@mattzcarey mattzcarey commented Nov 24, 2026 •

Copy link
Copy Markdown
Member

The repo's Workers tests now run on @cloudflare/vitest-plugin 1.9.1 instead of the deprecated @cloudflare/vitest-pool-workers 0.19.1. The package is renamed in 8 package.json files, every Vitest config import, and every test types entry; the lockfile is regenerated. The pool now runs workerd 1.20261123.1, and three things change with it:

  • the pool stores SQLite rows up to 8 MiB, as production does, so platform-limits.test.ts now asserts that the pool holds 8 MB
  • @cloudflare/worker-bundler picks the Pyodide lockfile from the Worker's compatibility date and flags: 3.12 before 2025-09-29, 3.13 until 2026-09-07, 3.14 from 2026-09-08. The new workerd runs the Python the date picks, as production does, so the fixed 3.12 wheels no longer import. A wrangler.toml/wrangler.jsonc in a Python project is also no longer uploaded as a module.
  • the size-error message names the old pool as the one with the 2.2 MB row cap

Why:

  • @cloudflare/vitest-pool-workers is deprecated on npm ("renamed to @cloudflare/vitest-plugin; this package will not receive future updates"), and its last release still ships a 2.2 MB-row workerd
  • the config API is unchanged (cloudflareTest() from the package root); the codemod @cloudflare/codemods vitest:pool-workers-to-vitest-plugin did the rename
  • pinned to 1.9.1, exact: 1.9.2 is still inside the repo's 24-hour minimumReleaseAge
  • no other dependency moved: the lockfile changes only the plugin's closure (it drops wrangler 4.116.0, which the plugin no longer needs, and the old workerd 1.20260730.1)
  • measured on a deployed dynamic Worker (slim-limits-pyver, deleted), Python by compatibility date: 3.12.1 up to 2025-09-28, 3.13.2 from 2025-09-29, 3.14.2 from 2026-09-08; python_workers_20250116 and python_workers_314 override the date. The docs state 3.14 from 2026-09-08. So the bundler's fixed 3.12 wheels were already broken in production for every date from 2025-09-29.

Tests that changed result on the new pool:

  • worker-bundler "createWorker with pyproject.toml" (6 tests): native wheels failed to import. Fixed in the bundler, not the tests. A new test per Python range (2025-09-01 → 3.12, 2026-01-01 → 3.13, 2026-09-08 → 3.14) imports pyyaml's C extension and checks sys.version_info. A unit test checks the date boundaries and flags.
  • harness-pi, four tests ("seeds the root after the object restarts…", "schedules the wake before a signal…", "holds the object while a tool waits…", "resumes a replay-safe tool after an eviction…"): they read or ran the alarm at a moment when the wake's alarm can be mid-dispatch, and the new pool fires alarms sooner. They now wait for the alarm to be armed (or for the wake to drain) with one alarmArmed helper, and assert the same end state. Each passed every isolated run (3 to 5 runs), and the pi suite passes in full (115).
  • platform-limits.test.ts: flipped, as above.

Locally: one full nx run-many -t test, and then agents, ai-chat and think three times each. Runs 1 and 3 were green. Run 2 had two failures: the pi wake test above (fixed after that run) and an opencode test that timed out under machine load and passes 5 of 5 alone. The three Think tests that fail locally on main (#2014 aged tool output, truncated workspace text reads, action ledger sweep) passed in all three runs. pnpm run test:react passed (182 tests). The test:e2e suites start wrangler dev or Vite, not this plugin. With an account set, Think's e2e passed (35 tests). pi-recovery's and tanstack-recovery's SIGKILL tests fail the same way on main. agent-think needs Docker, and agents-as-tools timed out starting its Vite server.

Stacked on #3079. Test tooling only, so exempt from the deployment probe. The worker-bundler fix was measured on a deployed Worker (slim-limits-pyver, deleted).

@changeset-bot

changeset-bot Bot commented Nov 24, 2026 •

Copy link
Copy Markdown

🦋 Changeset detected

Latest commit: 4d1f386

The changes in this PR will be included in the next version bump.

This PR includes changesets to release 3 packages
Name Type
agents Patch
@cloudflare/worker-bundler 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

@pkg-pr-new

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

Copy link
Copy Markdown

Open in StackBlitz

agents

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

@cloudflare/ai-chat

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

@cloudflare/codemode

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

hono-agents

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

@cloudflare/shell

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

@cloudflare/think

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

@cloudflare/voice

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

@cloudflare/worker-bundler

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

commit: 4d1f386

@agent-think

agent-think Bot commented Nov 24, 2026 •

Copy link
Copy Markdown
Contributor

✅ agents import sizes: no significant changes (fba754f5 → 4d1f3868, workflow run)

@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: No Issues Found

Devin Review analyzed this PR and found no bugs or issues to report.

Devin Review

devin-ai-integration[bot]

This comment was marked as resolved.

Base automatically changed from slim/limits-11 to main November 24, 2026 10:05
@mattzcarey
mattzcarey force-pushed the slim/vitest-plugin branch 11 times, most recently from 0fdb93e to 02dbe92 Compare November 24, 2026 19:38
devin-ai-integration[bot]

This comment was marked as resolved.

devin-ai-integration[bot]

This comment was marked as resolved.

@mattzcarey
mattzcarey force-pushed the slim/vitest-plugin branch 3 times, most recently from 81b6fbe to 6ee9456 Compare November 24, 2026 21:04
… from Pyodide 0.26.0a2; pi test retries an alarm that fired first; doc workerd version
devin-ai-integration[bot]

This comment was marked as resolved.

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

Devin Review

@mattzcarey
mattzcarey merged commit e44ff29 into main Nov 24, 2026
26 checks passed
@mattzcarey
mattzcarey deleted the slim/vitest-plugin branch November 24, 2026 23:33
ben-reitz added a commit that referenced this pull request Nov 25, 2026
Backports the harness.test.ts part of #3098 (e44ff29) onto release/0.34. On agents 0.34.0 the restarted-root test reads the alarm while the wake its startup pushed is still running, and fails about 2 runs in 5.
ben-reitz added a commit that referenced this pull request Nov 25, 2026
…g 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.
ben-reitz added a commit that referenced this pull request Nov 25, 2026
…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.
@github-actions github-actions Bot mentioned this pull request Nov 25, 2026
ben-reitz added a commit that referenced this pull request Nov 26, 2026
* ci: release from release/** branches too

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.

* fix(agents): support Pi 1.6.1, whose tool parks already reach agents 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.

* Version Packages (#3204)

Co-authored-by: github-actions[bot] <41898282+github-actions[bot]@users.noreply.github.com>

---------

Co-authored-by: github-actions[bot] <41898282+github-actions[bot]@users.noreply.github.com>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant