AgentSession

View as MarkdownOpen in Claude

AgentSession<UserData> is the orchestrator that binds an Agent to the SignalWire platform. When start() is called, it translates the LiveWire agent definition into a SignalWire AgentBase instance, mapping instructions to prompts, tools to SWAIG functions, and LLM model settings to SignalWire AI parameters.

1import { Agent, AgentSession } from '@signalwire/sdk/livewire';
2
3const agent = new Agent({ instructions: 'You are a helpful assistant.' });
4const session = new AgentSession();
5await session.start({ agent });

Constructor

1new AgentSession<UserData>(options?: {
2 stt?: any;
3 tts?: any;
4 llm?: any;
5 vad?: any;
6 turnDetection?: any;
7 tools?: FunctionTool[];
8 mcpServers?: unknown;
9 userData?: UserData;
10 allowInterruptions?: boolean;
11 minInterruptionDuration?: number;
12 minEndpointingDelay?: number;
13 maxEndpointingDelay?: number;
14 maxToolSteps?: number;
15 preemptiveGeneration?: boolean;
16})
stt
any

STT provider instance. Accepted for API compatibility; SignalWire handles speech recognition automatically. Logs an informational message on first use.

tts
any

TTS provider instance. Accepted for API compatibility; SignalWire handles text-to-speech automatically. Logs an informational message on first use.

llm
any

LLM provider or model string. If provided, the model name is extracted (stripping any provider prefix like "openai/") and set on the underlying SignalWire agent.

vad
any

VAD provider instance. Accepted for API compatibility; SignalWire handles voice activity detection automatically.

turnDetection
any

Turn detection configuration. Accepted for API compatibility; SignalWire handles turn detection automatically.

tools
FunctionTool[]

Optional additional tools merged with the agent’s tools when start() is called.

mcpServers
unknown

Accepted for LiveKit parity. MCP servers are not yet supported in LiveWire — logs a one-time advisory and has no effect.

userData
UserDataDefaults to {}

Arbitrary data attached to the session. Accessible from tool handlers via RunContext.userData.

allowInterruptions
booleanDefaults to true

Forwarded to the SignalWire AI params when the session starts.

minInterruptionDuration
numberDefaults to 0.5

Accepted for LiveKit parity. Forwarded to the SignalWire AI params when the session starts.

minEndpointingDelay
numberDefaults to 0.5

Minimum endpointing delay in seconds. Forwarded to the SignalWire AI params when the session starts.

maxEndpointingDelay
numberDefaults to 3.0

Maximum endpointing delay in seconds. Forwarded to the SignalWire AI params when the session starts.

maxToolSteps
numberDefaults to 3

Accepted for LiveKit parity. SignalWire handles tool-execution depth automatically — logs a one-time advisory if set to a non-default value.

preemptiveGeneration
booleanDefaults to false

Accepted for LiveKit parity. Stored on the session but not currently used.

Properties

userData
UserData

Getter/setter for the session’s user data. Defaults to an empty object.

Methods

getSwAgent

1getSwAgent(): AgentBase | undefined

Returns the underlying SignalWire AgentBase instance, or undefined if start() has not been called yet. Useful for testing or advanced configuration.