Skip to content

[Enhancement] Add structured voice agent session export for post-session analytics #775

Description

@deepgram-robot

Summary

Add a session export capability to the Voice Agent client that captures and structures conversation data — per-turn transcripts, latency metrics (STT/LLM/TTS breakdown), function calls, and audio segment references — as a serializable JSON session object for post-session analytics, quality scoring, and debugging.

Problem it solves

Developers building production voice agents need to analyze conversation quality, debug issues, and track metrics after sessions end. Currently, developers must manually instrument every event callback to collect this data, leading to boilerplate code and inconsistent coverage. A built-in session export would provide structured, complete conversation data without custom instrumentation — enabling post-session analytics dashboards, quality scoring pipelines, compliance review, and debugging workflows out of the box.

Proposed API

from deepgram import DeepgramClient

client = DeepgramClient()
agent = client.agent.websocket.v1()

# ... run voice agent conversation ...

# Export structured session data
session = agent.export_session()

# Access per-turn data
for turn in session.turns:
    print(f"Speaker: {turn.speaker}")
    print(f"Transcript: {turn.transcript}")
    print(f"STT latency: {turn.stt_latency_ms}ms")
    print(f"LLM latency: {turn.llm_latency_ms}ms")
    print(f"TTS latency: {turn.tts_latency_ms}ms")
    print(f"Tools called: {turn.function_calls}")

# Export as JSON for storage
session.to_json("session_export.json")

# Session-level aggregate metrics
print(f"Total turns: {session.total_turns}")
print(f"Avg TTFB: {session.avg_time_to_first_byte_ms}ms")
print(f"Duration: {session.duration_seconds}s")

Acceptance criteria

  • Session export captures per-turn transcripts and speaker attribution
  • Includes per-turn latency breakdown (STT, LLM, TTS components)
  • Captures function call invocations and responses per turn
  • Serializable to JSON for storage and analysis
  • Includes session-level aggregate metrics (total turns, avg latency, duration)
  • Documented with usage example
  • Compatible with existing API

Raised by the DX intelligence system.

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions