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

from signalwire.livewire import Agent, AgentSession, AgentServer, JobContext, function_tool, run_app
@function_tool
def get_weather(city: str) -> str:
"""Get the current weather for a city."""
return f"Sunny in {city}"
server = AgentServer()
@server.rtc_session()
async def entrypoint(ctx: JobContext):
await ctx.connect()
agent = Agent(instructions="You help with weather.", tools=[get_weather])
session = AgentSession()
await session.start(agent, room=ctx.room)
run_app(server)