IDEN
AI Engineering / RAPIAPP READING

Let the agent think. Put brakes on the bill and retries.

Deadlines, step limits, queues, and fallbacks help protect an app when models and networks stop cooperating.

One chat can set off a lot of work.

A user request may trigger retrieval, several model calls, and external tools. If every layer retries without coordination, load grows faster than the UI suggests. The user clicked once; the backend has thrown its own retry festival. Set a budget per user task, not just per API call.

Set limits for steps, tokens, total time, and actions. Do not assume an agent loop will stop once it has a good answer. The application needs an enforceable stop condition when the model keeps asking for the same tool. Low-value work can sound remarkably productive.

A timeout is not an end-to-end deadline.

A timeout limits one operation. A deadline limits the entire task. Five operations that each take ten seconds can still keep someone waiting well beyond the product target. Propagate remaining time, cancel work that is no longer useful, and cap the queue. An unbounded queue turns a quick failure into a long wait.

In the visual, each attempt takes two seconds with a half-second pause. A six-second deadline allows two complete attempts. Raising the maximum to five does not mean all five may run. This is a simple capacity model with fixed durations, not a real-world latency distribution.

Not every error deserves a retry.

AWS discusses timeouts, backoff, and jitter for transient failures without making overload worse. A validation error usually needs corrected input, not an identical retry. Operations with side effects need a request identity or reconciliation. A timeout does not prove the server failed to act.

For a payment or email, checking status can be safer than retrying immediately. Assign retry ownership so the SDK, gateway, and worker do not all try again. Jitter spreads retry timing. It does not make backend capacity infinite. Test the service contract you actually use.

A fallback needs a product specification.

If a source fails, the app might give a limited answer with an explanation, defer the task, or ask the user to try again. Do not silently switch from a private source to a public one that answers a different question. A fallback model still needs to pass evaluation on the tasks routed to it. A fallback is not an unlimited panic button.

Background work needs a status and a way to retrieve its result. Important actions need explicit confirmation of the outcome. Streaming text can make waiting feel better, but moving text does not prove the task is complete. The answer and side effects still need checking.

Measure successful tasks, not only tokens.

Google SRE explains how overload can trigger cascading failures. Limit concurrency and reduce work when capacity drops. Measure high-percentile latency, task success, tool calls, retries, and cost per successful task. A healthy average can hide a subset of users who wait a very long time.

Prepare runbooks for model timeouts, empty retrieval, tool access denial, and request spikes. Test using controlled fake dependencies. A mature system shows that partial failures do not take the whole service down. Reliability is behavior in a bad situation, not just uptime while everything cooperates.

Example to inspect

Example budget per task
Total deadline: 6 seconds
Attempt limit: enforced by the application
Retry: only transient errors that are safe to retry
Side effect: idempotency key or reconciliation
Done: validated result, not merely text on screen

Exercise: A payment tool times out. May the agent send it again with a new transaction identity?

Answer: No. A timeout does not prove the transaction failed. Check its status or use service-supported idempotency according to the contract.

Three things to keep: The budget includes the model, retrieval, and tools. Assign retry ownership and propagate deadlines. Test overload and fallback with task-level metrics.

Sources: AWS, “Timeouts, retries, and backoff with jitter”; Google SRE, “Addressing cascading failures.” Primary references reviewed 7 November 2026. Explanations, examples, and visuals by RapiApp. The diagram simplifies the issue for learning; assumptions are stated in the article.

Sources

Open the Indonesian version and its original visuals ↗