Why do we need to compare fallback and retry?
When building an Agent workflow, error handling is an unavoidable step. Whether the LLM call times out, the external API returns an exception, or the tool fails to execute, you need to decide whether to retry (retry) or switch to an alternate path (fallback). Choosing the wrong one can lead to wasted resources, task deadlocks, or inconsistent results. This article is based on actual engineering scenarios to break down the essential differences and applicable boundaries between the two.
The definition and core differences between fallback and retry
Fallback (Downgrade/Backup): Execute a predefined alternative when the primary path fails. For example, after an LLM call returns an empty result, switch to the rules engine to generate a reply; or when the payment service is unavailable, switch to an alternate gateway.
Retry: Repeat the failed operation, expecting to succeed again after temporary failure recovery. For example, exponential backoff retries after a network timeout, or regeneration when the LLM output format is incorrect.
| Dimensions | Fallback | Retry |
|---|---|---|
| Execution Logic | Switch to alternate path | Repeat current path |
| Applicable scenarios | Unrecoverable errors, business blocking is not allowed | Recoverable transient failures |
| Resource consumption | Usually high (requires backup resources) | Possible cumulative number of calls |
| Latency Impact | Switch Time + Alternate Execution | Retry Interval × Number of Times |
| Probability of success | Rely on backup path reliability | Gradual decay or flattening |

Real scenario: Intelligent customer service order query
Suppose an Agent needs to query the order status: first call the new order system, and fallback to the old system if it fails; at the same time, for transient errors such as network timeout, up to 3 retries are used.
Scenario: The new system returns 503 (service overload). At this time, retry will increase the load, and you should fallback directly to the old system. But if the new system returns 429 (current limiting), you can wait and retry. If error types are not distinguished, using all retry may lead to an avalanche; using all fallback may cause the old system to be overwhelmed.
Decision Point: Mechanism must be chosen based on error code and context. In practice, retry is used for client errors (such as timeout, format error), and fallback is used for server errors (such as unavailability, authentication failure).

The easiest pitfall: unlimited retry and implicit fallback
Pit 1: Unlimited retries. A team set up infinite retries on LLM calls. As a result, LLM continued to return exceptions and consumed thousands of yuan in API fees. Correct approach: Set a maximum number of retries (usually 2-3) and an exponential backoff.
Pit 2: Implicit fallback coverage problem. For example, the fallback path is not independently monitored, causing the primary path to silently switch to the backup after a failure. The backup itself is also defective, and users get incorrect results without knowing it. Logs and alarms must also be recorded for the fallback path.
Pit 3: Ignore idempotence. The Retry operation must be idempotent, otherwise repeated execution may result in duplicate orders and duplicate deductions. If the operation is not idempotent, you should give priority to using fallback or designing a deduplication mechanism.
Specific operations: how to choose and implement
- Classification Error Type. Divide errors into transient (retryable) and permanent (fallback required). For example, network timeout and HTTP 503 are considered instantaneous; authentication failure and 404 are considered permanent.
- Set retry strategy. Using exponential backoff + jitter, the maximum number of retries is adjusted according to the service SLA. For LLM calls, 2-3 times, spaced 1-5 seconds apart, are recommended.
- Design fallback path. Ensure that the resources and data of the backup path are independent and monitored in place. For example, when paying, use Alipay and fallback to WeChat Pay (user confirmation is required).
- Combined use. Retry a few times first, and if it still fails, trigger fallback. For example, calling external API: retry 3 times → fallback to cached results.
- Record decision tracks. Write the reason, time, and result of each retry/fallback into the log to facilitate debugging and optimization.
Fallback plan in case of failure
If neither is available or cannot be determined, consider:
- Manual intervention: Mark the task as pending and notify the developer to fix it manually.
- Skip current step: If the business allows, ignore this task and continue to perform subsequent steps.
- Safe Defaults: Return a reasonable default value to avoid interruption of the entire workflow.
Note that the backup solution should also have logs and monitoring and not become a black box.
Conclusion
Fallback and retry are not either/or, but complementary. The correct approach is to use a combination according to the error type and business requirements: retry handles transient faults, and fallback handles persistent faults. At the same time, it is necessary to set boundaries (number of retries, timeout time), monitor fallback paths, and ensure idempotence to make Agent workflow stable and reliable.

No comments yet. Be the first to share your thoughts.