Retry a `FallbackModel` on Temporal unless every model failed with a non-retryable error

Merged
DO
4d ago
+403-19

Written by Claude Code on behalf of @DouweM.

On Temporal, a FallbackModel whose models all failed raises FallbackExceptionGroup out of the model request activity, and every activity retry policy listed that type as non-retryable. So a chain whose models were all rate-limited or briefly unavailable failed the activity on its first attempt, while a single model with the same error is retried by the activity's retry policy.

[!WARNING]
Compatibility impact: On Temporal, a FallbackModel whose models all failed with retryable errors (rate limits, outages, dropped connections) now has its model request activity retried by the activity's retry policy instead of failing at once. With Temporal's default unlimited retry policy, such a chain keeps retrying until a model answers or the activity times out, as a single model already did.

Why this can ship in a minor release: It makes a FallbackModel behave like a single model under the same retry policy, and a chain whose models all rejected the request for good (authentication, quota, context window, a UserError) still fails on its first attempt.

Migration: To keep failing at once, add 'FallbackExceptionGroup' to the retry policy's non_retryable_error_types, or set maximum_attempts.

FallbackExceptionGroup is no longer in the non-retryable list. Instead, the activity raises it as a non-retryable ApplicationError when every error in it is non-retryable: one of the framework's non-retryable errors, or, in a model activity, one of TemporalDurability's non_retryable_model_errors. Otherwise it goes out unchanged and the retry policy retries it. Tool child workflows use the same check. A FallbackExceptionGroup that the ModelFallback capability raises in workflow code still fails the workflow, as before.

Tests (Temporal, in tests/durable_exec/temporal/test_durability.py):

  • A FallbackModel whose models are both unavailable on the first attempt is retried, and answers on the second. It fails on main.
  • A FallbackModel whose models both fail authentication fails on its first attempt, with a non-retryable FallbackExceptionGroup.
  • The pinned retry-policy lists no longer include FallbackExceptionGroup.

Docs: the Temporal page's list of non-retryable errors, with a sentence on the group.

Checklist

  • No breaking changes in accordance with the version policy.
  • Any permitted compatibility impact has a label, warning, migration and release note, and an exact API-check waiver if the gate reports it.
  • PR title is fit for the release changelog.

đŸ¤– Generated with Claude Code


Summary by cubic

Retries a FallbackModel on Temporal when all its models failed, unless every error in the group is non-retryable. Previously a chain whose models were all rate-limited or briefly unavailable failed its model request activity on the first attempt, while a single model with the same error was retried by the activity's retry policy.

  • FallbackExceptionGroup is removed from the pinned non_retryable_error_types lists. The activity raises it as a non-retryable ApplicationError only when every member error is non-retryable, counting the model activity's non_retryable_model_errors, the error types the retry policy names as non-retryable, and an UnsupportedSettingWarning a model raised for a fallback_on that names it; otherwise it goes out unchanged and the retry policy retries it. A group the ModelFallback capability raises in workflow code still fails the workflow, as before.
  • Tool child workflows use the same check, matching group members by class name, as their retry policy matches a lone error.
  • A retried group waits on the retry policy's backoff; it doesn't honor the members' Retry-After as a single rate-limited model does. A ResponseRejected member from a rejected response stays retryable.

Migration

  • To keep failing at once, add FallbackExceptionGroup to the retry policy's non_retryable_error_types, or set maximum_attempts.