Repository navigation
Think on the harness: messengers through Channels (C4, part 1) - #3347
Merged
Merged
Conversation
|
| Name | Type |
|---|---|
| agents | Minor |
| @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
agents
@cloudflare/ai-chat
@cloudflare/codemode
hono-agents
@cloudflare/shell
@cloudflare/think
@cloudflare/voice
@cloudflare/worker-bundler
commit: |
Contributor
🟡 agents import sizes: 2 entry points grew
Changed exports (3)
How this worksEach 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 |
mattzcarey
force-pushed
the
slim/deliveries-channels-c4
branch
from
November 27, 2026 03:00
04587e5 to
67d676a
Compare
mattzcarey
marked this pull request as ready for review
November 27, 2026 03:24
mattzcarey
force-pushed
the
slim/deliveries-channels-c4
branch
from
November 27, 2026 04:55
6f2ad82 to
1eaf3f1
Compare
mattzcarey
added a commit
that referenced
this pull request
Nov 27, 2026
… on a cut response's turn; chatSdkChannel starts a stream with its first text; replay test tg-resetmid on both configs (harness still posts an extra 'Got')
mattzcarey
force-pushed
the
slim/deliveries-channels-c4
branch
from
November 27, 2026 05:57
573e0d2 to
993bdef
Compare
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 (
think/src/harness/think.ts) answers its messengers through Channels. Each messenger fromgetMessengers()becomes a Chat SDK Channel (#3203) whose replies are delivery runs (deliverToSurfaces, #3197), mounted withChannels.forHarness(this.harness). Its webhooks are checked by the messenger'sverifyWebhookand then go through the gateway's own code inside the object (ChannelGateway, every sender routed to this object). The webhook answers once its replies are sent, as Think's does.This is the first part of CHANNELS.md's C4, which H2 (#3295) unblocked:
think.tskeeps its messenger runtime until H11 swaps the classes.think/src/messengers' routing is deleted then, so C4 is finished together with H11.conversation: "self"does in Think, but a reply goes only to the thread whose message started its turn. The asker's surface is kept in KV under the event id until Channels settles the turn, so a reply after a reset still finds it.onStart, which runs after Channels re-attaches the session. Before, the rerun's answer never reached the chat.SupersededResponse, so the attempt is retried, and the retry reads it as empty.getMessengers()is read in the constructor, not at start as Think reads it, because Channels mounts its channels (and their deliveries register on Tasks) at construction. A subclass whosegetMessengers()reads a field set in its own constructor gets the field's initial value.Chat(subscriptions, mentions, bursts, the lane's arrival policy), recovery of replies a reset cut off, and per-thread sub-agents. Button approvals come after H7.Validation:
messengers.test.tson the harness-backed Think goes from 79 of 111 to 85 of 115 (pnpm test:harness,harness-compat.md). The new cases pass on both classes: a webhook its messenger'sverifyWebhookrefuses gets 401 and never reaches the adapter; a webhook sent to a sub-agent reaches the sub-agent's ownonRequest; two threads each get only their own reply, through their own messenger only; and nothing of the asker is kept once a turn that a reset cut has settled.durable-admission.test.tsalternates between 3 and 4 of 9 from run to run, so its intermittent test stays in the baseline.chat-sdk.test.tscase for the trimmed post and edit. The channels unit tests and the agents channels suite pass.messenger-replay.test.ts) gains "answers a direct message once after a reset mid-answer": onesendRichMessage"Got it". It passes on Think. Locally it also passes on the harness class through the newvitest.replay.harness.config.ts, which CI does not run.Cost: no released class changes, so no hot path of agents 0.34 / think 0.24 moves. A sub-agent of a harness-backed Think with messengers creates the empty Streams tables of the idle Channels at its first start, and runs one list query of streaming responses at each start.
Cost (root): for each answered message, the harness-backed class writes Channels' surface KV row, the asker KV row (deleted when the turn settles) and the response stream, plus one delivery run per surface (deleted once delivered).
Probe (reviewer), on account
543fbdef…, Workerslim-outbox-3347:getMessengers()returningtelegramMessenger({ token, userName, secretToken, apiBaseUrl }). PointapiBaseUrlat a route on the same Worker that records Bot API calls.sendRichMessage, with the rerun's full answer.onRequest(404 or the app's answer) and posts nothing. Its own chat turns are unchanged.getMessengers()returned{}).