Public declaration syntax from forge-rs/crates/forge-core/src/routing.rs Original source SHA-256: 84b98a249edcdb6b5b15b3932b1fe9c49f3d9f982d4dc4ebcda98d9ecc647fd1 Function bodies and constant values are omitted. This is not the complete implementation. Source line 78 #[derive(Debug, Clone, Copy, PartialEq, Eq, Hash, Serialize, Deserialize)] #[serde(rename_all = "snake_case")] pub enum TaskMode { /// Strategic reasoning, goal decomposition, plan generation. Planning, /// Direct task execution (code generation, content creation, data processing). Execution, /// Reviewing, grading, or verifying outputs from prior steps. Evaluation, /// Condensing, abstracting, or reformatting prior outputs. Summarization, } Source line 97 pub fn as_role_name(&self) -> &'static str; Source line 124 #[derive(Debug, Clone, Copy, Default, PartialEq, Eq, Hash, Serialize, Deserialize)] #[serde(rename_all = "snake_case")] pub enum ExecutionTopology { /// A single sequential call. #[default] Sequential, /// One of N parallel calls that will be aggregated. ParallelFanOut, /// The aggregation call after a fan-out completes. FanIn, /// A call within a retry/fallback chain. Retry, } Source line 162 #[derive(Debug, Clone, Default, Serialize, Deserialize)] pub struct RoutingContext { /// The domain classification for this call. /// /// Examples: "code", "math", "creative", "analysis", "general". /// When `None`, the router does not attempt domain-based matching. #[serde(default, skip_serializing_if = "Option::is_none")] pub domain: Option, /// The task mode for this call. /// /// When `None`, the router does not attempt task-mode-based matching. #[serde(default, skip_serializing_if = "Option::is_none")] pub task_mode: Option, /// The execution topology for this call. /// /// Describes how this inference call relates to other concurrent calls. /// When `None`, defaults to `Sequential`. #[serde(default, skip_serializing_if = "Option::is_none")] pub execution_topology: Option, /// Tool capabilities required for the model selected by this route. /// /// Specific tool names that must be callable. The router may use this /// information to select a model that supports the required tools. #[serde(default, skip_serializing_if = "Vec::is_empty")] pub tool_requirements: Vec, /// Explicit role override. /// /// When set, the router returns the slot with this role name without /// applying strategy logic. Analogous to `tier_override` in the /// Aut0 Router. #[serde(default, skip_serializing_if = "Option::is_none")] pub role_override: Option } Source line 222 #[derive(Debug, Clone, Serialize, Deserialize)] pub struct ResolvedRoute { /// The role name of the selected slot. pub slot_role: String, /// The specific `ProviderRef` to use (primary or one of the fallbacks). pub provider: ProviderRef, /// The model capabilities of the selected provider. pub model_capabilities: ModelCapabilities, /// Whether a fallback model was selected instead of the primary. pub fallback_used: bool } Source line 268 pub trait ModelRouter: Send + Sync { /// Returns the name of this routing strategy (for telemetry and debugging). fn name(&self) -> &str; /// Selects a slot from the topology. /// /// The router must return a `ResolvedRoute` that references a slot present /// in the topology. Returning a role name that does not exist in the /// topology is a routing error. /// /// # Arguments /// /// * `context` - The routing context describing the current task. /// * `topology` - The model topology to select from. /// /// # Returns /// /// A `ResolvedRoute` identifying the selected slot and provider. /// /// # Errors /// /// Returns `ForgeError` if routing fails (e.g., requested role not found). fn route( &self, context: &RoutingContext, topology: &ModelTopology, ) -> ForgeResult; } Source line 343 pub struct DefaultModelRouter;