pub struct RouterConfig {Show 21 fields
pub mode: String,
pub router_agent: String,
pub router_model: String,
pub timeout_seconds: u64,
pub fallback_executor: String,
pub agents: Vec<String>,
pub max_route_attempts: u32,
pub allowed_tools: Vec<String>,
pub default_skills: Vec<String>,
pub model_map: HashMap<String, HashMap<String, Vec<String>>>,
pub weighted_round_robin: bool,
pub pool: Vec<String>,
pub fallback: String,
pub self_routing_penalty: f64,
pub weights: HashMap<String, f64>,
pub skip_limited_threshold: f64,
pub agent_backoff_bases: HashMap<String, i64>,
pub max_tasks_per_tick: usize,
pub ollama_url: String,
pub ollama_model: String,
pub ollama_timeout_seconds: u64,
}Expand description
Router configuration.
Fields§
§mode: StringRouting mode: “llm”, “local”, or “round_robin”
- “llm”: Use cloud LLMs for routing (default, supports pool-based routing)
- “local”: Use local Ollama model for routing
- “round_robin”: Distribute tasks evenly across available agents
router_agent: StringWhich agent performs routing (default: “claude”)
router_model: StringModel for routing (default: “haiku”)
timeout_seconds: u64Timeout for routing LLM call in seconds
fallback_executor: StringFallback executor if routing fails
agents: Vec<String>Configurable agent list (checked against PATH at runtime)
max_route_attempts: u32Max LLM routing attempts before falling back to round-robin
allowed_tools: Vec<String>Default tools allowed
default_skills: Vec<String>Default skills to always include
model_map: HashMap<String, HashMap<String, Vec<String>>>Model map for complexity levels.
Each entry is a pool of models; one is selected randomly (skipping cooled ones) per dispatch.
A single-model pool vec!["model"] behaves identically to the old string format.
weighted_round_robin: boolEnable weighted round-robin routing based on rate limit capacity. When true, agents that hit rate limits get fewer tasks.
pool: Vec<String>Pool of agent:model entries to round-robin the router LLM call.
When empty, a single-entry pool is derived from router_agent:router_model.
Special value opencode:free is expanded at startup via opencode models.
fallback: StringFallback agent:model when all pool entries are cooled or fail.
When empty, defaults to router_agent:router_model.
self_routing_penalty: f64Penalty weight applied when the LLM routes a task to itself (the routing agent).
Range: 0.0 (always redirect away from router agent) to 1.0 (no penalty, default).
When < 1.0 and the LLM selects its own agent, the router probabilistically
redirects to another available agent, reducing self-routing bias.
Example: 0.5 means ~50% of self-routed tasks are redirected to another agent.
weights: HashMap<String, f64>Configurable base weights per agent.
Higher weight = more tasks routed to this agent. Agents without an explicit
weight default to 1.0. The weighted selection normalizes these into
probabilities, so {claude: 0.6, minimax: 0.03} means claude gets ~95%
of tasks when both are available.
Set in config.yml under router.weights:
router:
weights:
claude: 0.6
codex: 0.2
opencode: 0.15
minimax: 0.03
kimi: 0.02skip_limited_threshold: f64If an agent’s routing weight falls below this threshold, consider it
degraded and skip it during proactive routing decisions. Value in
0.0..=1.0 where 1.0 means never skip and 0.0 skips only when
weight is exactly zero (practically never). Default: 0.3.
agent_backoff_bases: HashMap<String, i64>Per-agent base backoff overrides (seconds). Agents not listed use the
default BACKOFF_BASE_SECS (5 minutes). Configure as router.backoff_base.{agent}.
Example: set router.backoff_base.opencode: 600 for a 10-minute base
instead of the default 5-minute base (useful for agents with higher
failure rates like opencode at 24.8%).
max_tasks_per_tick: usizeMaximum number of tasks to route per tick. Prevents blocking the tick loop when multiple tasks are queued simultaneously (e.g., cron jobs). Each routing operation involves an LLM call taking 10-45 seconds, so routing N tasks sequentially would block for N×LLM-latency seconds.
Configurable via router.max_tasks_per_tick (default: 1).
ollama_url: StringOllama base URL for local routing (default: “http://localhost:11434”).
ollama_model: StringOllama model name for routing (default: “qwen2.5-coder:3b-instruct”).
ollama_timeout_seconds: u64Timeout for Ollama HTTP call in seconds (default: 30).
Implementations§
Source§impl RouterConfig
impl RouterConfig
Sourcepub fn from_config() -> Self
pub fn from_config() -> Self
Load configuration from config files.
Sourcepub fn effective_pool(&self) -> Vec<String>
pub fn effective_pool(&self) -> Vec<String>
Return the effective pool — the configured pool, or a single-entry pool from router_agent:router_model.
Sourcepub fn effective_fallback(&self) -> String
pub fn effective_fallback(&self) -> String
Return the effective fallback entry — the configured fallback, or router_agent:router_model.
Sourcepub fn normalize_model_identifier(model: &str) -> String
pub fn normalize_model_identifier(model: &str) -> String
Normalize a model identifier by stripping trailing slashes. This is a defense-in-depth measure to handle edge cases where a model string might have been incorrectly formatted.
pub fn has_available_model_for_complexity( &self, agent: &str, complexity: &str, ) -> bool
Sourcepub fn model_for_complexity(
&self,
agent: &str,
complexity: &str,
task_id: &str,
) -> Option<String>
pub fn model_for_complexity( &self, agent: &str, complexity: &str, task_id: &str, ) -> Option<String>
Get the model for a given agent and complexity level.
When the complexity tier has a pool of models, selects randomly using
task_id as an entropy source and skips models currently in cooldown.
Falls back to pool[0] if all models are cooled.
Backward-compatible: a single-model pool always returns that model.
Trait Implementations§
Source§impl Clone for RouterConfig
impl Clone for RouterConfig
Source§impl Debug for RouterConfig
impl Debug for RouterConfig
Auto Trait Implementations§
impl Freeze for RouterConfig
impl RefUnwindSafe for RouterConfig
impl Send for RouterConfig
impl Sync for RouterConfig
impl Unpin for RouterConfig
impl UnsafeUnpin for RouterConfig
impl UnwindSafe for RouterConfig
Blanket Implementations§
Source§impl<T> BorrowMut<T> for Twhere
T: ?Sized,
impl<T> BorrowMut<T> for Twhere
T: ?Sized,
Source§fn borrow_mut(&mut self) -> &mut T
fn borrow_mut(&mut self) -> &mut T
Source§impl<T> CloneToUninit for Twhere
T: Clone,
impl<T> CloneToUninit for Twhere
T: Clone,
Source§impl<T> Instrument for T
impl<T> Instrument for T
Source§fn instrument(self, span: Span) -> Instrumented<Self> ⓘ
fn instrument(self, span: Span) -> Instrumented<Self> ⓘ
Source§fn in_current_span(self) -> Instrumented<Self> ⓘ
fn in_current_span(self) -> Instrumented<Self> ⓘ
Source§impl<T> IntoEither for T
impl<T> IntoEither for T
Source§fn into_either(self, into_left: bool) -> Either<Self, Self> ⓘ
fn into_either(self, into_left: bool) -> Either<Self, Self> ⓘ
self into a Left variant of Either<Self, Self>
if into_left is true.
Converts self into a Right variant of Either<Self, Self>
otherwise. Read moreSource§fn into_either_with<F>(self, into_left: F) -> Either<Self, Self> ⓘ
fn into_either_with<F>(self, into_left: F) -> Either<Self, Self> ⓘ
self into a Left variant of Either<Self, Self>
if into_left(&self) returns true.
Converts self into a Right variant of Either<Self, Self>
otherwise. Read more