i need to collect metric, I want to collect the st...
# ask-ai
r
i need to collect metric, I want to collect the stt response i.e. what user said and llm response i.e. what agent said to keep track of turn wise conversation history how can I acheive that. what to save in csv file
t
Thanks for reaching out, Riddhi. I'm an AI assistant and I'm here to help. Give me a moment while I research this topic.
To collect turn-wise conversation history of both user (STT response) and agent (LLM response), use event listeners (such as
user_input_transcribed
,
user_speech_committed
, and
agent_stopped_speaking
) to capture each exchange in real-time. Alternatively, access the session history via the
session.history
property at any point, or persist the full history using a shutdown callback when the session ends. For CSV storage, it's recommended to include for each turn: • timestamp – when the message occurred • session_id – conversation/session identifier • turn_id – sequential turn number • speaker_type – 'user' or 'agent' • content – transcript or LLM reply • is_final – if the transcript is final (for STT) • confidence_score – STT confidence (if available) Additional columns can include
speaker_id
,
message_id
,
model_used
, response time, etc. This structure enables comprehensive turn-wise tracking and later analysis of interaction quality and flow. For implementation examples—such as real-time collection, session shutdown handling, and CSV modifications—refer to the survey caller and transcriber examples within the documentation. Sources: Session recording and transcripts | LiveKit Docs | complex-agents/turn-taking/README.md | Recording agent sessions | LiveKit Docs | livekit-agents/livekit/agents/voice/agent.py