---
title: prefactor_livekit.session module
editUrl: true
head: []
template: doc
sidebar:
  hidden: false
  attrs: {}
pagefind: true
draft: false
---

# prefactor_livekit.session module

LiveKit session wrapper for Prefactor observability.

### *class* prefactor_livekit.session.PrefactorLiveKitSession(client: [PrefactorCoreClient](../../core/reference/prefactor_core.client.md#prefactor_core.client.PrefactorCoreClient) | None = None, agent_id: str = 'livekit-agent', agent_name: str | None = None, instance: [AgentInstanceHandle](../../core/reference/prefactor_core.managers.agent_instance.md#prefactor_core.managers.agent_instance.AgentInstanceHandle) | None = None, tool_schemas: Mapping[str, [LiveKitToolSchemaConfig](prefactor_livekit.schemas.md#prefactor_livekit.schemas.LiveKitToolSchemaConfig) | Mapping[str, Any]] | None = None)

Bases: `object`

High-level LiveKit session wrapper for Prefactor tracing.

#### *async* attach(session: AgentSession[Any]) → [AgentInstanceHandle](../../core/reference/prefactor_core.md#prefactor_core.AgentInstanceHandle)

Attach to an existing LiveKit session.

#### *async* close() → None

Flush pending tasks and release wrapper-owned resources.

#### *async* ensure_initialized() → [AgentInstanceHandle](../../core/reference/prefactor_core.managers.agent_instance.md#prefactor_core.managers.agent_instance.AgentInstanceHandle)

Initialize and return the active Prefactor instance.

#### *classmethod* from_config(api_url: str, api_token: str, agent_id: str = 'livekit-agent', agent_name: str | None = None, schema_registry: [SchemaRegistry](../../core/reference/prefactor_core.schema_registry.md#prefactor_core.schema_registry.SchemaRegistry) | None = None, include_livekit_schemas: bool = True, tool_schemas: Mapping[str, [LiveKitToolSchemaConfig](prefactor_livekit.schemas.md#prefactor_livekit.schemas.LiveKitToolSchemaConfig) | Mapping[str, Any]] | None = None) → [PrefactorLiveKitSession](#prefactor_livekit.session.PrefactorLiveKitSession)

Create a wrapper from raw configuration.

#### *async* start(session: AgentSession[Any], agent: Agent, \*\*kwargs: Any) → Any

Attach and delegate to `AgentSession.start()`.