Every agent run has a turn limit and a token budget
An agent bouncing between two tools will keep looping until something stops it, and the only things that will are a limit you set or the bill.
for (let turn = 0; turn < 40; turn++) { … }
if (usedTokens > 200_000) return giveUp("budget");Log the runs that hit the limit, because those are your bugs. A run that needs sixty turns is a task that should have been split up.
ai-agentsreliability