Skip to main content

Module router

Module router 

Source
Expand description

Agent router — selects the best agent and model for each task.

The router uses LLM-based classification to route tasks to the best agent (claude, codex, opencode, kimi, or minimax) based on task content, labels, and configured routing rules. It also generates a specialized agent profile.

Routing logic (in priority order):

  1. Check for agent:* label on task — use that agent directly
  2. If weighted_round_robin enabled, select by capacity-weighted probability
  3. If round_robin mode, cycle through agents (stateful, skips last-used)
  4. Call LLM classifier for intelligent routing
  5. After N LLM failures, fall back to round-robin
  6. Track last routed agent to distribute load across agents

Re-exports§

pub use config::parse_pool_entry;
pub use config::RouterConfig;
pub use weights::AgentWeights;

Modules§

config
Router configuration — loading, defaults, and model map.
weights
Per-agent routing weights and rate-limit recovery.

Structs§

AgentProfile
Specialized agent profile for a task.
LlmRouterHandle
An opaque, cheaply-cloneable handle to the LLM routing subsystem.
RouteResult
Result of routing a task to an agent.
Router
The agent router.

Enums§

AllAgentsCooledError
Error returned when all agents/models are in cooldown and routing is temporarily unavailable.
RouteResultError
Typed error returned by get_route_result.

Functions§

get_route_result
Retrieve routing result from the task store.