New Tool Radar

AI Concepts

How to Handle a Failed Agent Tool Call with a Retry

Handle a failed agent tool call by retrying once with the same arguments, then reporting the failure to the model.

Schematic illustration of handle a failed agent tool call with a retry: step one catch the failure, step two retry once, step three tell the model.

A tool call can fail: the function returns an error, the arguments are wrong, or the service is down. The agent’s job is not to pretend it worked. Retry the call once, because a transient failure is common, and if it fails again, send the error back to the model as a tool result so the model can change its plan or tell the user.

Prerequisites

  • An agent loop that receives tool results.
  • A retry rule: one retry, then stop.
  • A way to send an error back to the model as a tool result.

Steps

Step 1: Catch the failure

Catch the failure in your code, not in the model: log the tool name, the arguments and the error message. Do not send a made-up result to the model.

Step 2: Retry once

Retry the same call once with the same arguments. If the failure was transient, the retry succeeds; if it was caused by bad arguments, the retry fails the same way, and that tells you the cause.

Step 3: Tell the model

If the retry fails, send the error to the model as the tool’s result, with the tool call’s id, so the model knows the call failed. The model can then try a different tool, ask the user for the missing information, or report the failure.

Worked example: Harbor Light library catalogue lookup

The fictional Harbor Light library’s agent calls get_book, which fails twice: first a timeout, then a wrong argument.

Attempt Tool Result Action
1 get_book Timeout error Retry once
2 get_book Timeout error again Send the error to the model
3 Model’s response Asks the reader for the book’s author User helps

After 2 failed attempts the error goes back to the model, which asks the reader for the author instead of calling the same tool a third time.

Expected result. A failed tool call is retried once, and a second failure is reported to the model, not hidden. UNTESTED: this guide was not run against a live model or API. The worked example below is fictional practice material, and its result is the expected result, not a measured one.

Limits

  • Retrying with the same bad arguments will fail the same way; fix the arguments instead of retrying blindly.
  • One retry is a starting rule; a service that is down needs a longer wait, not more retries.
  • This guide does not cover tool calls that return wrong data instead of an error.

Sources

See all