Repository navigation
fix(agents): let the server snapshot heal a diverged observed assistant (#2166) - #2344
Merged
threepointone merged 1 commit intoSep 24, 2026
Conversation
threepointone
added this pull request to stack #2345
September 23, 2026 19:59
🦋 Changeset detectedLatest commit: b1e8c58 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 |
Contributor
🟡 agents import sizesMeasured 344 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 Changed imports (13)
All 344 current runtime imports
Reported by agent-think[bot]. |
agents
@cloudflare/ai-chat
@cloudflare/codemode
hono-agents
@cloudflare/shell
@cloudflare/think
@cloudflare/voice
@cloudflare/worker-bundler
commit: |
threepointone
marked this pull request as ready for review
September 23, 2026 20:33
threepointone
force-pushed
the
fix/2166-observer-snapshot-heal
branch
2 times, most recently
from
September 23, 2026 21:39
fb4b843 to
8ce79a2
Compare
threepointone
force-pushed
the
fix/2166-observer-snapshot-heal
branch
from
September 23, 2026 22:09
8ce79a2 to
bdb1494
Compare
threepointone
force-pushed
the
fix/2166-observer-snapshot-heal
branch
from
September 23, 2026 22:47
bdb1494 to
b48a66c
Compare
threepointone
force-pushed
the
fix/2166-observer-snapshot-heal
branch
from
September 23, 2026 23:20
b48a66c to
d1a659a
Compare
…nt (#2166) Co-authored-by: Cursor <cursoragent@cursor.com>
threepointone
force-pushed
the
fix/2166-observer-snapshot-heal
branch
from
September 23, 2026 23:58
d1a659a to
b1e8c58
Compare
Merged
AshishKumar4
added a commit
to AshishKumar4/kinu
that referenced
this pull request
Oct 6, 2026
agents 0.24.0 -> 0.26.0 and ai-chat 0.12.1; both hunks are re-ported (paging after 0.25's settled-run branch; reconnect, which cloudflare/agents#2344 leaves open). The MCP overrides go: 0.26 still pins its MCP peers exactly, yet the lock holds one client 2.3.1 and SDK 1.32.1 (bun warns) and `bun pm scan` is clean. Root cause of the four workerd reds: since 0.25 an async method a stub calls starts its object first. A Nimbus sibling now starts, so its start returns before the startup row, and the probe's own reads are plain functions; a facet also calls `_cf_closeSubAgentConnectionsForPrefix` on its root. Proof: workerd start-before-rpc, addressed-name, attribution and nimbus-git-npm pass; a production turn runs 397 statements (limit 397); the recovery-scan units fail on the unpatched scan and pass patched. Left to CI: the rest of workerd, worker-heap, the first-run hang flows and the live-app reconnect rows (a local live-app run stalled on load at 1,200 s).
tombeckenham
added a commit
to tombeckenham/agents-tom
that referenced
this pull request
Oct 7, 2026
Brings react-agui.tsx level with the legacy hook in agents/chat/react, which received these through the upstream merge: - cloudflare#2344 the server snapshot heals a diverged observed assistant - cloudflare#2348 an observer skips replayed continuation frames it already applied - cloudflare#2361 onToolCall fires only after the stream ends - cloudflare#2378 onTurnEnd fires once per ended request - cloudflare#2383 turns settle across replay, resume and observers (held and recovering requests, the resume:false idle probe) - cloudflare#2496 streaming protection is released when the socket closes - cloudflare#2394 follow the socket when the agent name changes - cloudflare#2403 the tool-result cleanup no longer dispatches per chunk - cloudflare#2039 keep an optimistic send the reconnect transcript omits The last three had no failing test: their upstream tests are ported into react-tests (the address-change one against a fake of useAgent's pending socket, since this package has no test worker) and failed before the fix. restoreBufferedSends, MAX_REMEMBERED_ENDED_TURNS and isSocketAddressPending are exported from agents/chat/react so the two hooks share them.
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.
Fixes #2166. Related to #1951.
While a tab observes a stream (cross-tab, or resumed via the fallback observer),
useAgentChatre-applied its live accumulator over everycf_agent_chat_messagessnapshot. If the observed copy got interleaved or duplicated, the server's clean snapshot was discarded every time. Thedonemerge then reapplied the scrambled copy too, because Think broadcasts the final snapshot beforedone, so only a reload fixed it.Both places now keep the server's copy when the accumulator's text no longer extends it (
observedDivergesFrominbroadcast-state.ts). A healthy live accumulator is always the snapshot plus more, so normal observing, trailing-snapshot protection and continuations behave as before.This heals the symptom regardless of trigger. It does not fix #1951: a continuation replay that duplicates the already-rendered suffix still extends the snapshot text, and on reconnect that replay is usually owned by the AI SDK transport. That needs a separate design.
broadcast-state.test.ts, and a hook test inuse-agent-chat.test.tsx(fails without the fix).