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 userData?: UserData;
8 voiceOptions?: Partial<VoiceOptions>;
9})
stt
anyDefaults to undefined

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

tts
anyDefaults to undefined

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

llm
anyDefaults to undefined

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
anyDefaults to undefined

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

turnDetection
anyDefaults to undefined

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

userData
UserDataDefaults to {}

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

voiceOptions
Partial<VoiceOptions>Defaults to undefined

Voice configuration (voice, engine, language) passed through to the SignalWire AI config.

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.