Agent Fallback Adapter for LLM. Manages multiple LLM instances with automatic fallback when the current LLM fails.

Example

const fallbackLLM = new FallbackAdapter({
llms: [primaryLLM, secondaryLLM, tertiaryLLM],
attemptTimeout: 5.0,
maxRetryPerLLM: 1,
});

Hierarchy (view full)

Constructors

Properties

attemptTimeout: number
llms: llm.LLM[]
maxRetryPerLLM: number
retryInterval: number
retryOnChunkSent: boolean

Accessors

  • get model(): string
  • The model of the instance that serves next (see nextInstance). Spans and metrics read this, so a failover shows the model expected to answer rather than the adapter; the instance that actually served is stamped per request by the stream.

    Returns string

Methods

  • Pre-warm connection to the LLM service.

    Establishes DNS resolution and the TLS connection to the provider before the first inference request, reducing time-to-first-token on the initial reply. Non-blocking (fire-and-forget) and idempotent; calls made after aclose are ignored. Providers enable it by overriding _prewarmImpl.

    Returns void