Voice
Trace a voice bot
Record each turn of a Pipecat or LiveKit Agents bot with its speech-to-text, model and text-to-speech timings, and read the test call's session token so both sides of a call line up.
A voice bot built on Pipecat or LiveKit Agents reports each turn with one call. The call becomes a voice.session trace, and each bot turn a voice.turn span of type agent, from when the bot heard the user start to speak to when it stopped speaking its reply. Turns count from 0 at the first user utterance, so a greeting belongs to no turn. When the user talks over the reply, the turn ends when the bot falls silent, and the next turn has already started.
Both integrations need SDK 0.3.8 or later and evalkit.init() before the call starts. Neither framework's own OpenTelemetry tracing is needed. The names on this page were checked against pipecat-ai 1.15 and livekit-agents 1.8.
Pipecat
Add the observer to the pipeline's worker before it runs; before Pipecat 1.3 the worker is a PipelineTask. The speech-to-text, model and text-to-speech timings come from Pipecat's metrics, so build the worker with enable_metrics=True.
import evalkit
from fastapi import FastAPI, WebSocket
from pipecat.pipeline.worker import PipelineParams, PipelineWorker
from pipecat.runner.utils import parse_telephony_websocket
from pipecat.workers.runner import WorkerRunner
evalkit.init(subscription_key="tk_live_...", service_name="booking-bot")
app = FastAPI()
@app.websocket("/ws")
async def media_stream(websocket: WebSocket):
await websocket.accept()
transport_type, call_data = await parse_telephony_websocket(websocket)
... # build the transport and the pipeline as usual
worker = PipelineWorker(pipeline, params=PipelineParams(enable_metrics=True))
evalkit.instrument_pipecat(worker, websocket=websocket, call_data=call_data)
runner = WorkerRunner()
await runner.add_workers(worker)
await runner.run()instrument_pipecatreturns the observer, orNonewith a warning when the worker cannot take one; the pipeline then runs untraced.- To pass it when you build the worker:
PipelineWorker(pipeline, observers=[evalkit.pipecat_observer(websocket=websocket)]). - Use one observer per call.
- If the bot also turns on Pipecat's own tracing, pass the session token as
PipelineWorker(..., conversation_id=token). Pipecat puts it on its spans asconversation.id, which EvalKit reads as the session too.
LiveKit Agents
Instrument the session before you start it:
import evalkit
from livekit.agents import AgentSession, JobContext
evalkit.init(subscription_key="tk_live_...", service_name="booking-bot")
async def entrypoint(ctx: JobContext):
session = AgentSession(stt=..., llm=..., tts=..., vad=...)
evalkit.instrument_livekit_agents(session)
await session.start(agent=Assistant(), room=ctx.room)The timings come from the messages the session adds to the conversation, ChatMessage.metrics, on LiveKit Agents 1.4 and later. On earlier versions they come from metrics_collected and the user and agent state changes.
What each turn records
| Attribute | Meaning |
|---|---|
evalkit.voice.v1.turn.index | The turn number, from the first user utterance. |
evalkit.voice.v1.user.speech_end_ms | When the bot decided the user had stopped, in ms from the start of its session. |
evalkit.voice.v1.eou.delay_ms | End-of-utterance delay: from the end of the user's speech to that decision. |
evalkit.voice.v1.stt.duration_ms | Speech-to-text time: from the end of speech to the final transcript. |
evalkit.voice.v1.llm.ttft_ms | The model's time to first token. |
evalkit.voice.v1.tts.ttfb_ms | Text-to-speech time to first byte. |
evalkit.voice.v1.interrupted | Whether the user cut the reply off, as the bot saw it. |
evalkit.voice.v1.transcript.user | The bot's speech-to-text of what it heard. |
evalkit.voice.v1.transcript.bot | The text the bot spoke. |
evalkit.voice.v1.session and session.id | The test call's session token, when there is one. |
Where each framework's figure comes from:
| Figure | Pipecat | LiveKit Agents |
|---|---|---|
| When the user stopped | UserStoppedSpeakingFrame | end of speech plus end_of_turn_delay |
| End-of-utterance delay | VAD stop_secs back from VADUserStoppedSpeakingFrame, to the decision | end_of_turn_delay |
| Speech-to-text time | the STT service's TTFB | transcription_delay |
| Model time to first token | the LLM service's TTFB | llm_node_ttft |
| Text-to-speech time to first byte | the TTS service's TTFB | tts_node_ttfb |
| Interrupted | the user started speaking while the bot spoke | the reply's interrupted flag |
| What the user said | TranscriptionFrame | the user's message |
| What the bot said | TTSTextFrame | the reply's message |
Each figure is the first in the turn: a later sentence's speech synthesis, or the model call after a tool call, does not replace it. A figure the framework did not measure is left out:
- Pipecat reports STT, LLM and TTS timings only with
enable_metrics=True. EvalKit logs this once, at the end of a call that had none. - The end-of-utterance delay needs a Pipecat VAD frame that says how much silence it waited for (
stop_secs, Pipecat 1.0 and later). A pipeline that leaves turn detection to its speech-to-text service has none. - Speech-to-speech models, such as OpenAI Realtime and Gemini Live, have no separate STT or TTS step, so those figures are left out on both frameworks.
- LiveKit Agents leaves out the end-of-utterance and transcription figures for a turn whose voice activity detection it found unreliable.
The transcripts are content. capture_content=False drops them, along with the span's prompt and completion, which hold the same text, and a mask hook sees them; see Configuration and privacy. From 0.3.8, capture_content=False also removes the lk.pii.* content attributes from the spans LiveKit Agents sends itself.
Join a test call
Each test call carries a session token, <agentId or sdk>:<runId>:<scenarioId>:<callIndex>. When your bot puts it on its spans as session.id, its trace joins the test call's session, and its turns line up with the caller's by session and time. Neither trace is nested inside the other.
| Where the caller sends it | Format | Pipecat reads it from |
|---|---|---|
the URL's query: ?evalkit_session=<token> | both | websocket= |
customParameters.evalkit_session in the Twilio start message | twilio | call_data= or websocket= |
session in the raw PCM start message | pcm16 | serializer= |
call_data=is whatparse_telephony_websocketreturned, andwebsocket=the socket it read thestartmessage from.serializer=is the transport's serializer, which the observer watches for the raw PCMstartmessage.session_id=on either integration sets the token directly.- A run started with
--session-query-param NAME, or a voice agent with another Session query parameter, sends the URL's token under that name; passquery_param="NAME"to the Pipecat integration. - Send the bot's traces to the Environment the run reports to. A session is read inside one Environment, so a bot that traces elsewhere is not joined.
For a bot that reads the start message itself, these helpers return the token, or None:
token = (
evalkit.voice_session_from_url(websocket.query_params) # or a URL or a query string
or evalkit.voice_session_from_twilio_start(message) # text, bytes or parsed JSON
or evalkit.voice_session_from_pcm16_start(message)
)
evalkit.voice_session_from_start_message(message) # either format's start message
evalkit.voice_session_from_livekit_participant(participant)
handle = evalkit.set_voice_session(token) # the call's session.id from here on, in this task
...
evalkit.clear_voice_session(handle)evalkit.set_voice_session(token) makes the token the session of every span recorded after it in that asyncio task, the model calls and HTTP calls included, and of the tasks it starts. Call it before the pipeline or session starts. It returns a handle for evalkit.clear_voice_session(handle). A value that cannot be a token is ignored: an empty one, one over 512 characters, or one with control characters.
What you see in the console
- Traces marks a bot's own
voice.sessiontrace with avoicebadge and the test caller'svoice.callwithvoice test. Once a loaded row is a voice call, the toolbar has a Voice switch that keeps only voice calls, and the sessions that hold one. - A
voice.sessionroot span's panel has the call summary: the median of each stage (End of utterance, Speech to text, Model first token, Speech first audio) with the slowest one marked, each turn's timings, and the conversation from the transcripts. - A
voice.callroot span's panel has the response delay and talk-over of each turn, measured from the recording, and plays the call, with a link to its scorecard. It says how the caller talked (evalkit.voice.v1.call.mode:scriptedordynamic). - On a goal-based call, each
voice.turnpanel of the test caller shows what the caller heard the bot say (evalkit.voice.v1.transcript.bot) and the caller's thinking time before its line (evalkit.voice.v1.turn.think_ms), marked as the caller's time, not the bot's. The call summary lists the same per turn, beside the conversation. - A test call's session page says which sides are there, for example "both sides are here" or "only the test caller's trace", and has Open call scorecard.
- From a call's page in Simulations → Voice runs, Open trace and Open session lead back to the traces.
The test caller's traces have the service name evalkit-voicetest. To read either side over HTTP, see Trace read API.
Why the frameworks' own spans are not used
Both frameworks have OpenTelemetry tracing, and SyntropyLabs takes OpenTelemetry spans, but neither framework's spans give the turn the test caller measures. Pipecat's tracing is off unless the worker is built with enable_tracing=True, its first turn starts when the pipeline starts, and a turn ends 2.5 seconds after the bot stops unless the user speaks first. LiveKit Agents splits a turn into a user turn and an agent turn, and has renamed its span attributes between minor versions. The observer frames and session events the integrations read carry the times directly and have kept their names across versions.