Skip to main content

LiveKit Agents integration for Prefactor observability

Project description

prefactor-livekit

LiveKit Agents integration for Prefactor observability. This package wraps livekit-agents sessions and emits Prefactor spans from public LiveKit session events.

Installation

pip install prefactor-livekit

Usage

Factory pattern

from livekit.agents import AgentSession
from prefactor_livekit import PrefactorLiveKitSession

session = AgentSession(...)

tracer = PrefactorLiveKitSession.from_config(
    api_url="https://api.prefactor.ai",
    api_token="your-api-token",
    agent_id="voice-agent",  # Optional for deployment-scoped tokens
    agent_name="Voice Agent",
)

await tracer.start(session=session, agent=my_agent)
await tracer.close()

With a deployment-scoped token you can omit agent_id; the backend derives the agent and environment from the token during registration.

Example runner

The example script has a local smoke mode that emits representative LiveKit session events into Prefactor without needing STT/TTS providers or a room.

uv run python packages/livekit/examples/simple_session.py --mode smoke

It prints the Prefactor instance ID plus ready-to-run Prefactor CLI commands for retrieving the instance and listing spans for the example's time window.

prefactor agent_instances retrieve <instance-id>
prefactor agent_spans list \
  --agent_instance_id <instance-id> \
  --start_time <recent-start-time> \
  --end_time <recent-end-time> \
  --include_summaries

There is also a model-backed mode for a real text turn:

uv run python packages/livekit/examples/simple_session.py \
  --mode live \
  --model anthropic/claude-sonnet-4-5-20250929

Manual attachment

Use this when your app manages the session lifecycle itself and you just want the LiveKit events traced.

from prefactor_livekit import PrefactorLiveKitSession

tracer = PrefactorLiveKitSession(instance=instance)
await tracer.attach(session)

await session.generate_reply(user_input="hello")

await tracer.close()

Traced span types

  • livekit:session
  • livekit:user_turn
  • livekit:assistant_turn
  • livekit:tool
  • livekit:llm
  • livekit:stt
  • livekit:tts
  • livekit:state
  • livekit:error

Development

uv run pytest packages/livekit/tests -v

Project details


Download files

Download the file for your platform. If you're not sure which to choose, learn more about installing packages.

Source Distribution

prefactor_livekit-0.1.2.tar.gz (20.2 kB view details)

Uploaded Source

Built Distribution

If you're not sure about the file name format, learn more about wheel file names.

prefactor_livekit-0.1.2-py3-none-any.whl (13.0 kB view details)

Uploaded Python 3

File details

Details for the file prefactor_livekit-0.1.2.tar.gz.

File metadata

  • Download URL: prefactor_livekit-0.1.2.tar.gz
  • Upload date:
  • Size: 20.2 kB
  • Tags: Source
  • Uploaded using Trusted Publishing? No
  • Uploaded via: uv/0.10.9 {"installer":{"name":"uv","version":"0.10.9","subcommand":["publish"]},"python":null,"implementation":{"name":null,"version":null},"distro":{"name":"macOS","version":null,"id":null,"libc":null},"system":{"name":null,"release":null},"cpu":null,"openssl_version":null,"setuptools_version":null,"rustc_version":null,"ci":null}

File hashes

Hashes for prefactor_livekit-0.1.2.tar.gz
Algorithm Hash digest
SHA256 d794d91690663c980be7a0a05d98f11b7228347c55d8975c23c8c055385b360c
MD5 30b747b087c8be459e4e16d94cacba05
BLAKE2b-256 d85163909984485a6570ae653bc62c4c46475380ae77294132fccc24f4c1a684

See more details on using hashes here.

File details

Details for the file prefactor_livekit-0.1.2-py3-none-any.whl.

File metadata

  • Download URL: prefactor_livekit-0.1.2-py3-none-any.whl
  • Upload date:
  • Size: 13.0 kB
  • Tags: Python 3
  • Uploaded using Trusted Publishing? No
  • Uploaded via: uv/0.10.9 {"installer":{"name":"uv","version":"0.10.9","subcommand":["publish"]},"python":null,"implementation":{"name":null,"version":null},"distro":{"name":"macOS","version":null,"id":null,"libc":null},"system":{"name":null,"release":null},"cpu":null,"openssl_version":null,"setuptools_version":null,"rustc_version":null,"ci":null}

File hashes

Hashes for prefactor_livekit-0.1.2-py3-none-any.whl
Algorithm Hash digest
SHA256 2b8049fa234cabb87555fe3ec51951b943fddcbe83c4b19211dbd3998d9ab27e
MD5 98012b16f6d3dfd7f23233fa09bf858b
BLAKE2b-256 4c71c3d96d6ad50f31b6f98f54ca42e1294aafa9a2379a43643c6cd7a6426731

See more details on using hashes here.

Supported by

AWS Cloud computing and Security Sponsor Datadog Monitoring Depot Continuous Integration Fastly CDN Google Download Analytics Pingdom Monitoring Sentry Error logging StatusPage Status page