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",
    agent_name="Voice Agent",
)

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

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.1.tar.gz (19.1 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.1-py3-none-any.whl (12.7 kB view details)

Uploaded Python 3

File details

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

File metadata

  • Download URL: prefactor_livekit-0.1.1.tar.gz
  • Upload date:
  • Size: 19.1 kB
  • Tags: Source
  • Uploaded using Trusted Publishing? No
  • Uploaded via: uv/0.9.26 {"installer":{"name":"uv","version":"0.9.26","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.1.tar.gz
Algorithm Hash digest
SHA256 3c2fc64c62f8c9b2448beacbe127e73c8c008330efe8c3e6aedbb10ff1c0349f
MD5 6f2957d668500911f5bee6ab91ba6630
BLAKE2b-256 a511185e5095ab8bf12db68c3e353fb89c49396cd0bdc7ac7857b5f97c5d4f88

See more details on using hashes here.

File details

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

File metadata

  • Download URL: prefactor_livekit-0.1.1-py3-none-any.whl
  • Upload date:
  • Size: 12.7 kB
  • Tags: Python 3
  • Uploaded using Trusted Publishing? No
  • Uploaded via: uv/0.9.26 {"installer":{"name":"uv","version":"0.9.26","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.1-py3-none-any.whl
Algorithm Hash digest
SHA256 5a9e423086cec98bee46fa85e01bd0535ee20695f165d3bc591ae488dea5e500
MD5 489337580a511e093deac6001304aef5
BLAKE2b-256 a22f581822df7cf9a681ff4c511f3f0fc62a3aa46a0a900172b39eaec15c5d0a

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