Skip to content

Chat: a turn stopped during its retry backoff settles its stream (4.iii 6f, parity 8, draft) - #3322

Closed
mattzcarey wants to merge 1 commit into
slim/chat-fn-6f8from
slim/chat-fn-6f9
Closed

mattzcarey wants to merge 1 commit into
slim/chat-fn-6f8from
slim/chat-fn-6f9

Conversation

@mattzcarey

Copy link
Copy Markdown
Member

DRAFT, 4.iii 6f parity step 8, stacked on #3316.

A turn cut off by a transient error waits out its retry backoff as a pending Tasks run with its stream open. A cancel or clear in that window ends the run without entering the handler again, so nothing settled the stream, and the streamed text was never stored (turn-task's note on #3289).

cancelTurn and clearChat now read such a turn first (retryingTurn: the run is pending with wait reason retry, plus its base and discarded checkpoints and its input) and settle it after the cancel:

  • a stop stores what streamed as a reply, with cut-off tools settled, like a stop mid-stream;
  • a clear keeps nothing.

In both cases the stream is closed.

Tests: a stop during the backoff stores "Part" and the stream is no longer streaming; a clear during the backoff leaves an empty transcript and a settled stream. Both fail without the change.

Cost: a cancel does one run lookup first; a clear does one lookup per waiting turn of the lane. The hot path is unchanged.

@changeset-bot

changeset-bot Bot commented Nov 26, 2026 •

Copy link
Copy Markdown

⚠️ No Changeset found

Latest commit: 3197c8c

Merging this PR will not cause a version bump for any packages. If these changes should not result in a new version, you're good to go. If these changes should result in a version bump, you need to add a changeset.

This PR includes no changesets

When changesets are added to this PR, you'll see the packages that this PR includes changesets for and the associated semver types

Click here to learn what changesets are, and how to add one.

Click here if you're a maintainer who wants to add a changeset to this PR

@pkg-pr-new

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

Copy link
Copy Markdown

Open in StackBlitz

agents

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

@cloudflare/ai-chat

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

@cloudflare/codemode

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

hono-agents

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

@cloudflare/shell

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

@cloudflare/think

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

@cloudflare/voice

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

@cloudflare/worker-bundler

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

commit: 3197c8c

@agent-think

agent-think Bot commented Nov 26, 2026 •

Copy link
Copy Markdown
Contributor

✅ agents import sizes: no significant changes (cdf3329a → 3197c8c6, workflow run)

@mattzcarey

Copy link
Copy Markdown
Member Author

Closed to drain open PRs (COMMON, 27 Nov). This PR's commits are commits of #3361 (the switch), which now sits directly on #3298. The branch is kept.

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