Repository navigation
Think on the harness: messengers through Think's Chat SDK Chat (C4, part 2) - #3360
Merged
Merged
Conversation
|
agents
@cloudflare/ai-chat
@cloudflare/codemode
hono-agents
@cloudflare/shell
@cloudflare/think
@cloudflare/voice
@cloudflare/worker-bundler
commit: |
Contributor
|
✅ agents import sizes: no significant changes ( |
mattzcarey
force-pushed
the
slim/deliveries-channels-c4-chat
branch
from
November 27, 2026 03:48
6e5cd08 to
3868cb7
Compare
mattzcarey
force-pushed
the
slim/deliveries-channels-c4
branch
from
November 27, 2026 04:55
6f2ad82 to
1eaf3f1
Compare
mattzcarey
force-pushed
the
slim/deliveries-channels-c4-chat
branch
from
November 27, 2026 04:59
3868cb7 to
c94262d
Compare
mattzcarey
force-pushed
the
slim/deliveries-channels-c4
branch
from
November 27, 2026 05:57
573e0d2 to
993bdef
Compare
mattzcarey
force-pushed
the
slim/deliveries-channels-c4-chat
branch
from
November 27, 2026 06:31
98442b4 to
5769996
Compare
…tate, subscriptions, mentions, bursts, locks)
mattzcarey
force-pushed
the
slim/deliveries-channels-c4-chat
branch
from
November 27, 2026 06:35
5769996 to
ff8e8ce
Compare
mattzcarey
marked this pull request as ready for review
November 27, 2026 06:44
…harness-compat messengers 94 of 116
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.
The harness-backed Think's messengers take their webhooks through Think's own Chat SDK
Chat, so they answer what Think answers. That coversrespondTo, mentions found in a burst, subscriptions, bursts joined into one prompt with speaker labels,messengerConcurrency, and the thread lock held through the turn. Each event theChatroutes joins the harness's default session throughChannels.forHarness, and the reply is still sent by the messenger's Chat SDK Channel as a delivery run.Follows #3347 (C4, part 1); this is part 2:
Chatconstruction and its handlers move out ofThinkMessengerRuntimeintocreateMessengerChat(), which both classes call. Nothing is copied, and the released class behaves as before.Chatkeeps its state on Think'sThinkMessengerStateAgentsub-agents, so the release'schat_sdk_state_*rows (subscriptions, locks, queued messages) are read as they are. CHANNELS.md's storage rule asks for that.asker), and the handler returns once Channels settled the turn and the deliveries' first attempts ended.ChannelGatewayfrom part 1 is gone from this path. The gateway hands each message to its own turn, which would split a burst and drop the thread lock that Think holds through a turn. Think's dedupe key (idempotencyKeyForEvent) is the operation id.chatSdkChannel({ initialize })(internal) is for an adapter aChatalready owns. The Channel sends through theChat's initialization and takes no webhooks of its own.messengerConcurrencyis a field on the harness-backed class, read when the first webhook arrives.Validation:
messengers.test.tson the harness-backed Think goes from 86 of 115 to 94 of 116 (441 of 1313 in total, 0 class-only) (pnpm test:harness). The bursts, the queue strategy, mixed senders, subscribed and unsubscribed threads, the skipped mention and the lock TTL tests now pass, plus a new case: a group speaker gets the messenger'schannelSpeakerLabel, on both classes. The 22 left are recovery, the queue drains behind a reply and the reply texts (later parts).messengers.test.tsandtelegram-messenger.test.tson Think pass, as do the channels unit tests, plus a new case forinitialize. The Telegram replay (messenger-replay.test.ts, 3 cases including a reset mid-answer) passes on both classes.Cost: no released class changes. Per answered message the harness-backed class now does what Think does in Chat SDK state: the thread lock and the dedupe key, on the state sub-agent. Channels adds its surface KV row, its response stream and one delivery run per surface, deleted once delivered.
Probe (reviewer): the same as #3347, on
slim-rv-2-…with this head. Also send a burst of three updates to one private chat in one webhook: one turn, one sent message, and a prompt with the three lines in order. Then send a group update that mentions the bot followed by an unmentioned one in the same webhook: answered once, and the thread is subscribed.