Skip to main content

Module routing

Module routing 

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

ClassifierStrategy
Chooses the opening candidate by asking a classifier model (ClassifierStrategy).
ClassifierStrategyOptions
Options of a ClassifierStrategy (ClassifierStrategyOptions).
FallbackStrategy
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.
ModelRouter
Routes each invocation among a fixed set of candidate models (ModelRouter).
ModelRouterOptions
Options of a ModelRouter (ModelRouterOptions).
RoutingAttempt
A candidate used during an invocation and how that attempt went (RoutingAttempt).
RoutingCandidate
A model or nested router with optional evidence for strategies (RoutingCandidate).
RoutingCandidateOptions
How to build a RoutingCandidate (RoutingCandidateOptions): new and the with_* setters, or the builder.
RoutingContext
What a strategy reads to choose a candidate (RoutingContext): copies of the request, the configured candidates and the attempts of this invocation.
RoutingFailure
What failed on a RoutingAttempt: the error’s name and message.

Enums§

CandidateModel
What a candidate routes to: a concrete model, or a nested router used as one opaque candidate.

Traits§

RoutingStrategy
Chooses a configured candidate (RoutingStrategy).