Skip to main content

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://app.prefactorai.com",
    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

Metadata

Release files for prefactor-livekit 0.1.5

For a detailed explanation of source distributions (sdists) and built distributions (wheels), please see the package formats documentation.

Source distribution (sdist)

Source distribution for prefactor-livekit 0.1.5
File Size Uploaded
prefactor_livekit-0.1.5.tar.gz 21.7 kB Details

Built distribution (wheel)

Table of built distributions (wheels) for prefactor-livekit 0.1.5
File Interpreter ABI Platform
prefactor_livekit-0.1.5-py3-none-any.whl Python 3 none any Details

Total release size: 35.5 kB

Release files / prefactor_livekit-0.1.5.tar.gz

Download URL prefactor_livekit-0.1.5.tar.gz
Size 21.7 kB
Tags Source
SHA-256 checksum
How to use checksums
d413125708fbf993f48b8247d88f24d0bbd224ae34c5734145ae7fe0571cd19e
BLAKE2b-256 checksum
How to use checksums
aa2e3c08cf80f278f3fea3297b10b6c8286b3b452f2f8dd6618d621ce7682198
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
No
Uploaded via uv/0.11.28 {"installer":{"name":"uv","version":"0.11.28","subcommand":["publish"]},"python":null,"implementation":{"name":null,"version":null},"distro":{"name":"Ubuntu","version":"26.04","id":"resolute","libc":null},"system":{"name":null,"release":null},"cpu":null,"openssl_version":null,"setuptools_version":null,"rustc_version":null,"ci":null}

Release files / prefactor_livekit-0.1.5-py3-none-any.whl

Download URL prefactor_livekit-0.1.5-py3-none-any.whl
Size 13.7 kB
Tags Python 3
SHA-256 checksum
How to use checksums
b3c661ac646dcfac808b79403aa64b71780a533ff5b56b6d84f52935476b7e7f
BLAKE2b-256 checksum
How to use checksums
e81a11243368f3a6d09fb0ede1f9d2b63411170f138f2268862b3d93350afa03
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
No
Uploaded via uv/0.11.28 {"installer":{"name":"uv","version":"0.11.28","subcommand":["publish"]},"python":null,"implementation":{"name":null,"version":null},"distro":{"name":"Ubuntu","version":"26.04","id":"resolute","libc":null},"system":{"name":null,"release":null},"cpu":null,"openssl_version":null,"setuptools_version":null,"rustc_version":null,"ci":null}

Release history Release notifications | RSS feed

This release

0.1.5 This release

2 release files

0.1.4

2 release files

0.1.3

2 release files

0.1.2

2 release files

0.1.1

2 release files

0.1.0

2 release files

Anthropic, PBC Visionary sponsor Bloomberg Visionary sponsor Hudson River Trading Visionary sponsor Meta Visionary sponsor NVIDIA Visionary sponsor Microsoft Sustainability sponsor Depot Continuous Integration AWS Cloud computing and Security Sponsor Datadog Monitoring Fastly CDN Google Download Analytics Sentry Error logging StatusPage Status page