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.3

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.3
File Size Uploaded
prefactor_livekit-0.1.3.tar.gz 20.3 kB Details

Built distribution (wheel)

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

Total release size: 33.2 kB

Release files / prefactor_livekit-0.1.3.tar.gz

Download URL prefactor_livekit-0.1.3.tar.gz
Size 20.3 kB
Tags Source
SHA-256 checksum
How to use checksums
2725fef91863d0461a3ee713204394e712baff3f12990738610dd4b7097b4d6f
BLAKE2b-256 checksum
How to use checksums
3ee81f16979d701691aae0b57636effe750d69c7ff18e62499703ffb59abb7bf
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.3-py3-none-any.whl

Download URL prefactor_livekit-0.1.3-py3-none-any.whl
Size 13.0 kB
Tags Python 3
SHA-256 checksum
How to use checksums
608ce517e13d46e4859578dc7439e2b840c9033049cd310c675b3238a0d3810c
BLAKE2b-256 checksum
How to use checksums
5a3125ef8a6bf6cd90c712b5bd7b15c6e8cfb3dcb437dcfad4cfadca46df2d1d
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

0.1.5

2 release files

0.1.4

2 release files

This release

0.1.3 This release

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