pub struct CascadeConfig {
pub quality_threshold: f64,
pub max_escalations: u8,
pub classifier_mode: CascadeClassifierMode,
pub window_size: usize,
pub max_cascade_tokens: Option<u32>,
pub cost_tiers: Option<Vec<String>>,
pub judge_timeout_ms: u64,
}Expand description
Configuration for cascade routing (strategy = "cascade").
Cascade routing tries providers in chain order (cheapest first), escalating to the next provider when the response is classified as degenerate (empty, repetitive, incoherent). Chain order determines cost order: first provider = cheapest.
§Limitations
The heuristic classifier detects degenerate outputs only, not semantic failures.
Use classifier_mode = "judge" for semantic quality gating (adds LLM call cost).
Fields§
§quality_threshold: f64Minimum quality score [0.0, 1.0] to accept a response without escalating. Responses scoring below this threshold trigger escalation.
max_escalations: u8Maximum number of quality-based escalations per request. Network/API errors do not count against this budget. Default: 2 (allows up to 3 providers: cheap → mid → expensive).
classifier_mode: CascadeClassifierModeQuality classifier mode: "heuristic" (default) or "judge".
Heuristic is zero-cost but detects only degenerate outputs.
Judge requires a configured summary_model and adds one LLM call per evaluation.
window_size: usizeRolling quality history window size per provider. Default: 50.
max_cascade_tokens: Option<u32>Maximum cumulative input+output tokens across all escalation levels.
When exceeded, returns the best-seen response instead of escalating further.
None disables the budget (unbounded escalation cost).
cost_tiers: Option<Vec<String>>Explicit cost ordering of provider names (cheapest first). When set, cascade routing sorts providers by their position in this list before trying them. Providers not in the list are appended after listed ones in their original chain order. When unset, chain order is used (default behavior).
judge_timeout_ms: u64Hard timeout for the judge LLM call (milliseconds). If the judge does not respond within this budget, the call is treated as a failure and heuristic scoring is used instead. Default: 5000 (5 s).
Trait Implementations§
Source§impl Clone for CascadeConfig
impl Clone for CascadeConfig
Source§fn clone(&self) -> CascadeConfig
fn clone(&self) -> CascadeConfig
1.0.0 (const: unstable) · Source§fn clone_from(&mut self, source: &Self)
fn clone_from(&mut self, source: &Self)
source. Read more