fix(adk): set streaming meta for agentic tool chunks#1045
Merged
Conversation
Codecov Report❌ Patch coverage is
Additional details and impacted files@@ Coverage Diff @@
## main #1045 +/- ##
==========================================
- Coverage 83.05% 82.99% -0.07%
==========================================
Files 162 162
Lines 23029 23038 +9
==========================================
- Hits 19127 19120 -7
- Misses 2647 2659 +12
- Partials 1255 1259 +4 ☔ View full report in Codecov by Sentry. 🚀 New features to boost your workflow:
|
2d87081 to
03613bc
Compare
Change-Id: I4d42e16cd420690625342d5097df4dbcae07cb8b
03613bc to
c04fb33
Compare
mrh997
reviewed
May 28, 2026
mrh997
approved these changes
May 28, 2026
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.
Agentic Tool Stream Metadata
Problem
Streamable tool results emitted through the ADK event sender were converted into
AgenticMessagechunks withoutStreamingMeta.Expected behavior:
schema.ConcatAgenticMessagesmaterializes them into one finalfunction_tool_resultblockActual behavior:
function_tool_resultSolution
Mark
AgenticMessagechunks produced bytypedToolStreamEventandtypedToolEnhancedStreamEventwithStreamingMeta{Index: 0}.This matches the existing
AgenticToolsNode.Streambehavior and givesschema.ConcatAgenticMessagesthe grouping signal it needs. The final materialized message still drops transientStreamingMeta; it only uses the metadata while concatenating stream chunks.Key Insight
There are two Agentic tool streaming producers:
AgenticToolsNode.Stream, which already attachesStreamingMetaStreamingMetaStreamingMetais not persisted as final message state. It is a transient stream-concat hint used before materialization.Summary
StreamingMetaStreamingMeta{Index: 0}intypedToolStreamEventStreamingMeta{Index: 0}intypedToolEnhancedStreamEventAgentic 工具流式元数据
问题
ADK event sender 发出的 Streamable tool result 会被转换成
AgenticMessagechunk,但这些 chunk 没有StreamingMeta。预期行为:
schema.ConcatAgenticMessages将它们物化成一个最终的function_tool_resultblock实际行为:
function_tool_result解决方案
在
typedToolStreamEvent和typedToolEnhancedStreamEvent生成的AgenticMessagechunk 上设置StreamingMeta{Index: 0}。这与现有
AgenticToolsNode.Stream行为保持一致,并为schema.ConcatAgenticMessages提供正确的分组信号。最终物化后的 message 仍然不会保留临时的StreamingMeta;它只在流式 chunk 拼接阶段使用。关键洞察
Agentic tool streaming 有两个生产者:
AgenticToolsNode.Stream,它已经会设置StreamingMetaStreamingMetaStreamingMeta不是最终消息状态的一部分。它是物化前用于 stream concat 的临时分组信号。总结
StreamingMetatypedToolStreamEvent中设置StreamingMeta{Index: 0}typedToolEnhancedStreamEvent中设置StreamingMeta{Index: 0}