register

View as MarkdownOpen in Claude

Register an AgentBase instance at a URL route on the server. The agent’s FastAPI router is mounted at the specified prefix so all of its endpoints (SWML, SWAIG, debug, post-prompt) become available under that path.

Registering a duplicate route raises ValueError. Each route can only host one agent.

Parameters

agent
AgentBaseRequired

The agent instance to register. Must be an AgentBase subclass.

route
Optional[str]

URL path prefix for this agent (e.g., "/sales"). If omitted, the agent’s own route property is used. Leading slashes are added and trailing slashes are stripped automatically.

Returns

None

Example

1from signalwire import AgentServer
2from signalwire import AgentBase
3
4class SalesAgent(AgentBase):
5 def __init__(self):
6 super().__init__(name="sales-agent", route="/sales")
7 self.prompt_add_section("Role", "You are a sales rep.")
8
9server = AgentServer(port=3000)
10server.register(SalesAgent(), "/sales")
11server.run()