Show the answer a running step is writing, provisional until the receipt - #22
Merged
Merged
Conversation
When the host advertises agents.text_stream, each step a run is working on shows a Live answer pane: the answer as the model writes it, read off the host's text/event-stream route with the same rules as the SDK -- sequences contiguous from the cursor, an id naming its sequence, a gap the only sanctioned jump, foreign fields refused, a terminal only with a read receipt. Text written before a tool call is withdrawn and the pane says so; a gap is said rather than papered over; when the run has a receipt the pane yields to the verified result, which decides the outcome. The pane reconnects from its last sequence on request and never restarts a run. It does not depend on the run view's callback identity, so a status poll cannot reopen the stream. Fourteen unit tests over the reader and capability, an API client test for the request shape, and four browser journeys: the pane arrives and yields to the verified result on desktop and mobile, withdrawn text is cleared and said, and no pane without the capability. 32 native journeys and 523 unit tests pass; typecheck and build are clean. Co-Authored-By: Claude Fable 5.1 <noreply@anthropic.com> Claude-Session: https://claude.ai/code/session_012aNJobunWMPFEa8mjsFQqY
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
Pairs with native PR #108 (
agents.text_stream). When the host advertises it, each step a run is working on shows a Live answer pane: the answer as the model writes it, read off/v1/agent-runs/{id}/steps/{step}/text/streamwith the SDK's rules (contiguous sequences from the cursor, an id naming its sequence, a gap the only sanctioned jump, foreign fields refused, a terminal only withread_receipt). Withdrawn text is cleared and said; a gap is said rather than spliced; once the run has a receipt the pane yields to the verified result. Reconnects from the last sequence on request; never restarts a run; independent of the run view's callback identity so status polls cannot reopen the stream.Files:
src/agents/answer-stream.ts(reader + address),src/agents/AnswerPane.tsx,ApiClient.answerStream, capabilityagents.text_stream, README.Verification
tests/agent-answer.test.ts(14): sequence and terminal; withdraw/gap/end; resume continuity; eight refusals (id, repeated sequence, error frame, cut stream, unknown kind, foreign field, terminal without receipt, gap off the cursor); capability parsing.tests/api.test.ts(+1): cursor as query andLast-Event-ID, bad ids/cursor refused before any request, non-SSE and redirects refused, 401 expires the session.scripts/test-agents.cjs(+4 journeys, desktop + mobile): the pane arrives with the provisional text and no result, then yields to the verified result with exactly one stream opened; withdrawn text cleared and said; no pane without the capability. 32/32 native journeys, 523 unit tests,tscandvite buildclean.🤖 Generated with Claude Code
https://claude.ai/code/session_012aNJobunWMPFEa8mjsFQqY