Skip to content

fix(agent): use unique block ids for text/thinking stream events#2002

Open
liulangjietou wants to merge 1 commit into
agentscope-ai:mainfrom
liulangjietou:fix/unique-text-thinking-block-ids
Open

fix(agent): use unique block ids for text/thinking stream events#2002
liulangjietou wants to merge 1 commit into
agentscope-ai:mainfrom
liulangjietou:fix/unique-text-thinking-block-ids

Conversation

@liulangjietou

Copy link
Copy Markdown

AgentScope-Java Version

2.0.0-RC4 (main, latest)

Description

ReActAgent'''s streaming block events for text and thinking blocks were emitted
with hardcoded block ids ("text" / "thinking"), which violates the documented
contract that blockId uniquely identifies each content block. Tool-call block
events in the same code path already use a unique toolId, so this brings
text/thinking blocks in line with that existing precedent.

Fix: ModelCallBlockLifecycle now lazily allocates a unique block id (same
generation scheme as replyId: UUID.randomUUID().toString().replace("-", ""))
when a text/thinking block starts, and reuses that id across the block'''s
Start/Delta/End events. Two hardcoded call sites were fixed — the primary
emitBlockEvents path and a second duplicate path further down the file.

No public API changes; no existing test asserted on the literal "text"/"thinking"
ids, so this is behavior-compatible for all in-repo consumers.

Fixes #1899

Checklist

  • Code has been formatted with mvn spotless:apply
  • All tests are passing (mvn test)
  • Javadoc comments are complete and follow project conventions
  • Related documentation has been updated (e.g. links, examples, etc.)
  • Code is ready for review

Text/thinking block events were emitted with hardcoded block ids
("text"/"thinking"), violating the documented contract that blockId
uniquely identifies each content block. Allocate a unique id per block
in ModelCallBlockLifecycle (consistent across Start/Delta/End of the
same block), following the existing tool-call block precedent.

Fixes agentscope-ai#1899
@liulangjietou liulangjietou requested a review from a team July 3, 2026 13:04
@CLAassistant

Copy link
Copy Markdown

CLA assistant check
Thank you for your submission! We really appreciate it. Like many open source projects, we ask that you sign our Contributor License Agreement before we can accept your contribution.
You have signed the CLA already but the status is still pending? Let us recheck it.

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"

2 participants