Routing & Composition

Fallback Chain

Try a primary handler; on failure or low confidence, fall through to a sequence of fallback handlers.

Problem

When the single primary handler fails, the user sees an outage even though other working handlers exist in the system. When the primary returns a low-confidence answer, the product silently ships a degraded response with no signal that something better could have been tried. Without a defined ordering of handlers and a rule for moving between them, every team improvises on each incident and quality regressions in the primary go unnoticed.

Solution

Define an ordered chain of handlers. Each handler returns either a confident answer or a failure/low-confidence signal. On failure, the next handler runs. Final fallback is a generic 'I don't know' rather than a wrong answer.

When to use

  • Single-handler failure would cascade to the user as an outage.
  • Multiple handlers exist with meaningful differences in capability or cost.
  • Each handler can return a confidence or failure signal that triggers the next.

Open the full interactive page

Diagram, neighbourhood map, code examples, related patterns and full provenance.

Related