Skip to main content

Which tool errors should an agent retry, and where should the retry logic live: in the model or in the harness? Use a payment tool that times out as your example.

Agents and tools · Intermediate 3

Short answer

Retry only errors that are temporary, such as timeouts and rate limits, and only if the call is safe to repeat. The harness should do those retries in code, with backoff and a limit. Permanent errors go back to the model as a clear message. For a payment, use an idempotency key and check the status before any retry.

Deeper answer

Errors fall into three groups. Temporary ones, such as a timeout or a 429, may succeed if tried again. Input errors, such as a wrong ID format, will fail every time until the arguments change, so the model must see the message and fix its call. Permanent ones, such as insufficient balance, need a different plan or a person.

Retries for temporary errors belong in the harness. Code can apply backoff, count attempts and stay cheap. If the model does it, each attempt costs a full model call and may loop. A timeout is a special case, because you do not know whether the action happened. For a read, just repeat it. For a payment, repeating can charge the customer twice. So the tool takes an idempotency key that stays the same across attempts, and the harness checks the payment status before it tries again. Interviewers listen for the three groups, for idempotency, and for error text written so the model can act on it.

What a strong answer covers

Answer it out loud in the mock interview about 2 min

Follow-ups to expect

Common mistakes

Learn it

Tool calling

Practice Agents and tools questions

More on this topic

Today's AI turns are used

Lessons, roadmaps, videos, practice cards and the code playground stay free with your account, with no limit.