Routing Agents
Learn how to create and configure routing agents to direct tasks to specialized tools and agents
Routing Agents
Routing agents are a special type of agent in Oxy that act as intelligent dispatchers, analyzing incoming tasks and directing them to the most appropriate specialized agent, workflow, or SQL query based on the request content. They serve as the entry point for complex multi-agent systems.
Overview
A routing agent uses vector embeddings and semantic similarity to match user requests with the best available tool. When a task is received, the routing agent:
- Analyzes the Task: Evaluates the user’s request to understand the intent and requirements
- Finds the Best Match: Uses semantic search to identify the most relevant route from available options
- Routes the Task: Forwards the task to the selected specialized agent or tool
- Synthesizes Results: Processes and formats the output from the specialized tool into a coherent response
How Routing Works
Tool Discovery Process
- Semantic Search: Uses vector embeddings to find the most relevant routes for the user’s query
- Tool Resolution: Converts found routes into executable tools (agents, workflows, or SQL queries)
- Execution: The selected tool processes the request
- Result Synthesis: Optionally processes and formats the tool’s output (controlled by
synthesize_results
)
Vector Database Management
Each routing agent maintains its own vector database named {agent_name}-routing
in LanceDB, storing embeddings of available routes for fast semantic similarity matching.
Configuration
Routing agents are defined in .agent.yml
files with type: routing
. Here’s the basic structure:
Required Fields
model
: The LLM model to use for routing decisionstype
: Must be set torouting
to identify this as a routing agent (agent-level field)routes
: Array of paths to agents, workflows, or SQL files that can handle tasks
Optional Fields
route_fallback
: Default agent to use when no specific route matchesreasoning
: Configuration for the reasoning processsystem_instructions
: Custom instructions for the routing behavior (has a default value)embed_model
: Embedding model for semantic similarity (default: “text-embedding-3-small”)n_dims
: Embedding dimensions (default: 512)top_k
: Number of top matches to consider (default: 4)factor
: Scaling factor for similarity scoring (default: 5)table
: Vector database table name (default: “documents”)db_path
: LanceDB database path (default: “.lancedb”)synthesize_results
: Whether to process and format tool outputs (default: true)
Route Types
Agent Routes
Point to other .agent.yml
files for specialized tasks:
Workflow Routes
Include workflow files using glob patterns:
SQL Query Routes
Direct access to SQL files for data queries:
SQL files used in routing must have appropriate database source type metadata to determine which database connection to use. The routing agent automatically detects the database type from the SQL file’s metadata.
Examples
Simple Routing Agent
Here’s a minimal routing agent with just the required fields:
Complete Routing Agent
Here’s a full-featured routing agent with all available configuration options: