feat(core): propagate ToolResultBlock metadata through agent events and AG-UI protocol (#2315)
## Description Tools can return structured execution context through `ToolResultBlock.metadata`. Previously, this metadata was preserved on the tool result block itself, but was not exposed on the fine-grained v2 agent tool-result events emitted during ReAct execution. This PR propagates `ToolResultBlock.getMetadata()` into the corresponding core tool-result events so event-stream consumers can access tool-specific context from `ToolResultTextDeltaEvent`, `ToolResultDataDeltaEvent`, and `ToolResultEndEvent`. AG-UI event types already support the optional `rawEvent` base field, but this PR does not change AG-UI’s default wire output and does not add a `metadata` field to `AguiEvent.ToolCallResult`. Applications that want to expose event metadata through AG-UI can opt in with a custom `AguiEventEnricher`. ## Changes Made ### Core events (`agentscope-core`) - Added Jackson metadata deserialization support to: - `ToolResultStartEvent` - `ToolResultTextDeltaEvent` - `ToolResultDataDeltaEvent` - `ToolResultEndEvent` - Kept backward-compatible constructors for callers that do not provide metadata. - Updated `ReActAgent.runToolBatch` to copy `ToolResultBlock.metadata` into: - streamed tool-result text/data delta events - non-streaming tool-result text/data delta events - final `ToolResultEndEvent` - Added tests for: - metadata round-trip serialization/deserialization on tool-result events - metadata propagation from a tool result into emitted ReAct agent events
N
ningmeng0503 committed
2e891c13b2da8339059bf01becc71f2b144ea70d
Parent: 91e8a66
Committed by GitHub <noreply@github.com>
on 8/11/2026, 6:35:22 AM