get_agent

View as MarkdownOpen in Claude

Retrieve a specific agent by its route. Returns None if no agent is registered at the given path.

Parameters

route
strRequired

The route to look up (e.g., "/sales"). Leading slashes are added and trailing slashes are stripped automatically for matching.

Returns

AgentBase | None — The agent instance registered at the route, or None if not found.

Example

1from signalwire import AgentServer
2from signalwire import AgentBase
3
4agent1 = AgentBase(name="sales", route="/sales")
5agent2 = AgentBase(name="support", route="/support")
6server = AgentServer(port=3000)
7server.register(agent1)
8agent = server.get_agent("/sales")
9if agent:
10 print(f"Found: {agent.get_name()}")
11else:
12 print("No agent at /sales")