Skip to main content

RoutingStrategy

Trait RoutingStrategy 

Source
pub trait RoutingStrategy: Send + Sync {
    // Required method
    fn route(
        &self,
        task: &str,
        agents: &[AgentCapability],
    ) -> (RoutingDecision, ComplexitySignals);
}
Expand description

Pluggable routing strategy for deciding single-agent vs orchestrator dispatch.

Implement this trait to replace the default keyword-based heuristic with domain-specific routing logic (e.g., route to “quoter” when a task mentions pricing, or route to “miner” when it mentions leads).

§Example

struct DomainRouter;

impl RoutingStrategy for DomainRouter {
    fn route(&self, task: &str, agents: &[AgentCapability]) -> (RoutingDecision, ComplexitySignals) {
        if task.contains("pricing") || task.contains("quote") {
            let idx = agents.iter().position(|a| a.name == "quoter").unwrap_or(0);
            return (
                RoutingDecision::SingleAgent { agent_index: idx, reason: "pricing domain" },
                ComplexitySignals::default(),
            );
        }
        // Fallback to default
        KeywordRoutingStrategy.route(task, agents)
    }
}

Required Methods§

Source

fn route( &self, task: &str, agents: &[AgentCapability], ) -> (RoutingDecision, ComplexitySignals)

Analyze a task and decide routing.

Implementors§