start

View as MarkdownOpen in Claude

Bind an Agent to this session and prepare the underlying SignalWire infrastructure. This translates the agent’s instructions into a prompt, registers tools as SWAIG functions, and maps the LLM model (if provided) to the SignalWire AI model parameter.

Signature

1async start(params: { agent: Agent<UserData>; room?: any }): Promise<void>

Parameters

agent
AgentRequired

The Agent instance to bind to this session.

room
anyDefaults to undefined

A room instance. Accepted for API compatibility with LiveKit.

Returns

Promise<void>

Example

1import { Agent, AgentSession, tool } from '@signalwire/sdk/livewire';
2
3const checkBalance = tool({
4 description: 'Check the balance for an account.',
5 parameters: { accountId: { type: 'string' } },
6 execute: (params) => {
7 return `Account ${params.accountId} has a balance of $150.00.`;
8 },
9});
10
11const agent = new Agent({
12 instructions: 'You are a helpful banking assistant.',
13 tools: { checkBalance },
14});
15
16const session = new AgentSession({ llm: 'gpt-4o' });
17await session.start({ agent });