Expand description
Strategy-based model routing.
A ModelRouter passed as the agent’s model asks its RoutingStrategy for a candidate
before the first model call and after each failure no retry strategy claimed. The default
FallbackStrategy fails over to the healthiest untried candidate; ClassifierStrategy
asks a classifier model which candidate fits the request. The API is provisional.
Structs§
- Classifier
Strategy - Chooses the opening candidate by asking a classifier model (
ClassifierStrategy). - Classifier
Strategy Options - Options of a
ClassifierStrategy(ClassifierStrategyOptions). - Fallback
Strategy - Selects the healthiest candidate not yet tried since the last success (
FallbackStrategy): the fewest failures, ties broken by declaration order. A success clears that candidate’s failure count. - Model
Router - Routes each invocation among a fixed set of candidate models (
ModelRouter). - Model
Router Options - Options of a
ModelRouter(ModelRouterOptions). - Routing
Attempt - A candidate used during an invocation and how that attempt went (
RoutingAttempt). - Routing
Candidate - A model or nested router with optional evidence for strategies (
RoutingCandidate). - Routing
Candidate Options - How to build a
RoutingCandidate(RoutingCandidateOptions):newand thewith_*setters, or the builder. - Routing
Context - What a strategy reads to choose a candidate (
RoutingContext): copies of the request, the configured candidates and the attempts of this invocation. - Routing
Failure - What failed on a
RoutingAttempt: the error’s name and message.
Enums§
- Candidate
Model - What a candidate routes to: a concrete model, or a nested router used as one opaque candidate.
Traits§
- Routing
Strategy - Chooses a configured candidate (
RoutingStrategy).