Repository navigation
fix(agents): resolve ready only after the initial state frame (#2268) - #2402
Merged
threepointone merged 3 commits intoSep 28, 2026
Merged
Conversation
🦋 Changeset detectedLatest commit: 4e4c13c 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 #2407
September 28, 2026 14:47
threepointone
marked this pull request as ready for review
September 28, 2026 14:50
threepointone
force-pushed
the
fix/2268-ready-after-state
branch
from
September 28, 2026 15:46
30ad6e7 to
9cfa658
Compare
Contributor
|
✅ agents import sizes: no significant changes ( |
The identity frame now carries stateFollows when a state frame is next, and AgentClient and useAgent hold ready and identified until that state lands. The server sets the flag only when it will send the frame (serialized before the identity goes out), and clients also complete if the state arrived first, so a stateless host never waits. Unflagged servers and clients that ignore the flag keep the previous behavior. Co-authored-by: Cursor <cursoragent@cursor.com>
Co-authored-by: Cursor <cursoragent@cursor.com>
…ady settles Co-authored-by: Cursor <cursoragent@cursor.com>
threepointone
force-pushed
the
fix/2268-ready-after-state
branch
from
September 28, 2026 16:54
9cfa658 to
4e4c13c
Compare
agents
@cloudflare/ai-chat
@cloudflare/codemode
hono-agents
@cloudflare/shell
@cloudflare/think
@cloudflare/voice
@cloudflare/worker-bundler
commit: |
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.
Fixes #2268.
Problem
The server sends the identity frame before the state frame, and the tests in
msg-ordering.test.tspin that order as part of the wire protocol.AgentClientanduseAgentresolvedreadyandidentifiedon identity, so code awaitingreadyreadstateasundefinedon an agent that has state.Fix
I kept the wire order and added a flag:
stateFollows: trueonly when a state frame will actually follow. The new publicsendConnectFrames()does this;Agentand thewebsocketscapability both use it.readyandidentifieduntil the state lands, if the flag is set. They also complete when state arrived before identity, so a stateless host never waits.Compatibility works in both directions. An unflagged server behaves as before, and a client that ignores the flag behaves as before.
useAgentkeeps per-socket connect progress in aWeakMap, so a socket that was replaced cannot complete the new one's handshake.Tests
useAgentReadyProbetest and anAgentClienttest assert that state lands before identity resolves. Both fail without the fix.