feat: AgentLite streaming partial content events#66
Open
DorianZheng wants to merge 3 commits into
Open
Conversation
Adds four new AgentLite events that enable the Dune UI to render agent responses token-by-token as they arrive from the Claude API: - run.partial_content — text token delta (content_block_delta/text_delta) - run.partial_tool_call — tool arg JSON delta (input_json_delta) - run.partial_content.done — stream completed normally (message_stop) - run.partial_content.interrupted — stream cut short (container crash/exit) includePartialMessages:true was already set; this extracts the stream_event SDK messages and surfaces them as typed events. Tracks in-flight jids via streamingJids set; drains all on container error or stopped state. Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com>
…ent events Covers all four new event types (run.partial_content, run.partial_tool_call, run.partial_content.done, run.partial_content.interrupted): 1. text_delta → run.partial_content with delta, contentBlockIndex, agentId, jid, timestamp 2. input_json_delta → run.partial_tool_call with jsonDelta 3. non-delta stream events (message_start) → no partial events emitted 4. message_stop → run.partial_content.done 5. container error during streaming → run.partial_content.interrupted (container_error) 6. container stopped during streaming → run.partial_content.interrupted (container_exit) 7. contentBlockIndex omitted when streamEvent.index is undefined 8. multiple sequential text_deltas → one event per delta + one done event Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com>
…ts 6-8 - Add per-jid in-memory ring buffer (last 2 KB) in MessageProcessor - appendToRingBuffer: appends text/tool deltas; marks evicted when >2 KB - resumePartialContent: replays buffered deltas on reconnect, or emits run.partial_content.interrupted (reason: buffer_evicted) when stream completed normally or buffer overflowed - Fix run.partial_content.done guard: only emit if streamingJids.has(chatJid) - Clear ring buffer on message_stop (stream completed normally) - Expose resumePartialContent via AgentImpl.resumePartialContent - Add test 6: ring-buffer replay replays deltas in order on reconnect - Add test 7: buffer_evicted emitted when stream completed before reconnect - Add test 8: two concurrent jids each get own events; drain interrupts both Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com>
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.
Adds run.partial_content, run.partial_tool_call, run.partial_content.done, and run.partial_content.interrupted events for token-by-token streaming output.
What's in this PR