otelMiddleware: media generation spans never capture prompt, input media or output, even with captureContent
Los mantenedores suelen responder en 1 día
@AlemTuzlak ya está trabajando en esto.
Desde el 27/9/2026.
Evaluación
Este issue todavía no se ha evaluado.
Descripción
Summary
otelMiddleware opens one CLIENT span for each media activity call (generateImage, generateVideo, generateAudio, generateSpeech, generateTranscription, …), added via #720. That span carries the provider, the model, the operation name and usage. It never records what was asked for or what came back, even with captureContent: true:
- no prompt
- no input media: reference images, start and end frames, source audio for transcription
- no output: generated image, video or audio URLs, or the transcript text
In PostHog, Langfuse or Datadog every media generation therefore shows up as an empty Input/Output pair with a cost attached. For image-to-video or reference-to-video, where the result depends mostly on the input images, there is nothing in the trace to debug from.
Root cause
startMediaSpan / endMediaSpan (packages/ai/src/middlewares/otel.ts:343–384) only set gen_ai.system, gen_ai.operation.name, gen_ai.request.model and usage. captureContent is only checked on the chat paths.
The inputs are already on the context: GenerationMiddlewareContext.artifactInputs holds the activity inputs. The media path never reads it, and the result is never inspected in the terminal hook.
The only workaround is attributeEnricher / onSpanEnd in every app, reimplementing the per-activity input and output shapes that the library already knows.
Proposal
When captureContent is on, the media span writes the same attributes the chat iteration spans do:
gen_ai.input.messages/langfuse.observation.input: the prompt as a text part, plus each input media reference as a URI part ({ type: 'uri', modality, uri }), reusing whatever part serialisation #1525 lands on.gen_ai.output.messages/langfuse.observation.output: output media URLs as URI parts, and transcript text as a text part.- Inline or base64 inputs and outputs follow the same rule as #1525: a placeholder by default, and an opt-in hook to swap in a URL.
redactandmaxContentLengthstill apply.
Related
- #720: added the media span (closed)
- #1525:
captureContentdrops non-text parts on chat spans
Version
@tanstack/ai 0.58.0 (current main has the same code).
I'm happy to open a PR.
- Lenguaje dominante
- TypeScript
- Estrellas
- 3.1k
- Forks
- 340
- Merge medio
- 2 d 7 h
- PR fusionados (30 d)
- 175
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
-
Dificultad 4/5 3-5 días Aptitud para principiantes 68/100
Los mantenedores suelen responder en 1 día
-
signin with openaiAbierto
Dificultad 5/5 Más de una semana Aptitud para principiantes 45/100
Los mantenedores suelen responder en 1 día
-
update elevenlabsPosiblemente ocupada @tombeckenham la tomó hace 1 día. Abiertohas-pr waiting-on: maintainer
Dificultad 4/5 3-5 días Aptitud para principiantes 25/100
TanStack/ai#1564 · 1 asignado ·
Los mantenedores suelen responder en 1 día
-
onAfterToolCall failure records a second, contradictory result for a successful server toolPosiblemente ocupada @AlemTuzlak la tomó hace 1 día. Abiertohas-pr waiting-on: maintainer
TanStack/ai#1558 · 1 asignado ·
Los mantenedores suelen responder en 1 día
-
SSE and NDJSON response streams drain unread sources without backpressurePosiblemente ocupada @tombeckenham la tomó hace 1 día. Abiertohas-pr waiting-on: maintainer
TanStack/ai#1556 · 1 asignado ·
Los mantenedores suelen responder en 1 día
Todos los issues de TanStack/ai
Issues similares
-
Mend: dependency security vulnerability untriaged
Dificultad 2/5 1-3 horas Aptitud para principiantes 68/100
opensearch-project/security-dashboards-plugin#2545 ·
Los mantenedores suelen responder en 1 día
-
Add: Dream TR SDAbiertocheck:passed streams:add
Dificultad 2/5 1-3 horas Aptitud para principiantes 70/100
Los mantenedores suelen responder en 1 día
-
doctor integrity sample scans soft-deleted pages on Postgres (batch path has no deleted_at filter)Abierto
Dificultad 2/5 1-3 horas Aptitud para principiantes 88/100
Los mantenedores suelen responder en 1 día
-
Dificultad 1/5 Menos de una hora Aptitud para principiantes 72/100
SocialGouv/egapro#4672 · 1 comentario ·
Los mantenedores suelen responder en 2 días
-
area:agents area:tui bug
Dificultad 2/5 1-3 horas Aptitud para principiantes 74/100
anthropics/claude-code#98358 ·
Los mantenedores suelen responder en 1 día