Skip to content

Chat: no deferred continuation slot (4.ii-a, slice 2) - #3240

Open
mattzcarey wants to merge 6 commits into
mainfrom
slim/chat-fn-2b
Open

mattzcarey wants to merge 6 commits into
mainfrom
slim/chat-fn-2b

Conversation

@mattzcarey

@mattzcarey mattzcarey commented Nov 26, 2026 •

Copy link
Copy Markdown
Member

Chat functions step 4.ii-a, slice 2 (slice 1 was #3239). The deferred continuation slot is gone. When a tool answer arrives while a continuation runs, it now schedules the next continuation like any other answer: it coalesces, and the barrier holds it until the running continuation has streamed and its reply is finalized (or the running one settles without a stream), because the model may still add tool calls to the reply it answers. Its turn then waits behind the running one in the lane. ChatTurns keeps the new ContinuationSlots (pending: scheduled, its turn not started; running: its turn started, its stream not; activeRequestId: its stream runs; and the tabs waiting) instead of ContinuationState, and these go with the slot: deferred, pastCoalesce, activateDeferred, the settle step that merged a deferred answer's targets into a newer continuation, and the stop branch that dropped a deferred answer.

What changes for an app: an answer that arrived during a continuation now starts its follow-up one coalesce window (50 ms) after the reply is finalized, not at once when the turn settles. A stop that drops it reports it under its own request id (cont-2:stopped), where it used to be requestId: null. The rules in continuation-turn.ts still hold, and each test that covered the deferred slot now covers the next-continuation path: one continuation per result, never against a transcript that ends in an answer, an answer during a run is never lost, a waiting tab always gets STREAM_RESUMING or STREAM_RESUME_NONE (a tab whose answer arrives during a run starts waiting once that run's stream starts or its turn ends), and a stop drops what waits. A tab's stop without an id is for the reply it was just told to resume, even when that tab already waits on the next continuation.

ContinuationState stays exported, unchanged and @deprecated, because released ai-chat 0.12.3 and Think 0.24.0 construct it and hand it to this ResumeHandshake. The handshake reads running as optional for that reason, and a test checks it still parks a tab on such a host's pending continuation. Next is slice 3: the stored continuation keys.

Cost: deferred slot code deleted from continuation-turn.ts and chat-turns.ts; ContinuationSlots added (≈90 lines with docs); the deprecated ContinuationState is still there for released imports. Interfaces: ContinuationTurnParts loses activateDeferred.

@changeset-bot

changeset-bot Bot commented Nov 26, 2026 •

Copy link
Copy Markdown

⚠️ No Changeset found

Latest commit: f12297f

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 changesets to release 4 packages
Name Type
agents Patch
@cloudflare/ai-chat Patch
@cloudflare/think Patch
@cloudflare/agent-think Patch

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

@cloudflare/ai-chat

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

@cloudflare/codemode

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

hono-agents

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

@cloudflare/shell

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

@cloudflare/think

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

@cloudflare/voice

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

@cloudflare/worker-bundler

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

commit: f12297f

@agent-think

agent-think Bot commented Nov 26, 2026 •

Copy link
Copy Markdown
Contributor

🟢 agents import sizes: 1 entry point changed, no growth

Entry point Exports Largest gzip change Size now
🟢 agents/chat 1 resized -169 B (-1.1%) 14.9 KiB
Changed exports (1)
Import Gzip change Size now
🟢 agents/chat#ChatTurns -169 B (-1.1%) 14.9 KiB
How this works

Each runtime export is bundled on its own, minified, and gzipped. Changes smaller than 100 B, or smaller than 1% and 1 KiB, are ignored. Growth over 10% or 5 KiB is marked 🔴. This report is informational and does not fail CI. The workflow artifact contains every measurement.

Compared 3282ee45 → f12297fd · workflow run · reported by agent-think[bot]

@mattzcarey
mattzcarey marked this pull request as ready for review November 26, 2026 07:05
devin-ai-integration[bot]

This comment was marked as resolved.

devin-ai-integration[bot]

This comment was marked as resolved.

devin-ai-integration[bot]

This comment was marked as resolved.

devin-ai-integration[bot]

This comment was marked as resolved.

…nuation schedules the next one, behind it in the lane (4.ii-a, slice 2)
…tles; a tab's stop is for the reply it was told to resume
… Think answer then a reset across the coalesce window
…tab; the gate assertion no longer hides in the model
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 1 new potential issue.

Devin Review

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