prefactor_livekit.session module
prefactor_livekit.session module
Section titled “prefactor_livekit.session module”LiveKit session wrapper for Prefactor observability.
class prefactor_livekit.session.PrefactorLiveKitSession(client: PrefactorCoreClient | None = None, agent_id: str | None = None, agent_name: str | None = None, instance: AgentInstanceHandle | None = None, tool_schemas: Mapping[str, LiveKitToolSchemaConfig | Mapping[str, Any]] | None = None)
Section titled “class prefactor_livekit.session.PrefactorLiveKitSession(client: PrefactorCoreClient | None = None, agent_id: str | None = None, agent_name: str | None = None, instance: AgentInstanceHandle | None = None, tool_schemas: Mapping[str, LiveKitToolSchemaConfig | Mapping[str, Any]] | None = None)”Bases: object
High-level LiveKit session wrapper for Prefactor tracing.
async attach(session: AgentSession[Any]) → AgentInstanceHandle
Section titled “async attach(session: AgentSession[Any]) → AgentInstanceHandle”Attach to an existing LiveKit session.
async close() → None
Section titled “async close() → None”Flush pending tasks and release wrapper-owned resources.
static create_client(config: PrefactorCoreConfig) → PrefactorCoreClient
Section titled “static create_client(config: PrefactorCoreConfig) → PrefactorCoreClient”Create a PrefactorCoreClient configured for use with this adaptor.
Use this when you need to manage the client and instance lifecycle
yourself (e.g. to share a client between the session wrapper and
other code) instead of letting from_config() manage them for you.
- Parameters: config – Core configuration for the client.
- Returns:
A PrefactorCoreClient ready for
await client.initialize().
Example
Section titled “Example”config = PrefactorCoreConfig(http_config=…) client = PrefactorLiveKitSession.create_client(config) await client.initialize()
instance = await client.create_agent_instance( : agent_id=”my-agent”, agent_version={“name”: “My Agent”}, agent_schema_version=…,
) session = PrefactorLiveKitSession(instance=instance)
async ensure_initialized() → AgentInstanceHandle
Section titled “async ensure_initialized() → AgentInstanceHandle”Initialize and return the active Prefactor instance.
classmethod from_config(api_url: str, api_token: str, agent_id: str | None = None, agent_name: str | None = None, schema_registry: SchemaRegistry | None = None, include_livekit_schemas: bool = True, tool_schemas: Mapping[str, LiveKitToolSchemaConfig | Mapping[str, Any]] | None = None) → PrefactorLiveKitSession
Section titled “classmethod from_config(api_url: str, api_token: str, agent_id: str | None = None, agent_name: str | None = None, schema_registry: SchemaRegistry | None = None, include_livekit_schemas: bool = True, tool_schemas: Mapping[str, LiveKitToolSchemaConfig | Mapping[str, Any]] | None = None) → PrefactorLiveKitSession”Create a wrapper from raw configuration.
async start(session: AgentSession[Any], agent: Agent, **kwargs: Any) → Any
Section titled “async start(session: AgentSession[Any], agent: Agent, **kwargs: Any) → Any”Attach and delegate to AgentSession.start().