You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
{{ message }}
Repository navigation
[Bug]: With ToolEmitter, the event stream / AG-UI TOOL_CALL_RESULT reports emitted chunks instead of the tool's return value #3312
ToolEmitter documents that "The emitted chunks do NOT affect what the LLM receives - only the tool method's return value is sent to the LLM." The event stream, however, treats emitted chunks as the streamed form of the result: in ReActAgent, once a tool has emitted chunks its id is added to chunkedToolIds, and emitToolResultDelta then skips emitting the tool's actual return value. ToolResultEndEvent does not carry the result either.
As a result, for a tool that emits progress chunks, the event stream (and therefore AG-UI TOOL_CALL_RESULT) reports the concatenated chunk text, while the model receives the return value. The two histories diverge:
AG-UI clients insert TOOL_CALL_RESULT into their message history as the tool message. A client that resends full history without server-side memory feeds the chunk text back to the model as the tool result — contradicting the ToolEmitter contract, and leaking anything that was emitted only for the UI (e.g. a one-time code shown to the user).
A client that relies on TOOL_CALL_RESULT to show the operation's outcome sees progress text instead of the actual result.
Reproduction (verified on 2.0.4-SNAPSHOT built from main, AG-UI server, scripted model)
Model request: the tool result is fingerprint enrolled.
AG-UI TOOL_CALL_RESULT.content: press oncepress againdone (the return value never appears in the event stream).
Expected
The final tool result in the event stream (ToolResultTextDeltaEvent/ToolResultDataDeltaEvent before ToolResultEndEvent, and thus TOOL_CALL_RESULT) is the tool's return value — what the model receives — regardless of whether progress chunks were emitted. Progress chunks could remain distinguishable (e.g. by their metadata) for UIs that want to render them.
Issue Evaluation (automated verification against main @ 857e3e6)
Category: bug | Status: Confirmed | Severity: high (contract violation in a public API; silent data divergence between what the model sees and what protocol clients record)
All four claims were checked against the source, independently of the report:
#
Claim
Verdict
Evidence
1
ToolEmitter documents that chunks never reach the LLM
TRUE
agentscope-core/.../tool/ToolEmitter.java:25 — "delivered to onActingChunk() events but are NOT sent to the LLM. Only the final return value ..."; same statement at :65
2
Once a tool emits chunks, its id is registered and the real return value is never emitted as deltas
TRUE
ReActAgent.java:3217 (chunkedToolIds), :3226 (id added on non-empty chunk), :3328 → emitToolResultDelta(...), :3482 — if (chunkedToolIds.contains(toolId)) { return; }, before any output of entry.getValue() is read
3
ToolResultEndEvent carries no result payload
TRUE
event/ToolResultEndEvent.java:25-28 — fields are replyId, toolCallId, toolCallName, state only
4
Event stream / AG-UI TOOL_CALL_RESULT therefore reports the concatenated chunks
TRUE
agui/adapter/strategy/ToolResultEventConverter.java:38-52 buffers text/data deltas; AguiStreamContext.endToolResult (:283-300) emits AguiEvent.ToolCallResult from that buffer, which is exactly the chunk text
One correction to the report: the model context is not polluted. ReActAgent.notifyPostActingHook builds the tool message from the real ToolResultBlock (ReActAgent.java:3735-3736 → ToolResultMessageBuilder.buildToolResultMsg). The leak is into the client-side / persisted event history, which is what bites clients that resend history or that render TOOL_CALL_RESULT as the outcome.
Blast radius is larger than AG-UI. Any consumer that rebuilds a tool result from ToolResultTextDeltaEvent/ToolResultDataDeltaEvent + ToolResultEndEvent has the same divergence:
service-dataplane/.../managed/SessionEventMapper.java:212-251 — persists AGENT_TOOL_RESULT from the delta buffer, so the wrong text also lands in stored session history
agentscope-harness/.../subagent/protocol/RemoteEventCodec.java:118-127 and the AG-UI SubagentEventConverter.java:118-127 — end event carries id/name/state only
The chunkedToolIds logic itself is localized to ReActAgent; no other agent class duplicates it.
Existing tests do not pin this contract (ToolEmitterIntegrationTest.java:232-277 asserts hook callbacks only; AguiAgentAdapterV2Test.java:737-756 and SessionEventMapperTest.java:195-211 test manual delta aggregation, so they pass with the bug).
Proposed fix (minimal, backward compatible)
Add an optional ToolResultBlock result to ToolResultEndEvent (extra constructor overload + getter; existing constructors unchanged).
In ReActAgent.runToolBatch, populate it with the actual entry.getValue() when the end event is emitted (independent of chunkedToolIds).
In AguiStreamContext.endToolResult, prefer the end-event result for ToolCallResult.content, falling back to the accumulated buffer when absent — progress chunks remain available as deltas (with their existing ordering/metadata) for UIs that want to render live progress.
Same "prefer real result" treatment in SessionEventMapper and AistioObserverMiddleware.
No change to ToolEmitter, tool method signatures, or the AG-UI event records; consumers that ignore the new field keep today's behavior until they opt in.
Needs one design decision from a maintainer before a PR: is TOOL_CALL_RESULT defined as the canonical tool result (this fix), or as a stream replay where chunks legitimately win? If the former, we will open a PR implementing steps 1-3 above plus regression tests in agentscope-core, agentscope-extensions-agui and service-dataplane.
Automated evaluation by github-manager (oss-maintainer). Reply /approve to generate the PR as described, /revise <notes> to adjust the approach, or /reject to drop it.
Proposal window closed — no competing PR will be filed from this proposal window
The 72 h feedback window opened by the evaluation above (2026-09-26T15:06:52Z) reached its bound on 2026-09-29T15:06:52Z with no /approve, /revise or /reject directive from a maintainer or the reporter. Automated PR generation for this issue is therefore skipped: no automated PR will be generated from this window.
The thread did answer the underlying question in another way. Community PR #3331 (fix(core): report the tool return value on ToolResultEndEvent, authored by @King52HerTz on 2026-09-28T05:45:43Z) cross-references this issue and targets the same seam the evaluation described — the emitted-chunks-vs-return-value gap on the tool-result event. As of this read #3331 is OPEN, not a draft, unmerged, head fe18b3838781ae74c5a93d637a94a04b416bf12d, mergeable_state reported MERGEABLE, last updated 2026-09-28T06:49:55Z.
So the implementation path here is already owned by a community PR waiting on maintainer review. Filing a second PR against the same issue is exactly the collision this window policy exists to prevent, which is why the proposal is stood down rather than escalated.
Nothing in this notice disputes the evaluation: with ToolEmitter, an AG-UI TOOL_CALL_RESULT carrying the streamed chunks instead of the tool's return value is a real correctness gap, and the reported reproduction stands. The productive thread now is review of #3331 — merge it, request changes, or close it. If #3331 is closed unmerged and this fix is still wanted, reply on this issue and the question will be re-evaluated against whatever main looks like at that point.
Automated feedback-window maintenance by github-manager-bot
Activity
oss-maintainer commentedon Sep 26, 2026
Issue Evaluation (automated verification against
main@857e3e6)Category:
bug| Status: Confirmed | Severity: high (contract violation in a public API; silent data divergence between what the model sees and what protocol clients record)All four claims were checked against the source, independently of the report:
ToolEmitterdocuments that chunks never reach the LLMagentscope-core/.../tool/ToolEmitter.java:25— "delivered toonActingChunk()events but are NOT sent to the LLM. Only the final return value ..."; same statement at:65ReActAgent.java:3217(chunkedToolIds),:3226(id added on non-empty chunk),:3328→emitToolResultDelta(...),:3482—if (chunkedToolIds.contains(toolId)) { return; }, before any output ofentry.getValue()is readToolResultEndEventcarries no result payloadevent/ToolResultEndEvent.java:25-28— fields arereplyId,toolCallId,toolCallName,stateonlyTOOL_CALL_RESULTtherefore reports the concatenated chunksagui/adapter/strategy/ToolResultEventConverter.java:38-52buffers text/data deltas;AguiStreamContext.endToolResult(:283-300) emitsAguiEvent.ToolCallResultfrom that buffer, which is exactly the chunk textOne correction to the report: the model context is not polluted.
ReActAgent.notifyPostActingHookbuilds the tool message from the realToolResultBlock(ReActAgent.java:3735-3736→ToolResultMessageBuilder.buildToolResultMsg). The leak is into the client-side / persisted event history, which is what bites clients that resend history or that renderTOOL_CALL_RESULTas the outcome.Blast radius is larger than AG-UI. Any consumer that rebuilds a tool result from
ToolResultTextDeltaEvent/ToolResultDataDeltaEvent+ToolResultEndEventhas the same divergence:service-dataplane/.../managed/SessionEventMapper.java:212-251— persistsAGENT_TOOL_RESULTfrom the delta buffer, so the wrong text also lands in stored session historyagentscope-extensions-aistio/.../AistioObserverMiddleware.java:138-155agentscope-harness/.../middleware/AgentTraceMiddleware.java:188-210,AsyncToolMiddleware.java:247-250agentscope-harness/.../subagent/protocol/RemoteEventCodec.java:118-127and the AG-UISubagentEventConverter.java:118-127— end event carries id/name/state onlyThe
chunkedToolIdslogic itself is localized toReActAgent; no other agent class duplicates it.Existing tests do not pin this contract (
ToolEmitterIntegrationTest.java:232-277asserts hook callbacks only;AguiAgentAdapterV2Test.java:737-756andSessionEventMapperTest.java:195-211test manual delta aggregation, so they pass with the bug).Proposed fix (minimal, backward compatible)
ToolResultBlock resulttoToolResultEndEvent(extra constructor overload + getter; existing constructors unchanged).ReActAgent.runToolBatch, populate it with the actualentry.getValue()when the end event is emitted (independent ofchunkedToolIds).AguiStreamContext.endToolResult, prefer the end-event result forToolCallResult.content, falling back to the accumulated buffer when absent — progress chunks remain available as deltas (with their existing ordering/metadata) for UIs that want to render live progress.SessionEventMapperandAistioObserverMiddleware.No change to
ToolEmitter, tool method signatures, or the AG-UI event records; consumers that ignore the new field keep today's behavior until they opt in.Needs one design decision from a maintainer before a PR: is
TOOL_CALL_RESULTdefined as the canonical tool result (this fix), or as a stream replay where chunks legitimately win? If the former, we will open a PR implementing steps 1-3 above plus regression tests inagentscope-core,agentscope-extensions-aguiandservice-dataplane.Automated evaluation by github-manager (oss-maintainer). Reply
/approveto generate the PR as described,/revise <notes>to adjust the approach, or/rejectto drop it.oss-maintainer commentedon Sep 29, 2026
Proposal window closed — no competing PR will be filed from this proposal window
The 72 h feedback window opened by the evaluation above (
2026-09-26T15:06:52Z) reached its bound on2026-09-29T15:06:52Zwith no/approve,/reviseor/rejectdirective from a maintainer or the reporter. Automated PR generation for this issue is therefore skipped: no automated PR will be generated from this window.The thread did answer the underlying question in another way. Community PR #3331 (
fix(core): report the tool return value on ToolResultEndEvent, authored by @King52HerTz on2026-09-28T05:45:43Z) cross-references this issue and targets the same seam the evaluation described — the emitted-chunks-vs-return-value gap on the tool-result event. As of this read #3331 is OPEN, not a draft, unmerged, headfe18b3838781ae74c5a93d637a94a04b416bf12d,mergeable_statereported MERGEABLE, last updated2026-09-28T06:49:55Z.So the implementation path here is already owned by a community PR waiting on maintainer review. Filing a second PR against the same issue is exactly the collision this window policy exists to prevent, which is why the proposal is stood down rather than escalated.
Nothing in this notice disputes the evaluation: with
ToolEmitter, an AG-UITOOL_CALL_RESULTcarrying the streamed chunks instead of the tool's return value is a real correctness gap, and the reported reproduction stands. The productive thread now is review of #3331 — merge it, request changes, or close it. If #3331 is closed unmerged and this fix is still wanted, reply on this issue and the question will be re-evaluated against whatevermainlooks like at that point.Automated feedback-window maintenance by github-manager-bot
fix(core): carry tool progress on its own event type (#3331)