AG-UI TOOL_CALL_RESULT metadata is dropped in the live stream reducer
Los mantenedores suelen responder en 1 día
Evaluación
- Dificultad
- 2/5
- Tiempo estimado
- 1-3 horas
- Aptitud para principiantes
- 35/100
- Tipo de issue
- Error
- Claridad
- Bien especificado
- Estado de actividad
- Estancado
- Stack tecnológico
- typescript
Línea de trabajo
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.
Escrito por el modelo de indexación a partir del texto del issue.
Descripción
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!
- Lenguaje dominante
- TypeScript
- Estrellas
- 3.3k
- Forks
- 378
- Merge medio
- 1 d 2 h
- PR fusionados (30 d)
- 254
Preparar el entorno
- Sin Dockerfile ni archivo de Docker Compose
- Tiene una plantilla de pull request
- Leer la guía de contribución
Primeros pasos
- Lee el issue completo y luego la guía de contribución del proyecto.
- Comenta en el issue que vas a ocuparte — evita que dos personas hagan lo mismo.
- Haz un fork del repositorio y trabaja en una rama.
- Abre un pull request que haga referencia al número del issue.
Más de TanStack/ai
-
openai-base: a Responses max_output_tokens cutoff ends as RUN_ERROR without usage instead of finishReason 'length'Posiblemente ocupada @tombeckenham la tomó hace 8 días. Abiertohas-pr waiting-on: maintainer
Dificultad 2/5 1-3 horas Aptitud para principiantes 74/100
TanStack/ai#1916 · 1 comentario · 1 asignado ·
Los mantenedores suelen responder en 1 día
-
ai-sandbox: encrypt snapshot blobs at rest with an encrypting blob store wrapperPosiblemente ocupada @AlemTuzlak la tomó hace 1 día. Abiertowaiting-on: maintainer
TanStack/ai#2062 · 1 asignado ·
Los mantenedores suelen responder en 1 día
-
Sandbox takeover: the saved transcript loses everything the first host delivered before the restartPosiblemente ocupada @tombeckenham la tomó hace 1 día. Abiertowaiting-on: maintainer
TanStack/ai#2061 · 1 asignado ·
Los mantenedores suelen responder en 1 día
-
withSandbox: each run's save drops the harness tool calls of earlier runsPosiblemente ocupada @tombeckenham la tomó hace 1 día. Abiertohas-pr waiting-on: maintainer
TanStack/ai#2059 · 1 asignado ·
Los mantenedores suelen responder en 1 día
-
ai-compaction: checkpoint never reused when the store returns message keys in another orderPosiblemente ocupada @tombeckenham la tomó hace 1 día. Abiertohas-pr waiting-on: maintainer
TanStack/ai#2050 · 1 asignado ·
Los mantenedores suelen responder en 1 día
Todos los issues de TanStack/ai
Issues similares
-
The sample email preview's ResizeObserver is never disconnected and keeps raising errors after leaving SettingsPosiblemente ocupada Un pull request vinculado a esta issue está abierto o ya se fusionó. Abiertobug
Dificultad 2/5 1-3 horas Aptitud para principiantes 82/100
Los mantenedores suelen responder en 1 día
-
area:ui bug effort:S priority:P2
Dificultad 2/5 1-3 horas Aptitud para principiantes 72/100
Los mantenedores suelen responder en 1 día
-
Typo in WSL project description on Projects pagePosiblemente ocupada @akhil9tiet la tomó hoy. Abierto
Dificultad 1/5 Menos de una hora Aptitud para principiantes 75/100
microsoft/opensource.microsoft.com#1066 · 1 comentario ·
-
ArcGIS Maps SDK for JavaScript c-carousel calcite-design-tokens enhancement impact - p3 - not time sensitive needs triage
Dificultad 2/5 1-3 horas Aptitud para principiantes 68/100
Esri/calcite-design-system#15565 ·
Los mantenedores suelen responder en 1 día
-
bug
Dificultad 2/5 1-3 horas Aptitud para principiantes 68/100
linkwarden/linkwarden#1891 ·
Los mantenedores suelen responder en 1 día