Skip to content

Realtime models: OTel span misses input/output or usage on realtime_inference span, no user input on agent_turn span #7304

Description

@jannikmaierhoefer

Bug Description

With a realtime model (tested with GPTLiveModel, same code path as RealtimeModel), the spans from livekit-agents 1.8.x are missing most of the conversation content. A GenAI backend shows every turn as an empty generation with no cost.

The cascaded pipeline path is fine. llm_request gets gen_ai.input.messages, gen_ai.output.messages and usage, and agent_turn gets lk.pii.instructions and lk.pii.user_input. The realtime path never calls the content helpers.

What's missing

Span Has today Missing
realtime_inference (generate_content) provider, model, gen_ai.output.type, conversation id gen_ai.input.messages, gen_ai.output.messages, gen_ai.system_instructions, usage
agent_turn (invoke_agent) lk.pii.response.text, lk.pii.response.function_calls lk.pii.user_input, lk.pii.instructions

The user's transcript is on no span at all. Only user_speaking debug spans, without text.

Usage: GPT-Live's backend model (gpt-5.6-luna, ~1.4k prompt / 74 completion tokens per turn) is emitted as LLMMetrics on metrics_collected but never attached to a span. The voice model's RealtimeModelMetrics reports zero tokens (billed by duration), so realtime_inference has no usage even when record_realtime_metrics matches.

Expected Behavior

Parity with the pipeline path: realtime_inference carries input/output messages, system instructions and usage; agent_turn carries lk.pii.user_input and lk.pii.instructions.

Happy to send a PR. Rough shape: reuse to_input_messages / to_output_messages from telemetry/gen_ai.py on the realtime chat context, and attach the backend LLMMetrics to the pending realtime_inference span by response.id.

Reproduction Steps

1. `AgentSession(llm=GPTLiveModel(...))` with one function tool, `set_tracer_provider(provider)` with any OTLP exporter. `OTEL_INSTRUMENTATION_GENAI_CAPTURE_MESSAGE_CONTENT` unset (defaults on), no redaction.
2. Short conversation with one tool call.
3. Look at the spans.

Real example, the Langfuse voice demo (https://langfuse.com/docs/demo) runs exactly this setup. Public trace: https://cloud.langfuse.com/project/clkpwwm0m000gmm094odg11gi/traces/738d3c599f6071781340ebe0ead4054c?observation=ca5d2ea847dfef01

`realtime_inference` there carries only `gen_ai.operation.name=generate_content`, `gen_ai.provider.name=openai`, `gen_ai.request.model=gpt-live-1`, `gen_ai.request.stream=true`, `gen_ai.output.type=speech`, `gen_ai.conversation.id`. `agent_turn` has `lk.pii.response.text` and nothing about the user.

Operating System

MacOS

Models Used

No response

Package Versions

livekit-agents 1.8.1, livekit-plugins-openai 1.8.1, exporter is the Langfuse Python SDK. Same on `main` today.

Session/Room/Call IDs

No response

Proposed Solution

Additional Context

No response

Screenshots and Recordings

Image

Activity

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

No one assigned

    Labels

    bugSomething isn't working

    Type

    No type

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions