In Fit Retries Into a Time Budget, you kept every hiker’s wait within eight seconds. When the deadline fires, though, a hiker asking about the Valbrune ford gets an error, even with the wardens’ reports already retrieved.
Here, you’ll build a fallback chain that keeps the assistant answering when its model fails, count who’s served, and evaluate the model that steps in. Start with the chain’s order.
Build the Chain
A fallback chain lists steps that can each succeed where the one before failed:
- The answer role: Today’s model
- The fast role: Another model from the same provider, for when the answer model alone is overloaded or rate limited
- The latest-reports answer: No model, only the retrieved reports under a limited-answer message
A request moves down only on a failure that another step can fix: a timeout, a 429 rate limit, or a 5xx server error, Anthropic’s 529 included. retryable() in model/retry.js already names them, and any other error ends the request:
Most 400s and 401s mean an invalid request or key. Falling back would hide that bug, so the request fails and shows up in your error rate.
Budget stops differ. On December 2, 2026, Anthropic’s spend limit returns a 400, which ends the request and shows up in your error rate. OpenAI’s 429 insufficient_quota causes the fast role to fail too and raises the latest-reports share.
One retry on the answer role takes 3 + 1 + 3 = 7 seconds, leaving the fast role one second. Give the second attempt to the fast role. In model/retry.js, export retryable() and set retries to 0: