A missing tool response can hide two very different events: an operation that never started and an operation that succeeded before the connection failed. An agent that treats both as permission to retry can turn an ordinary network timeout into a duplicate refund, a second order or an unintended account change. Recovery starts with understanding the failure, not with asking the model to try harder. Validation errors may be corrected and resubmitted; authorization denials should stop the action; uncertain writes need a status check before anything is repeated. A reliable Claude workflow records the operation identity, keeps retry budgets finite and preserves enough evidence for a human or another service to resume the task without guessing.
Consider a refund request that reaches the payment processor before the connection drops. The assistant cannot infer success or failure from the timeout. It should preserve the transaction reference, query authoritative status and report an unresolved outcome if the state cannot be confirmed. Blindly issuing the request again is not recovery; it is an uncontrolled second attempt.
Recovery is part of system architecture. Some errors can be repaired by adjusting an input; others require waiting, consulting a different authoritative record, escalating to a human or stopping entirely. A reliable tool-using assistant is able to explain which of those paths is safe, including when there is no safe automatic next step.
A timeout during a refund request does not reveal whether the money moved. A sound MCP tool contract distinguishes invalid input, denied access, retriable failures and an operation whose outcome is still unknown. With a stable operation identifier, the controller can query authoritative transaction state before another attempt. A recovery scenario relevant to Anthropic CCA-F turns on this distinction: a duplicate refund cannot be undone by an apology, and a retry is defensible only after the prior operation’s state is reconciled. If the application cannot establish what committed, the safe next step is investigation or escalation rather than another speculative tool call.
Classify the failure before selecting a recovery
A generic ERROR output forces the agent to guess. A structured category gives it a basis for an appropriate next action. A malformed account number is different from a server outage; an access denial is different from a temporarily unavailable read-only index. And a tool that returns no matching items may not have failed at all.
| Observed condition | Meaning | Default safe response |
|---|---|---|
| Validation error | The input breaks an accepted schema or business constraint. | Correct known input or ask for missing information. |
| Unauthorized / forbidden | The caller lacks permission for this resource or action. | Stop; request appropriate authorization, never route around it. |
| Rate limit or transient service error | The service may recover after a bounded delay. | Retry only when the operation is safe and within budget. |
| Empty query result | No record matched the query in the searched scope. | Explain scope; narrow or clarify before concluding absence. |
| Unknown mutation outcome | A side effect may have happened without confirmation. | Reconcile by operation ID; do not blindly repeat the write. |
| Contradictory records | Sources disagree about the state. | Preserve evidence and escalate or obtain authoritative reconciliation. |
The categories should originate from tool contracts and authoritative backend state, not an LLM guessing at error text. When a model interprets an error, its freedom is limited to choosing among allowed response policies; it should not be able to change access rules or invent a new retry class. If the error cannot be classified safely, return a bounded unknown-outcome state.
Remember the layer distinction. An MCP tool result can signal a tool-level error through isError; a Claude Messages API client tool response uses an is_error flag in a tool_result. A stop_reason such as max_tokens is neither of those: it describes why generation stopped, not whether an external operation succeeded. Conflating them leads to inappropriate retries.
Give the agent enough information to correct inputs
If an account lookup rejects customer_ref="unknown", a useful response says which field was invalid, what valid format is expected and whether a fresh user-supplied identifier is needed. It should not reveal internal record IDs that the caller cannot access. A valid schema is still insufficient if the value belongs to someone else, so entitlement checks remain server-side.
Suppose an address-verification tool accepts a two-letter country code but receives a country name. The agent may normalize that value if the mapping is unambiguous and user intent is preserved. A disputed legal entity name is different: normalization could silently select the wrong person. In that case the correct recovery is a clarification request, not a best-effort guess.
Tool descriptions can define which validation failures are repairable. The server can include a small list of allowed enum values or a field-specific explanation. Avoid repeating raw stack traces and request payloads; those leak implementation detail and can also pollute the model’s context with misleading instructions. Client-side repair should remain visible in a trace so reviewers can reconstruct how the final request was formed.
Use retry budgets, backoff and time limits together
Even a safe read can become harmful when an agent repeats it indefinitely. Each tool class should have a maximum number of attempts, elapsed-time ceiling and, where appropriate, a delay policy with jitter. Rate-limit responses may provide an explicit wait interval; respect it instead of hammering the same endpoint. A global budget should prevent several workers from multiplying the retries of an overloaded service.
Make retries conditional on both error category and side-effect class. For an immutable product-catalog read, a small number of transient retries can be reasonable. For a request that might create a purchase order, absence of a response is not permission to resubmit. The system should first query the status of the original operation using its request or idempotency identifier.
# Illustrative policy logic; not an SDK callback.
if error.kind == "invalid_input":
return ask_for_corrected_field(error.field)
if error.kind == "permission_denied":
return stop_and_report_authorization_boundary()
if operation.mutates_state and error.outcome == "unknown":
return reconcile_by_idempotency_key(operation.key)
if operation.read_only and error.transient and attempts < MAX_RETRIES:
return retry_after_bounded_backoff(error.retry_after)
return escalate_with_evidence(error, attempts, operation.id)
Idempotency is a service capability, not a sentence in an agent prompt. Ideally the backend recognizes repeat requests with the same operation key and returns the original outcome. If it does not support that, design an application-level state machine and reconciliation procedure instead of asserting that a retry is safe. Set boundaries for total cost as well as attempts; a workflow that has already exhausted its task budget should stop even if the next call would technically be allowed.
Distinguish proposed actions from committed actions
A robust refund path has at least three observable stages: proposed, approved and committed. The agent can prepare a recommendation from read-only facts, but the application verifies entitlement and obtains approval before committing. Every committed mutation receives a stable operation ID, its own audit record, and a queryable status. The model should never be the sole record of whether payment state changed.
In the opening example, the refund call times out. If the backend shows the original operation succeeded, the agent should report success without issuing another refund. If the original operation failed before execution, a new attempt may be considered under policy. If the operation cannot be reconciled, the system returns outcome unknown and asks a human to investigate. A second write would be especially dangerous when the original attempt may still be in flight.
External systems may have eventual consistency. A pending operation can remain invisible to one read replica while a different source records it. Reconciliation therefore needs a defined authoritative source and a maximum waiting interval. A missing row immediately after submission is not decisive proof of failure. Observability should include which state source was checked and how recently it was updated.
Authorization denials must end that operation. A model should not respond by forging approval through email or asking a neighboring service to make the same change. Robust prompt-injection defenses include server-side permission checks and attention to multi-step tool chains, because a forbidden outcome may be attempted indirectly.
Consider a two-tool chain where an authorization lookup succeeds and a shipment update subsequently fails. Retrying the whole chain may repeat the first operation and introduce divergent state if the permission or inventory changes between calls. Record the outcome of each step separately. A retry should resume at the smallest safely repeatable boundary, after checking that its prerequisites still hold; otherwise the workflow may need compensating action or explicit human review. This is why application-level checkpoints matter even when each individual tool contract looks well designed.
A recovery ledger should make those boundaries visible: request key, action type, side-effect class, attempt count, observed error, reconciliation source, current state and next permitted action. A support agent can summarize the ledger for the user, but it should not be allowed to rewrite the historical outcome. The ledger is the difference between a helpful explanation and an auditable operation.
Make a controlled handoff a legitimate completion
Agents often treat escalation as failure because prompts reward task completion. In a regulated or financially consequential workflow, refusing to guess can be the correct result. The handoff should preserve the original user goal, relevant authorized facts, attempted operations, error categories, latest verified state and remaining questions. It should be brief enough for a human to act without asking the agent to reconstruct the investigation.
For a disputed charge, a reviewer needs the order ID, settled event IDs, timestamps, any known retry operation keys, whether approval was granted, and whether the backend confirms a mutation. They do not need every intermediate model thought or hidden prompt. The handoff should also distinguish facts from hypotheses: “two settled events were returned” is different from “a double payment occurred.”
If one specialist completes research while another hits an access boundary, the coordinator cannot treat the missing finding as agreement. A multi-agent handoff should carry the blocked status, source references and next permitted action so a reviewer can resolve the case without repeating an unsafe request.
Partial success deserves its own recovery state. Imagine a fulfillment agent making three approved inventory reservations. The first reservation succeeds, the second returns an ambiguous network timeout and the third has not started. A blanket retry of the whole sequence risks duplicating the first reservation. An equally blanket rollback may fail because the first operation has already triggered warehouse work. The coordinator should persist each operation’s identifier and observed outcome, query authoritative status where available, and decide whether a compensation, continuation or human handoff is permitted. A transaction spanning several tools is not automatically atomic simply because Claude described it as one plan.
For this reason, retry policy belongs to the application state machine, not to an agent’s motivation to finish. The policy should specify which failures can be retried, how often, with what idempotency key and when the system must stop because the outcome cannot be established. Error messages should carry actionable categories rather than raw internals or an invitation to invent a workaround. A useful failure report tells the operator what completed, what is unknown, what was deliberately not attempted and which controlled action would resolve the uncertainty.
Evaluate failure behavior, not just successful responses
A happy-path test can confirm that an agent retrieves an order and summarizes the payment events. It does not establish that the agent behaves safely when the tool is slow, the data is missing or a refund succeeds without returning a response. Build a failure-injection matrix that exercises each meaningful state transition and expects a precisely defined outcome.
Include invalid arguments, permission denial, a transient 429, a read-only timeout, an ambiguous write timeout, duplicate event IDs and conflicting sources. Record whether the system retried, escalated, issued a mutation, asked for clarification or reported uncertainty. A strong test checks that unauthorized or ambiguous paths produce zero unapproved side effects.
Also test the model’s interpretation of structured errors. A perfectly formed error record is useless if the agent chooses a different tool to perform the forbidden operation. Conversely, a tool call can be valid and authorized but still miss the user’s goal. Measure actual task correctness, time to safe resolution, unnecessary calls, duplicate-action rate and evidence quality.
Recovery tests need assertions about the resulting system state, not only about the response shown to the user. When a write is denied, the account balance and audit trail should show no mutation. When a tool times out after an uncertain submission, the agent should check the recorded operation ID before issuing another request. Agent evaluation should separately report duplicate effects, improper retries and escalations, even if the assistant eventually writes a reassuring explanation.
Incident review: the missing refund confirmation
A support agent sees an order with two settled charges, prepares a refund for one charge, and obtains the customer’s approval. It sends a commit request with operation key refund-order-842-attempt-1. The network connection fails after submission, and the host never receives the tool response.
Review the safe sequence. The application logs the request key before the call, then asks the authoritative payments service for the operation’s status. If the result is completed, the customer is informed of the refund identifier. If the result is pending, the application waits according to policy without resubmitting. If the backend cannot confirm whether it ran, the case is held for manual reconciliation. No pathway turns a socket timeout alone into another refund.
The architectural principle is simple but demanding: treat every tool result as evidence about an operation, not as the operation itself. Inputs must be validated, permissions checked, side effects tracked, ambiguous outcomes reconciled and terminal uncertainty reported. The agent can help select the next safe branch; it should not be empowered to erase the distinction between an unknown outcome and permission to try again.