Live token-by-token streaming in session connect#42
Merged
Conversation
The committed transcript still comes from the steps API (grouped tool calls / results), but the socket now also carries ephemeral `delta` frames (partial assistant text + a running output-token count) from the backend's --include-partial-messages relay. Render them as a live in-progress line and a footer token counter (the token-by-token feel of local Claude Code), superseded by the committed step when it lands. Delta frames do NOT trigger a steps refresh (no polling storm). Backward-compatible: against a backend that doesn't emit deltas, behavior is unchanged (step-granular).
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.
What
Adds the client side of live streaming to
agent session connect: an in-progress assistant line that fills token-by-token and a footer token counter, matching local Claude Code.The committed transcript is unchanged (still the structured steps API, grouped tool calls/results). This layers the backend's new ephemeral
deltaframes (partial assistant text + runningoutput_tokens, from the--include-partial-messagesrelay) on top:ws.ts:deltaadded toStreamFrame(text?,output_tokens?); flows throughonFrame, doesn't terminate the stream.ConnectApp.tsx: adeltaframe updates a live overlay (append text) + the live token counter, and does NOT trigger a steps refresh (no polling storm). The overlay clears when the committed assistant step lands (superseding it) or the turn settles.Compatibility
Backward-compatible: against a backend that doesn't emit
deltaframes (current prod, until the monorepo PR ships), behavior is unchanged (step-granular, as v0.8.2). Safe to merge/release ahead of the backend.Depends on
The backend relay (monorepo PR): headless
run_session_loop+--include-partial-messagesto anagent_deltaschannel to a{type:"delta"}frame on/stream. This PR is the consumer.Tests
typecheck + 214 vitest tests + build all green.