Skip to content

fix(event): generate unique blockId for text stream events#1929

Open
itxaiohanglover wants to merge 1 commit into
agentscope-ai:mainfrom
itxaiohanglover:fix/block-id-unique
Open

fix(event): generate unique blockId for text stream events#1929
itxaiohanglover wants to merge 1 commit into
agentscope-ai:mainfrom
itxaiohanglover:fix/block-id-unique

Conversation

@itxaiohanglover

Copy link
Copy Markdown
Contributor

Summary

  • Generate a unique blockId (replyId_text_N) for each text block instead of hardcoding "text"
  • Update TextBlockStartEvent, TextBlockDeltaEvent, and TextBlockEndEvent to use the generated ID
  • Add AtomicInteger counter to ModelCallBlockLifecycle to track text block sequence

Problem

The blockId in text stream events was hardcoded as the fixed string "text", which violates the documentation specifying that blockId should serve as a unique identifier for each text block. When a single reply contains multiple text blocks (e.g., text → tool call → more text), consumers cannot distinguish between them.

Fixes #1899

Test Plan

  • Verified no existing tests assert on blockId == "text"
  • ./gradlew :agentscope-core:test passes

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
@itxaiohanglover itxaiohanglover requested a review from a team June 26, 2026 03:59
@codecov

codecov Bot commented Jun 26, 2026

Copy link
Copy Markdown

Codecov Report

✅ All modified and coverable lines are covered by tests.

📢 Thoughts on this report? Let us know!

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

[Bug]: The blockId within the generated text stream event is hardcoded as the fixed string "text"

1 participant