← Table of Contents · Page 262 of 868
BUDGETS AND RESOURCE LIMITS
Part 5 of 9
PREVENTING RUNAWAY LOOPS AND INFINITE RETRIES
A runaway loop is a loop that keeps going because its stopping condition is never reached.
An agent can fall into one by repeating the same failing action, or by bouncing between two steps that undo each other.
Several protections work together.
A step limit caps the number of loop turns, regardless of tokens.
A repeat detector notices when the same tool is called with the same arguments several times in a row and interrupts the run.
A retry limit caps how often a failed call is tried again.
Exponential backoff means waiting longer after each failure, for example one second, then two, then four, so a struggling service is not hammered.
Jitter means adding a small random amount to each wait, so many agents do not all retry at the same instant.
After the retry limit is reached, the agent must change its approach or stop, instead of repeating the same call forever.
You will see in Chapter 56 how retries fit into wider error recovery.
Advertisement
Read Aloud:
0:00 / 0:00