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

from signalwire import AgentServer
from signalwire import AgentBase
agent1 = AgentBase(name="sales", route="/sales")
agent2 = AgentBase(name="support", route="/support")
server = AgentServer(port=3000)
server.register(agent1)
agent = server.get_agent("/sales")
if agent:
print(f"Found: {agent.get_name()}")
else:
print("No agent at /sales")