Skip to content

RoutingStrategy

Defined in: src/models/routing/strategy.ts:32

Chooses a configured routing candidate.

select(context): Promise<RoutingCandidate>;

Defined in: src/models/routing/strategy.ts:52

Select a candidate from context.candidates, or decline with undefined.

The router asks before the first model call with an empty attempt history, then after unclaimed failures until routing stops. The returned candidate must be the same instance as one in context.candidates.

Declining the opening selection uses the router’s default model. Declining after a failure ends routing and preserves the pending model error. During opening selection, strategy errors, invalid candidates, and candidate-resolution errors propagate. After a model failure, strategy errors and invalid candidates end routing without replacing the pending error.

Each failure round may use a candidate once. Returning a candidate already used in the current round ends routing. If a nested candidate cannot resolve after a failure, it consumes its round slot and the strategy is asked again.

ParameterTypeDescription
contextRoutingContextCurrent request and chronological routing history

Promise<RoutingCandidate>

A configured candidate, or undefined to decline