AG-UI TOOL_CALL_RESULT metadata is dropped in the live stream reducer
维护者通常 1 天内回复
评估
- 难度
- 2/5
- 预计耗时
- 1-3 小时
- 新手友好度
- 35/100
- Issue 类型
- 缺陷
- 描述清晰度
- 描述清楚
- 活跃度
- 停滞
- 技术栈
- typescript
调研方向
Read packages/ai/src/activities/chat/stream/processor.ts and packages/ai/src/activities/chat/stream/message-updaters.ts, then compare with the snapshot conversion in packages/ai/src/activities/chat/messages.ts. Check the existing tests for live tool result events and add coverage for metadata preservation on creation and update; done means live results retain metadata consistently with hydrated snapshots. An open linked pull request already covers this issue.
由索引模型根据 Issue 内容生成。
描述
Summary
The live AG-UI TOOL_CALL_RESULT handling path drops the event's metadata when constructing the ToolResultPart.
This makes metadata behave inconsistently between live streaming and message snapshot/history hydration: a ToolMessage.metadata received in a MESSAGES_SNAPSHOT can be preserved, but the same metadata delivered on a live TOOL_CALL_RESULT is not available on the resulting UIMessage.parts entry.
Expected behavior
When a TOOL_CALL_RESULT event contains metadata, the resulting ToolResultPart should retain it:
{
type: 'tool-result',
toolCallId: 'call-123',
content: '...',
state: 'complete',
metadata: {
displayType: 'account-assets',
},
}
Actual behavior
In packages/ai/src/activities/chat/stream/processor.ts, handleToolCallResultEvent() receives the full event, but calls updateToolResultPart() without forwarding chunk.metadata.
In packages/ai/src/activities/chat/stream/message-updaters.ts, updateToolResultPart() constructs a ToolResultPart containing content, state, error, and outcome, but does not set metadata.
The public ToolResultPart type in packages/ai/src/types.ts already declares metadata?: Record<string, unknown>, and the snapshot conversion path in packages/ai/src/activities/chat/messages.ts preserves metadata from tool messages. So the type and snapshot path support this field, but the live event reducer currently drops it.
Reproduction
-
Stream an AG-UI
TOOL_CALL_RESULTevent with ametadataobject:{ "type": "TOOL_CALL_RESULT", "messageId": "assistant-1", "toolCallId": "call-123", "content": "{\"ok\":true}", "metadata": { "displayType": "account-assets" } } -
Observe the resulting
UIMessage.partsentry withtype === 'tool-result'. -
The
contentis present, butmetadatais missing.
Suggested fix
Forward the event metadata into updateToolResultPart() and persist it on the created ToolResultPart. Please also consider how metadata should be merged when an existing tool-result part is updated, so an update does not accidentally discard previously stored metadata.
Add a regression test covering:
- Live
TOOL_CALL_RESULT.metadatais retained inToolResultPart.metadata. - Snapshot/history hydration and live streaming produce consistent metadata.
- Updating an existing tool-result part does not unintentionally lose metadata.
Relevant code
- Live event handling
- Tool result updater
- ToolResultPart type
- Snapshot conversion preserves tool message metadata
Thanks!
- 主要语言
- TypeScript
- 星标
- 3.3k
- 派生
- 378
- 平均合并
- 1 天 2 小时
- 30 天内合并 PR
- 254
环境准备
- 没有 Dockerfile 或 Docker Compose 文件
- 有 Pull Request 模板
- 阅读贡献指南
从这里开始
- 先读完整个 Issue,再读项目的贡献指南。
- 在 Issue 下留言说明你要接手 —— 这能避免两个人做同样的事。
- Fork 仓库,在一个分支上完成修改。
- 提交 Pull Request,并在描述里引用这个 Issue 编号。
TanStack/ai 的其他 Issue
-
openai-base: a Responses max_output_tokens cutoff ends as RUN_ERROR without usage instead of finishReason 'length'可能已有人在做 @tombeckenham 于 8 天前认领。 未关闭has-pr waiting-on: maintainer
难度 2/5 1-3 小时 新手友好度 74/100
TanStack/ai#1916 · 1 条评论 · 已指派 1 人 ·
维护者通常 1 天内回复
-
ai-sandbox: encrypt snapshot blobs at rest with an encrypting blob store wrapper可能已有人在做 @AlemTuzlak 于 1 天前认领。 未关闭waiting-on: maintainer
维护者通常 1 天内回复
-
Sandbox takeover: the saved transcript loses everything the first host delivered before the restart可能已有人在做 @tombeckenham 于 1 天前认领。 未关闭waiting-on: maintainer
维护者通常 1 天内回复
-
withSandbox: each run's save drops the harness tool calls of earlier runs可能已有人在做 @tombeckenham 于 1 天前认领。 未关闭has-pr waiting-on: maintainer
维护者通常 1 天内回复
-
ai-compaction: checkpoint never reused when the store returns message keys in another order可能已有人在做 @tombeckenham 于 1 天前认领。 未关闭has-pr waiting-on: maintainer
维护者通常 1 天内回复
相似的 Issue
-
The sample email preview's ResizeObserver is never disconnected and keeps raising errors after leaving Settings可能已有人在做 关联的 PR 仍在进行中或已合并。 未关闭bug
难度 2/5 1-3 小时 新手友好度 82/100
维护者通常 1 天内回复
-
area:ui bug effort:S priority:P2
难度 2/5 1-3 小时 新手友好度 72/100
维护者通常 1 天内回复
-
Typo in WSL project description on Projects page可能已有人在做 @akhil9tiet 今天认领。 未关闭
难度 1/5 1 小时以内 新手友好度 75/100
microsoft/opensource.microsoft.com#1066 · 1 条评论 ·
-
ArcGIS Maps SDK for JavaScript c-carousel calcite-design-tokens enhancement impact - p3 - not time sensitive needs triage
难度 2/5 1-3 小时 新手友好度 68/100
Esri/calcite-design-system#15565 ·
维护者通常 1 天内回复
-
bug
难度 2/5 1-3 小时 新手友好度 68/100
linkwarden/linkwarden#1891 ·
维护者通常 1 天内回复