Skip to content

Chat: a tool result that arrives mid-stream joins the reply (4.iii 6f, parity 2, draft) - #3310

Closed
mattzcarey wants to merge 2 commits into
slim/chat-fn-6f1from
slim/chat-fn-6f3
Closed

mattzcarey wants to merge 2 commits into
slim/chat-fn-6f1from
slim/chat-fn-6f3

Conversation

@mattzcarey

Copy link
Copy Markdown
Member

DRAFT, 4.iii 6f parity step 2, stacked on #3308. A client's tool result that arrives while the reply that asked for it is still streaming joins that reply. The turn definition registers its live turn (per session, in memory, per Streams capability) while it streams. answerTool finds the call there, injects tool-output-available (or tool-output-error) into the turn's pipeline, so it's stored, sent and part of the reply like the model's chunks. With autoContinue it then queues a tool-answer turn, which waits behind the streaming one in the lane and continues the stored reply. A reset drops the live entry; the answer then finds the call in the stored reply, as before. Test: the result lands mid-stream, the stored reply has the tool's output, and the continuation runs after it.

onChatResponse with owed calls after a reset is already covered by #3289 (a replay after the cutover reports the stored result again).

Cost: one in-memory map entry per streaming turn; no storage.

@changeset-bot

changeset-bot Bot commented Nov 26, 2026 •

Copy link
Copy Markdown

⚠️ No Changeset found

Latest commit: cd1fd40

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@3310

@cloudflare/ai-chat

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

@cloudflare/codemode

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

hono-agents

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

@cloudflare/shell

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

@cloudflare/think

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

@cloudflare/voice

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

@cloudflare/worker-bundler

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

commit: cd1fd40

@agent-think

agent-think Bot commented Nov 26, 2026 •

Copy link
Copy Markdown
Contributor

✅ agents import sizes: no significant changes (60286819 → cd1fd407, workflow run)

@mattzcarey

Copy link
Copy Markdown
Member Author

Folded into #3298 (it fixes a regression rv-1 and Devin found there). The branch stays for reference.

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