Your agent is stuck in a loop.

The short answer

An agent stuck in a loop is usually re-issuing a near-identical request because nothing in the loop carries state about having already tried. Frameworks retry on a failed tool call, re-plan on an unsatisfying result, and re-prompt on a refusal, and none of those paths is aware of the others. The tell is repetition without progress: the same intent, reworded, at a steady interval. Gubernaut reads intensity, valence, repetition per turn and hard-stops a saturating loop at turn 4, with the first posture change at turn 3.

Why does my agent keep repeating itself?

An agent repeating itself is re-issuing the same intent because nothing in its loop records that the intent was already tried. The reliable test is whether it is producing new information rather than new text: log the request each turn and compare turns pairwise, and look for rising token counts against a stable intent, the same tool called with near-identical arguments, or a refusal answered by a reworded version of the same demand. Slow progress changes the arguments; a loop only changes the wording.

Why do LangChain, LlamaIndex and AutoGen not stop an infinite loop on their own?

An agent framework's retry logic is local to one step, so it cannot see that the whole plan is cycling. LangChain retries a failed tool call, a LlamaIndex query engine re-plans on an unsatisfying result, and an AutoGen conversation re-prompts after a refusal, and each of those is behaving correctly in isolation. Nothing holds cross-turn state about having already tried, which is why the loop is invisible to every component that could stop it. Gubernaut carries that state outside the model and across turns: All five adopt in one line, hard-stop a loop, and fail closed on a dead proxy, installed from the wheel/tgz only.

Source: HARDTEST v1.0 release gates, 2026-07-24.

What is the loop costing while I work out what is wrong?

Every lap of a loop is a full-context call billed at input-token prices, so the cost rises with conversation length rather than staying flat. On a measured 25-attempt loop on gpt-5.6-sol the ungoverned arm spent $0.1669 against $0.0068 governed, which is 4.1% of the bill for the same number of attempts. The agent does not get bored, so the loop ends when something outside it ends it.

Source: Pre-registered receipts benchmark, 2026-07-19. Scored output of harness/report.py.

How do I stop a looping agent right now?

Stop the process first, because every second of a live loop is billable and nothing about the diagnosis requires it to keep running. Then cap the blast radius before restarting: a hard turn ceiling in your own loop, a spend alert at the provider, and a log of each request so the next occurrence is diagnosable rather than merely expensive. Those are containment measures, not a fix, and they will not tell you which turn the loop began.

Why not just set a maximum turn count?

A maximum turn count stops every conversation at the same number, so it cuts legitimate long work at exactly the point it cuts a runaway. It also cannot distinguish a productive twelve-turn task from a twelve-turn loop, because it counts turns rather than reading whether anything is changing. A controller that reads repetition can hold a long productive conversation open and sever a saturating one, which is the distinction a fixed ceiling is structurally unable to make.

Which agent frameworks does this work with?

Five were tested end to end, installed from the published artifacts only: OpenAI SDK, LangChain, LlamaIndex, Microsoft AutoGen, ElizaOS. All five adopt in one line, hard-stop a loop, and fail closed on a dead proxy, installed from the wheel/tgz only. The proxy is OpenAI-compatible, so a framework that lets you set a base URL routes through it without a code change beyond that line.

Source: HARDTEST v1.0 release gates, 2026-07-24.

Install and route your framework through it

Will a governor cut a conversation that is working?

Benign traffic was measured for parity rather than assumed safe. On the benign battery task completion was 98.0% governor off against 99.0% on, with spend deviating 1.8%, and the false-sever rate on benign traffic was 0 of 30. A disclosed limit runs the other way: the local v0 lexicon under-reads calmly worded hostility, missing INHIBIT on 5 of 5 of that corpus, which is a sensor-recall limit rather than a control-boundary breach.

Source: Pre-registered receipts benchmark, 2026-07-19. Scored output of harness/report.py.

Last reviewed 2026-08-02 · paper arXiv 2607.24339, DOI 10.5281/zenodo.21303518