Skip to main content

RouterConfig

Struct RouterConfig 

Source
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: String

Routing 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: String

Which agent performs routing (default: “claude”)

§router_model: String

Model for routing (default: “haiku”)

§timeout_seconds: u64

Timeout for routing LLM call in seconds

§fallback_executor: String

Fallback executor if routing fails

§agents: Vec<String>

Configurable agent list (checked against PATH at runtime)

§max_route_attempts: u32

Max 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: bool

Enable 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: String

Fallback agent:model when all pool entries are cooled or fail. When empty, defaults to router_agent:router_model.

§self_routing_penalty: f64

Penalty 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.02
§skip_limited_threshold: f64

If 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: usize

Maximum 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: String

Ollama base URL for local routing (default: “http://localhost:11434”).

§ollama_model: String

Ollama model name for routing (default: “qwen2.5-coder:3b-instruct”).

§ollama_timeout_seconds: u64

Timeout for Ollama HTTP call in seconds (default: 30).

Implementations§

Source§

impl RouterConfig

Source

pub fn from_config() -> Self

Load configuration from config files.

Source

pub fn effective_pool(&self) -> Vec<String>

Return the effective pool — the configured pool, or a single-entry pool from router_agent:router_model.

Source

pub fn effective_fallback(&self) -> String

Return the effective fallback entry — the configured fallback, or router_agent:router_model.

Source

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.

Source

pub fn has_available_model_for_complexity( &self, agent: &str, complexity: &str, ) -> bool

Source

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

Source§

fn clone(&self) -> Self

Returns a duplicate of the value. Read more
1.0.0 (const: unstable) · Source§

fn clone_from(&mut self, source: &Self)

Performs copy-assignment from source. Read more
Source§

impl Debug for RouterConfig

Source§

fn fmt(&self, f: &mut Formatter<'_>) -> Result

Formats the value using the given formatter. Read more
Source§

impl Default for RouterConfig

Source§

fn default() -> Self

Returns the “default value” for a type. Read more

Auto Trait Implementations§

Blanket Implementations§

Source§

impl<T> Any for T
where T: 'static + ?Sized,

Source§

fn type_id(&self) -> TypeId

Gets the TypeId of self. Read more
Source§

impl<T> Borrow<T> for T
where T: ?Sized,

Source§

fn borrow(&self) -> &T

Immutably borrows from an owned value. Read more
Source§

impl<T> BorrowMut<T> for T
where T: ?Sized,

Source§

fn borrow_mut(&mut self) -> &mut T

Mutably borrows from an owned value. Read more
Source§

impl<T> CloneToUninit for T
where T: Clone,

Source§

unsafe fn clone_to_uninit(&self, dest: *mut u8)

🔬This is a nightly-only experimental API. (clone_to_uninit)
Performs copy-assignment from self to dest. Read more
Source§

impl<T> From<T> for T

Source§

fn from(t: T) -> T

Returns the argument unchanged.

Source§

impl<T> FromRef<T> for T
where T: Clone,

Source§

fn from_ref(input: &T) -> T

Converts to this type from a reference to the input type.
Source§

impl<T> Instrument for T

Source§

fn instrument(self, span: Span) -> Instrumented<Self> ⓘ

Instruments this type with the provided Span, returning an Instrumented wrapper. Read more
Source§

fn in_current_span(self) -> Instrumented<Self> ⓘ

Instruments this type with the current Span, returning an Instrumented wrapper. Read more
Source§

impl<T, U> Into<U> for T
where U: From<T>,

Source§

fn into(self) -> U

Calls U::from(self).

That is, this conversion is whatever the implementation of From<T> for U chooses to do.

Source§

impl<T> IntoEither for T

Source§

fn into_either(self, into_left: bool) -> Either<Self, Self> ⓘ

Converts 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 more
Source§

fn into_either_with<F>(self, into_left: F) -> Either<Self, Self> ⓘ
where F: FnOnce(&Self) -> bool,

Converts 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
Source§

impl<T> PolicyExt for T
where T: ?Sized,

Source§

fn and<P, B, E>(self, other: P) -> And<T, P>
where T: Sized + Policy<B, E>, P: Policy<B, E>,

Create a new Policy that returns Action::Follow only if self and other return Action::Follow. Read more
Source§

fn or<P, B, E>(self, other: P) -> Or<T, P>
where T: Sized + Policy<B, E>, P: Policy<B, E>,

Create a new Policy that returns Action::Follow if either self or other returns Action::Follow. Read more
Source§

impl<T> Same for T

Source§

type Output = T

Should always be Self
Source§

impl<T> ToOwned for T
where T: Clone,

Source§

type Owned = T

The resulting type after obtaining ownership.
Source§

fn to_owned(&self) -> T

Creates owned data from borrowed data, usually by cloning. Read more
Source§

fn clone_into(&self, target: &mut T)

Uses borrowed data to replace owned data, usually by cloning. Read more
Source§

impl<T, U> TryFrom<U> for T
where U: Into<T>,

Source§

type Error = !

The type returned in the event of a conversion error.
Source§

fn try_from(value: U) -> Result<T, !>

Performs the conversion.
Source§

impl<T, U> TryInto<U> for T
where U: TryFrom<T>,

Source§

type Error = <U as TryFrom<T>>::Error

The type returned in the event of a conversion error.
Source§

fn try_into(self) -> Result<U, <U as TryFrom<T>>::Error>

Performs the conversion.
Source§

impl<V, T> VZip<V> for T
where V: MultiLane<T>,

Source§

fn vzip(self) -> V

Source§

impl<T> WithSubscriber for T

Source§

fn with_subscriber<S>(self, subscriber: S) -> WithDispatch<Self> ⓘ
where S: Into<Dispatch>,

Attaches the provided Subscriber to this type, returning a WithDispatch wrapper. Read more
Source§

fn with_current_subscriber(self) -> WithDispatch<Self> ⓘ

Attaches the current default Subscriber to this type, returning a WithDispatch wrapper. Read more