Skip to main content

AgentRouter Documentation

Welcome to the AgentRouter SDK documentation! AgentRouter is a powerful Python SDK for building scalable multi-agent applications with hierarchical agent management.

What is AgentRouter?

AgentRouter is an enterprise-grade framework that simplifies the creation and orchestration of complex multi-agent systems. It provides:

  • Hierarchical Agent Management: Create manager and worker agents with unlimited nesting
  • Tool Integration: Easy registration of Python functions as tools with OpenAI-compatible schemas
  • Complete Isolation: Full isolation between agent instances for security and stability
  • Production Ready: Built-in error handling, logging, monitoring, and configurable parameters
  • OpenAI Compatible: Works seamlessly with OpenAI message formats and responses

Why AgentRouter?

Building multi-agent systems is complex. AgentRouter handles the complexity for you:

🚀 Enterprise-Ready

  • Handle millions of requests with isolated agent instances
  • Configurable timeouts, retries, and execution parameters
  • Built-in error handling and recovery mechanisms

🏗️ Flexible Architecture

  • Create deep hierarchies of agents (managers, workers, sub-workers)
  • Share workers across multiple parents for efficiency
  • Dynamic tool registration and execution

🔧 Developer-Friendly

  • Simple, intuitive API design
  • Comprehensive documentation and examples
  • Full type hints and IDE support
  • Zero-overhead tracing and visualization

Core Concepts

Agents

  • Manager Agents: Orchestrate and coordinate multiple worker agents
  • Worker Agents: Specialized agents that perform specific tasks
  • Shared Workers: Reusable workers that can serve multiple parents

Tools

  • Register Python functions as tools with OpenAI-compatible schemas
  • Automatic validation and execution
  • Support for async operations

Workflow

  • Planning Agent: Analyzes tasks and determines whether to call tools or agents
  • Tool and Agent Calls: Generates proper calls with parameters for functions and worker agents
  • Auto-execution: Automatic execution of registered tools and worker agents

Terminology update

  • We now refer to the orchestrator as Planning Agent instead of Plan API
  • We now refer to invocation as Tool and Agent Calls instead of Tool Call API

Quick Example

from agentrouter import ManagerAgent, tool

# Create a manager agent
manager = ManagerAgent(
name="customer_service_manager",
api_key="your-api-key",
model="usf-mini",
backstory="Senior customer service manager",
goal="Resolve customer issues efficiently"
)

# Create a worker
tech_support = manager.create_worker(
name="Technical_Support",
role="Technical Support Specialist"
)

# Define and register a tool
@tool(
schema={
"type": "function",
"function": {
"name": "search_kb",
"description": "Search knowledge base",
"parameters": {
"type": "object",
"properties": {
"query": {"type": "string"}
},
"required": ["query"]
}
}
}
)
def search_kb(query: str):
return {"results": f"Found: {query}"}

tech_support.register_tool(search_kb)

# Execute a task
messages = [{"role": "user", "content": "Help with laptop issue"}]
response = await manager.execute(messages)