Repository navigation
fix(think): run WebSocket chat turns on the implicit web channel (#2255) - #2330
Merged
threepointone merged 4 commits intoSep 23, 2026
Merged
threepointone merged 4 commits into
threepointone merged 4 commits into
Conversation
🦋 Changeset detectedLatest commit: a3fbf75 The changes in this PR will be included in the next version bump. This PR includes changesets to release 2 packages
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 |
threepointone
added this pull request to stack #2332
September 23, 2026 14:18
agents
@cloudflare/ai-chat
@cloudflare/codemode
hono-agents
@cloudflare/shell
@cloudflare/think
@cloudflare/voice
@cloudflare/worker-bundler
commit: |
threepointone
force-pushed
the
fix/2255-ws-chat-web-channel
branch
from
September 23, 2026 14:29
7ed7ed4 to
29687f8
Compare
Contributor
⚪ agents import sizesMeasured 343 runtime imports as minified bundles. The primary size is gzip; raw minified size is included for diagnosis. An existing import growing by more than 10% is marked red. This report is informational.
Compared No import sizes changed. All 343 current runtime imports
Reported by agent-think[bot]. |
threepointone
force-pushed
the
fix/2255-ws-chat-web-channel
branch
from
September 23, 2026 14:52
29687f8 to
08da32d
Compare
threepointone
force-pushed
the
fix/2255-ws-chat-web-channel
branch
from
September 23, 2026 15:33
08da32d to
1536b8f
Compare
Comment on lines
+104
to
+115
| Turns from browser clients over WebSocket chat (`useAgentChat`) always run on the | ||
| implicit `web` channel, so a `web` entry in `configureChannels()` applies its | ||
| `instructions`, `tools`, and `maxTurns` to them. The channel is stamped on each | ||
| new user message, so continuations after tool results and recovered turns keep | ||
| it. Clients cannot choose or forge a channel. Regenerating a message another | ||
| channel sent runs on `web` and leaves that message's channel unchanged; a | ||
| continuation after a tool result keeps `web`, but one that runs after the agent | ||
| was evicted takes the stored message's channel. | ||
|
|
||
| A `runTurn()` or `chat()` call with no `channel` runs without a channel context | ||
| and applies no channel policy. Pass `channel: "web"` to apply the `web` policy to | ||
| such a turn. |
Contributor
Contributor
Author
There was a problem hiding this comment.
Acknowledged. The cloudflare-docs sync happens at release time with the rest of the Think docs.
threepointone
force-pushed
the
fix/2255-ws-chat-web-channel
branch
from
September 23, 2026 16:42
1536b8f to
939d783
Compare
WebSocket chat turns were admitted without a channel, so a `web` entry in configureChannels() never applied and activeChannel was undefined. The ws-chat path now admits turns on `web` and stamps it on new user messages, keeping server-owned metadata when the client re-sends the transcript. Auto-continuations re-resolve the channel from the latest user message. Fixes #2255 Co-authored-by: Cursor <cursoragent@cursor.com>
A WebSocket regeneration of a message another channel stored runs on web, but its auto-continuation re-derived the channel from that message and switched to the other channel's policy. Auto-continuations now use the channel of the turn they extend, falling back to history after an eviction. Co-authored-by: Cursor <cursoragent@cursor.com>
A continuation run on an explicit channel was followed by an auto-continuation on the preceding user turn's channel, and a continuation without a channel re-read history instead of the turn it extends. Co-authored-by: Cursor <cursoragent@cursor.com>
…tarts A continuation without an explicit channel captured the previous turn's channel at admission, so one queued behind an explicit-channel turn applied the older channel's policy. Co-authored-by: Cursor <cursoragent@cursor.com>
threepointone
force-pushed
the
fix/2255-ws-chat-web-channel
branch
from
September 23, 2026 17:51
939d783 to
a3fbf75
Compare
Merged
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Problem
WebSocket chat turns (
useAgentChat) were admitted with no channel. So awebentry inconfigureChannels()never applied itsinstructions,tools, ormaxTurnsto browser chat, andthis.activeChannelwasundefinedduring those turns. TheRunTurnBase.channelJSDoc also claimed that turns default toweb, which was not true for any path.Fix
ws-chatpath admits its turns on the implicitwebchannel.channel: "web". When the client re-sends the transcript without server-owned metadata, the stored stamp is kept (content edits keep the prior row's reserved metadata).continueLastTurn()already did.Behaviour change: an app that configured a
webchannel now gets that policy on browser chat. The changeset calls this out.runTurn()andchat()without achannelare unchanged.docs/think/channels.mdand theRunTurnBase.channelJSDoc describe the actual defaults.Validation:
ws-web-channel.test.tscovers: the policy andactiveChannelon a WebSocket turn, the stamp, the stamp surviving a transcript re-send, a forged channel being ignored, re-resolution on continuation, and server-driven turns staying channel-less. Five fail without the fix; the sixth guards the unchanged default.pnpm run checkpassed.Fixes #2255
Thanks to @lswith for the report.
Stacked PR 9 of 10. Base: #2329.