fix(event): generate unique blockId for text and thinking stream events#1929
Open
itxaiohanglover wants to merge 3 commits into
Open
fix(event): generate unique blockId for text and thinking stream events#1929itxaiohanglover wants to merge 3 commits into
itxaiohanglover wants to merge 3 commits into
Conversation
The blockId in TextBlockStartEvent, TextBlockDeltaEvent, and TextBlockEndEvent was hardcoded as "text", violating the contract that blockId should be a unique identifier per text block. Generate a unique blockId (replyId + "_text_" + counter) each time a new text block starts, so consumers can distinguish multiple text blocks within a single reply. Fixes agentscope-ai#1899
Codecov Report❌ Patch coverage is
📢 Thoughts on this report? Let us know! |
|
blockID of Thinking Block shell be fixed together |
Contributor
Author
|
Good catch. I'll update the PR to also generate unique blockIDs for ThinkingBlock, following the same pattern as the text block fix. |
Apply the same unique blockID pattern to ThinkingBlock that was already applied to TextBlock: replyId + "_thinking_" + counter. This ensures ThinkingBlockStart/Delta/End events within the same reply use a consistent, unique block ID instead of the hardcoded "thinking" string, which caused collisions when multiple thinking blocks appeared in a single model response.
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.
Problem
Text and Thinking block stream events used hardcoded block IDs (
"text"and"thinking") instead of unique identifiers. When a single model response contained multiple text or thinking blocks (e.g., text → tool call → text), all blocks shared the same ID, making it impossible for clients to correlate start/delta/end events to the correct block.Fix
Generate unique block IDs using
replyId + "_text_" + counterandreplyId + "_thinking_" + counter:replyId + "_text_" + textBlockCounter.incrementAndGet()replyId + "_thinking_" + thinkingBlockCounter.incrementAndGet()Both patterns are applied consistently to Start, Delta, and End events in:
emitBlockEvents()— main model call streamsummaryModelCallStream()— summary model call streamPer maintainer feedback (@yulindong), ThinkingBlock was included in the same fix.
Test plan
mvn compile -pl agentscope-core