TL;DR: Enforce the retry boundary in the runtime that executes tools. Classify the failure, preserve the attempt history and choose a safe terminal state. Repeated apologies are not progress, but neither is blindly switching models and repeating an operation whose outcome is unknown.
The execution boundary is the appropriate place to enforce these rules. Teams that own the agent runtime can control tool calls, budgets and terminal states independently of the generated explanation.
Distinguish three common failure paths
A transient read failure may be recoverable under a bounded policy. An authorization failure requires a valid permitted access path; another model does not create permission. A timed-out write can have succeeded remotely even when the client received no confirmation.
Microsoft's retry pattern discusses transient failures and repeated side effects. Decide whether repetition is appropriate before implementing a loop. If the operation's outcome is uncertain, inspect the authoritative state through an authorized readback or use the target's supported idempotency mechanism.
Keep error categories small enough to act on. Do not send raw credentials, private tool payloads or an entire conversation into an escalation log merely to explain that access was denied.
Put the decision outside the generated answer
Let the model suggest a next step where appropriate, but have the runtime decide whether a tool may be called again. Track the operation, its state, attempts and remaining budget. A new explanation must not reset those counters.
A different tool or model is not automatically a different strategy. If it repeats the same failing operation with the same missing permission or unknown side effect, the underlying condition remains.
Use a global task budget as well as individual retry limits in production. Otherwise several independently bounded tools can create a long chain of work. Request retry budgets explain that wider limit and why cancelling a wait is not proof that remote work stopped.
Exercise the reference controller
Download agent-retry-boundary.mjs and run:
node agent-retry-boundary.mjs
The script calls fake synchronous tools only. Its two-attempt limit is a teaching choice, not a recommended universal production value. The executed cases check these outcomes:
| Fake tool behavior | Calls made | Controller result |
|---|---|---|
| One transient read failure, then completion | 2 | Complete |
| Repeated transient read failure | 2 | Budget exhausted |
| Permission denied | 1 | Authorized access needed |
| Write outcome unknown | 1 | Readback needed |
| Unclassified error | 1 | Review needed |
The example checks both the terminal state and call count. Extend that controller with the application's semantic repetition check, backoff and wall-clock deadline before using it to govern model calls. Evaluate those behaviors against the actual runtime and failure cases.
Before adapting it to asynchronous production tools, add actual deadlines and cancellation appropriate to those operations. A loop counter cannot interrupt one tool that never returns. Check whether a client timeout cancels work or merely stops waiting for it.
Separate missing configuration from transient failure
A network-isolated harness stopped before task execution because a child process had not received the receipt-path parameter required by its preload. Repeating the same action with the same environment could not satisfy the missing precondition.
The correction was to create an independent private receipt path for each child, keep the guard enabled and reject a run if its receipt recorded forbidden access. With that configuration in place, the checks completed successfully while the network control remained enabled.
The diagnostic decision is to identify the unmet precondition: inspect the stated precondition, make the authorized correction and rerun the check, rather than repeating an unchanged failing action or switching models without a reason.
Preserve a useful handoff
A terminal state should tell the next authorized person or component what was attempted, what was observed and what remains unknown. For an ambiguous write, retain the operation reference needed to verify its result. Do not label the whole task failed merely because its final response was lost.
For denied access, identify the permitted access path without suggesting a bypass. For budget exhaustion, preserve the last verified state and the reason another automatic attempt is not allowed. A handoff is not complete simply because the assistant says it has escalated; verify the receiving mechanism if your product promises one.
Separate these states from business demand. A trial user encountering a permission error has not thereby rejected the product. The trial reconciliation guide keeps outcome, event delivery and user intention distinct.
Test progress and false alarms separately
A legitimate clarification or a long but productive operation can look repetitive in text. If you add semantic loop detection, evaluate both stalled and successful tasks, including false alarms. Do not report the deterministic controller's tests as evidence that the semantic detector works.
Anthropic's agent evaluation guidance distinguishes what the agent says from the outcome in its environment. Use an outcome check for the task, and evaluate retry behavior as a separate property. The benchmark claim guide shows how a seemingly strong score can hide invalid outputs.
The safe response to a stalled task may be another bounded read, a required authorization step, a state check or a clear stop. The improvement is an enforced and reviewable decision, not an additional promise that the assistant will always find a way through.