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 timing parameters to SignalWire AI parameters.

Parameters

agent
AgentRequired

The Agent instance to bind to this session.

room
AnyDefaults to None

A Room instance. Accepted for API compatibility.

record
boolDefaults to False

Whether to record the session. Accepted for API compatibility.

Returns

None

Example

1from signalwire.livewire import Agent, AgentSession, AgentServer, JobContext, function_tool, run_app
2
3@function_tool
4def get_weather(city: str) -> str:
5 """Get the current weather for a city."""
6 return f"Sunny in {city}"
7
8server = AgentServer()
9
10@server.rtc_session()
11async def entrypoint(ctx: JobContext):
12 await ctx.connect()
13 agent = Agent(instructions="You help with weather.", tools=[get_weather])
14 session = AgentSession()
15 await session.start(agent, room=ctx.room)
16
17run_app(server)