Agents

AgentServer

View as MarkdownOpen in Claude

AgentServer hosts multiple AgentBase instances on a single FastAPI process. Each agent registers at its own URL route, and the server provides unified health monitoring, SIP-based routing, and static file serving. Use AgentServer when you have several related agents (sales, support, billing) that share the same deployment environment.

For a single agent, use AgentBase.serve() or AgentBase.run() instead.

Properties

app
FastAPI

The underlying FastAPI application. Use this to add custom routes, middleware, or to run the server with an external ASGI server like gunicorn.

agents
dict[str, AgentBase]

Dictionary mapping route strings to registered AgentBase instances.

host
str

The host address the server binds to.

port
int

The port the server listens on.

log_level
str

The logging level for the server.

Methods

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.add_language("English", "en-US", "rime.spore")
8 self.prompt_add_section("Role", "You are a sales representative.")
9
10class SupportAgent(AgentBase):
11 def __init__(self):
12 super().__init__(name="support-agent", route="/support")
13 self.add_language("English", "en-US", "rime.spore")
14 self.prompt_add_section("Role", "You are a support specialist.")
15
16if __name__ == "__main__":
17 server = AgentServer(host="0.0.0.0", port=3000)
18 server.register(SalesAgent(), "/sales")
19 server.register(SupportAgent(), "/support")
20 server.run()

After starting, agents are available at:

EndpointDescription
http://localhost:3000/salesSales agent
http://localhost:3000/supportSupport agent
http://localhost:3000/healthHealth check
http://localhost:3000/readyReadiness check