Skip to content

FallbackPool

Defined in: core/src/fallback.ts:190

Ordered candidates with cooldowns shared across calls. Keep one pool alive per credential set: rebuilding it per request forgets a weekly lockout. State is in-memory and process-local; status and reset expose it without a background timer, vendor SDK, database or global singleton.

Type Parameter
T
new FallbackPool<T>(candidates, options?): FallbackPool<T>;

Defined in: core/src/fallback.ts:196

Parameter Type
candidates readonly T[]
options FallbackOptions<T>

FallbackPool<T>

reset(...selection): void;

Defined in: core/src/fallback.ts:224

Clear a cooldown after replacing a key or fixing configuration. Omit the candidate to clear all of this pool’s own; a shared store keeps the benches of candidates only other pools hold. Does not interrupt calls in flight.

Parameter Type
…selection [] | [T]

void


status(): object[];

Defined in: core/src/fallback.ts:230

object[]


stream<R>(
attempt,
signal?,
opts?
): AsyncGenerator<R>;

Defined in: core/src/fallback.ts:266

Only a pre-output failure can switch provider. A later failure still cools the endpoint for FUTURE calls but never restarts the current answer. maxAttempts counts callback invocations, not cooled candidates or waits for a probe. Each nested recovery layer has its own limit.

Type Parameter
R
Parameter Type
attempt (candidate, signal) => AsyncIterable<R>
signal? AbortSignal
opts? Pick<StreamOptions, "maxAttempts">

AsyncGenerator<R>


with<R>(
attempt,
signal?,
opts?
): Promise<R>;

Defined in: core/src/fallback.ts:246

Buffered calls only: do not wrap an agent turn that has run side effects.

Type Parameter
R
Parameter Type
attempt (candidate, signal) => Promise<R>
signal? AbortSignal
opts? Pick<StreamOptions, "maxAttempts">

Promise<R>