Skip to content

Fix Think RPC callbacks and e2e harness stability#1601

Merged
threepointone merged 2 commits into
mainfrom
fix/e2e-rpc-callback-and-harness
May 28, 2026
Merged

Fix Think RPC callbacks and e2e harness stability#1601
threepointone merged 2 commits into
mainfrom
fix/e2e-rpc-callback-and-harness

Conversation

@threepointone

@threepointone threepointone commented May 28, 2026

Copy link
Copy Markdown
Contributor

Summary

  • Make @cloudflare/think's StreamCallback RPC surface fixed by requiring onStart and onError, avoiding Workers RPC calls to missing optional methods.
  • Update Think callback tests/e2e helpers to implement the fixed callback contract and preserve error propagation semantics.
  • Stabilize local e2e harnesses by avoiding detached process-group kills, using ephemeral Wrangler inspector ports, draining readiness probes, clearing stale agents-as-tools Wrangler state, widening real-LLM helper waits, and running root e2e targets serially.

Why

Nightly/local e2e runs were failing in two ways:

  • Think.chat() called callback.onStart?.(...), but optional method probing is unsafe across Workers RPC; callback receivers without onStart threw The RPC receiver does not implement the method "onStart".
  • Full npm run test:e2e ran remote-AI/dev-server e2e targets concurrently, which made tests contend for local runtimes/remote AI and left helper panels stuck in running or Vitest workers unable to terminate.

Test plan

  • npm run test in packages/think
  • npm run build in packages/think
  • npm run test:e2e in packages/think on Node 25
  • npm run test:e2e in packages/agents on Node 25
  • E2E_NO_RETRY=1 npx playwright test e2e/refresh-replay.e2e.ts --grep "two completed runs" in examples/agents-as-tools on Node 25
  • npx nx run-many -t test:e2e --parallel=1
  • npm run check

Notes

  • npm run check still reports the existing Sherif warnings for example directories without package.json; no errors were introduced.

Made with Cursor


Open in Devin Review

@changeset-bot

changeset-bot Bot commented May 28, 2026

Copy link
Copy Markdown

🦋 Changeset detected

Latest commit: 3c4980c

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

This PR includes changesets to release 1 package
Name Type
@cloudflare/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: No Issues Found

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

View in Devin Review to see 3 additional findings.

Open in Devin Review

Require the Think StreamCallback RPC surface to implement onStart and onError so Workers RPC does not probe missing optional methods across durable object boundaries. This fixes chat recovery for helper sub-agents and makes error delivery explicit for callback implementers.

Stabilize local e2e runs by avoiding detached process-group kills that can terminate Vitest workers, using ephemeral Wrangler inspector ports, draining readiness fetches, clearing stale agents-as-tools Wrangler state, and running root e2e targets serially to avoid remote AI/dev-server contention.

Co-authored-by: Cursor <cursoragent@cursor.com>
@threepointone
threepointone force-pushed the fix/e2e-rpc-callback-and-harness branch from a309eca to a716a4a Compare May 28, 2026 10:55
@pkg-pr-new

pkg-pr-new Bot commented May 28, 2026

Copy link
Copy Markdown

Open in StackBlitz

agents

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

@cloudflare/ai-chat

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

@cloudflare/codemode

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

hono-agents

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

@cloudflare/shell

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

@cloudflare/think

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

@cloudflare/voice

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

@cloudflare/worker-bundler

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

commit: 3c4980c

Update documentation and design notes to mark StreamCallback handlers as required (remove optional ? for onStart and onError) across design/think.md, docs/think/sub-agents.md, and packages/think/README.md. Also clarify onError behavior text and add a usage example logging onStart. This aligns the docs with the runtime expectation that these callbacks are always provided.
@threepointone
threepointone merged commit 0fb0acf into main May 28, 2026
4 checks passed
@threepointone
threepointone deleted the fix/e2e-rpc-callback-and-harness branch May 28, 2026 11:46
@github-actions github-actions Bot mentioned this pull request May 28, 2026
threepointone added a commit that referenced this pull request May 28, 2026
* Fix Think RPC callbacks and e2e harness stability

Require the Think StreamCallback RPC surface to implement onStart and onError so Workers RPC does not probe missing optional methods across durable object boundaries. This fixes chat recovery for helper sub-agents and makes error delivery explicit for callback implementers.

Stabilize local e2e runs by avoiding detached process-group kills that can terminate Vitest workers, using ephemeral Wrangler inspector ports, draining readiness fetches, clearing stale agents-as-tools Wrangler state, and running root e2e targets serially to avoid remote AI/dev-server contention.

Co-authored-by: Cursor <cursoragent@cursor.com>

* Make StreamCallback handlers required in docs

Update documentation and design notes to mark StreamCallback handlers as required (remove optional ? for onStart and onError) across design/think.md, docs/think/sub-agents.md, and packages/think/README.md. Also clarify onError behavior text and add a usage example logging onStart. This aligns the docs with the runtime expectation that these callbacks are always provided.

---------

Co-authored-by: Cursor <cursoragent@cursor.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