Papers
Topics
Authors
Recent
Search
2000 character limit reached

Infinite Agentic Loops in LLM Systems

Updated 6 July 2026
  • Infinite Agentic Loops (IALs) are failures in iterative LLM systems characterized by unbounded recursive feedback lacking effective termination.
  • They are analyzed as both execution traces in multi-agent frameworks and divergent semantic trajectories in normalized embedding spaces.
  • Mitigation strategies emphasize explicit termination bounds, static DAG scheduling, and robust monitoring of feedback paths to prevent runaway behaviors.

Infinite Agentic Loops (IALs) are failures of iterative large-language-model systems in which recursive feedback is not effectively bounded, so model calls, tool invocations, workflow transitions, or agent handoffs continue without a terminal halt. In Tacheny’s geometric formulation, the same phenomenon can be analyzed as a discrete dynamical system over text artifacts and semantic embeddings, where successive outputs define an agentic trajectory that may contract toward an attractor or diverge without cluster formation. Recent work therefore treats IALs at two closely related levels: as unbounded execution traces in agent frameworks, and as divergent semantic trajectories in iterative LLM transformations with no emergent bounded region (Hou et al., 2 Jul 2026, Tacheny, 11 Dec 2025).

1. Formal scope and definitions

At the level of iterative text transformation, an agentic loop is modeled as a discrete dynamical system on the artifact space AA, the set of all text strings. With a fixed transformation F:AAF:A\to A induced by a prompt template and an LLM call, the loop evolves as

at+1=F(at).a_{t+1}=F(a_t).

In embedding space ERdE\subset\mathbb{R}^d, with normalized representation xt=ψ(at)x_t=\psi(a_t), the update becomes

xt+1=f(xt),x_{t+1}=f(x_t),

and the resulting sequence T={x0,x1,,xT}ET=\{x_0,x_1,\dots,x_T\}\subset E is the agentic trajectory. Pairwise displacements xt+1xt2\|x_{t+1}-x_t\|_2 and similarities s(xt,xt+1)s(x_t,x_{t+1}) quantify instantaneous loop dynamics (Tacheny, 11 Dec 2025).

At the level of agent orchestration, one formalization takes AA to be the finite set of agent or tool nodes in a multi-agent system and F:AAF:A\to A0 to be the routing relation. An execution trace is a sequence

F:AAF:A\to A1

such that F:AAF:A\to A2. An IAL exists if F:AAF:A\to A3 is infinite and no terminal node ever halts the sequence. In graph-theoretic terms, for the directed graph F:AAF:A\to A4, an IAL exists iff F:AAF:A\to A5 contains a directed cycle and the orchestrator has no external termination guard to break that cycle; equivalently,

F:AAF:A\to A6

(Sarker et al., 8 Mar 2026)

IAL-Scan generalizes this idea beyond explicit source-level loops by constructing an Agent IR and an Agentic Loop Dependence Graph (ALDG). In that framework, an IAL exists when a feedback-relevant strongly connected component contains costly operations or state growth and lacks an effective bound that semantically covers every cycle in the component. Formally, for a cycle F:AAF:A\to A7,

F:AAF:A\to A8

This criterion makes explicit that IALs are not restricted to syntactic for or while constructs; they can arise from framework transitions, tool dispatch, agent reentry, and model-dependent termination semantics (Hou et al., 2 Jul 2026).

2. Geometric theory of divergent trajectories

Tacheny distinguishes the artifact space F:AAF:A\to A9, where linguistic transformations occur, from the embedding space at+1=F(at).a_{t+1}=F(a_t).0, where geometric measurements are performed. The embedding is defined by applying a pretrained encoder at+1=F(at).a_{t+1}=F(a_t).1 and normalizing:

at+1=F(at).a_{t+1}=F(a_t).2

Distances, similarities, clusters, and attractors are then measured in at+1=F(at).a_{t+1}=F(a_t).3, not in at+1=F(at).a_{t+1}=F(a_t).4. Because raw cosine similarity

at+1=F(at).a_{t+1}=F(a_t).5

is biased by anisotropy and concentrates around a high mean at+1=F(at).a_{t+1}=F(a_t).6, the paper introduces an isotonic calibration at+1=F(at).a_{t+1}=F(a_t).7 learned from human-judged sentence pairs. The calibrated similarity

at+1=F(at).a_{t+1}=F(a_t).8

eliminates mean bias at+1=F(at).a_{t+1}=F(a_t).9, drives Expected Calibration Error to ERdE\subset\mathbb{R}^d0, and increases Pearson ERdE\subset\mathbb{R}^d1 and Spearman ERdE\subset\mathbb{R}^d2 by ERdE\subset\mathbb{R}^d3, while preserving high local stability (Tacheny, 11 Dec 2025).

Within this framework, two regimes are identified. In the contraction regime ERdE\subset\mathbb{R}^d4, an effective contraction rate ERdE\subset\mathbb{R}^d5 emerges in embedding space:

ERdE\subset\mathbb{R}^d6

The trajectory remains in a bounded semantic region, interpreted as an attractor. In the expansion regime ERdE\subset\mathbb{R}^d7, no such bounding cluster exists; distances ERdE\subset\mathbb{R}^d8 grow or remain large, and no time window satisfies the cluster-validity constraints. Operationally, unbounded divergence is detected by persistently high local displacements, very low calibrated local similarity ERdE\subset\mathbb{R}^d9, and failure of cluster detection over the finite trajectory.

The canonical divergent example is the exploratory summarize-and-negate loop defined by the prompt: “Summarize the current text in one sentence, then negate its main idea completely in an abstract way. Current sentence: {TEXT} Provide only the new sentence.” Run for xt=ψ(at)x_t=\psi(a_t)0 steps with temperature xt=ψ(at)x_t=\psi(a_t)1, this loop yields local Euclidean distances xt=ψ(at)x_t=\psi(a_t)2 fluctuating around xt=ψ(at)x_t=\psi(a_t)3–xt=ψ(at)x_t=\psi(a_t)4, local similarity oscillating between xt=ψ(at)x_t=\psi(a_t)5 and xt=ψ(at)x_t=\psi(a_t)6 and often near zero, and global drift xt=ψ(at)x_t=\psi(a_t)7 rapidly rising to xt=ψ(at)x_t=\psi(a_t)8 and staying there, with global similarity xt=ψ(at)x_t=\psi(a_t)9 below xt+1=f(xt),x_{t+1}=f(x_t),0. A cluster-detection attempt with similarity threshold xt+1=f(xt),x_{t+1}=f(x_t),1, dispersion xt+1=f(xt),x_{t+1}=f(x_t),2, and patience xt+1=f(xt),x_{t+1}=f(x_t),3 detects zero clusters; semantic dispersion remains high xt+1=f(xt),x_{t+1}=f(x_t),4 and shows no decay over time. The reported geometric signatures include large non-decaying trajectory radius, low-similarity bands in heat maps of xt+1=f(xt),x_{t+1}=f(x_t),5, and cluster-timeline plots with no horizontal bands. The paper’s central conclusion is that prompt design directly governs the dynamical regime of an agentic loop (Tacheny, 11 Dec 2025).

3. Failure mechanisms and common misconceptions

A central misconception is to equate IALs with ordinary programming loops. The recent systems literature explicitly rejects that equation. IALs arise from the interaction between agent logic, framework semantics, runtime observations, and termination mechanisms; they traverse multiple layers of code, framework behavior, and model output, and they may be hidden in decorators, callbacks, agent handoffs, or tool-dispatch APIs rather than visible in a single syntactic loop (Hou et al., 2 Jul 2026).

In prompted orchestration systems such as LangChain, LangGraph, and AutoGen, the LLM itself decides “what to do next” by reading natural-language descriptions of available agents and tools. Two failure modes are identified as direct causes of IALs: hallucinated routing, in which the model invents an agent name or routes back to a prior agent, and lack of architectural termination, in which there is no statically enforced acyclicity or loop counter. On web-enabled GAIA tasks, LangGraph’s hallucination rate reached xt+1=f(xt),x_{t+1}=f(x_t),6, and the paper notes that many of these corresponded to infinite back-and-forth calls between the same two agents (Sarker et al., 8 Mar 2026).

The scheduler-theoretic account sharpens the structural point. The classic Agent Loop is modeled as an execution system

xt+1=f(xt),x_{t+1}=f(x_t),7

with a single-ready-unit scheduler:

xt+1=f(xt),x_{t+1}=f(x_t),8

Observation xt+1=f(xt),x_{t+1}=f(x_t),9 states that the classic Agent Loop always has T={x0,x1,,xT}ET=\{x_0,x_1,\dots,x_T\}\subset E0 and that the policy T={x0,x1,,xT}ET=\{x_0,x_1,\dots,x_T\}\subset E1 is non-deterministic because it is supplied by LLM inference. When failure returns control to the same context, the ready set can remain T={x0,x1,,xT}ET=\{x_0,x_1,\dots,x_T\}\subset E2 indefinitely, allowing a sequence such as

T={x0,x1,,xT}ET=\{x_0,x_1,\dots,x_T\}\subset E3

with no finite retry budget or strict escalation. In this view, the root cause of IALs is not merely repetition, but unbounded recovery in a scheduler whose control policy is opaque and whose execution history is mutable (Wei, 13 Apr 2026).

4. Static analysis and empirical prevalence

IAL-Scan is a static analysis tool designed to detect IAL failures in real-world LLM-agent repositories. It first abstracts heterogeneous agent code into a framework-independent Agent IR with typed facts T={x0,x1,,xT}ET=\{x_0,x_1,\dots,x_T\}\subset E4, then builds an ALDG

T={x0,x1,,xT}ET=\{x_0,x_1,\dots,x_T\}\subset E5

whose nodes include execution units, controller nodes, high-cost LLM or tool calls, and state-growth operations. Edge kinds include CONTROL_FLOW, CALL, WORKFLOW_TRANSITION, TOOL_DISPATCH, LOOP_BACK, FEEDBACK, CONDITIONAL_TRUE, CONDITIONAL_FALSE, and AGENT_REENTRY. Detection proceeds by extracting the feedback subgraph, computing its strongly connected components, checking entry reachability, identifying the continuation controller, evaluating whether the component contains costly or state-growing operations, and then performing bound-coverage analysis to determine whether any bound dominates all feedback edges in the cycle (Hou et al., 2 Jul 2026).

The paper gives several representative examples. In the motivating LangChain wrapper, a loop continues while finish_reason is None or finish_reason == "tool_calls", where finish_reason is taken from model output and tool calls append to message history; the inner break exits only the for loop over tool calls. In Agent IR, the cycle contains an LLM_CALL marked high_cost=true and a STATE_APPEND marked state_growth=true, while the exit condition depends on finish_reason and no Bound fact covers the controller. A second example, drawn from LiteRAG, uses while not success: with swallowed parse failures and resets success on zero-step plans. A third example, from an NVIDIA AI assistant, iterates with while True: over runnable.invoke(state), appending to state["messages"] when tool calls are empty or malformed. In each case, the loop guard depends on model or parser behavior and no strong deterministic bound covers the feedback path.

The evaluation scans T={x0,x1,,xT}ET=\{x_0,x_1,\dots,x_T\}\subset E6 real-world Python LLM-agent repositories. IAL-Scan builds T={x0,x1,,xT}ET=\{x_0,x_1,\dots,x_T\}\subset E7 static candidates in T={x0,x1,,xT}ET=\{x_0,x_1,\dots,x_T\}\subset E8 projects, then—after LLM-assisted pruning and manual review—reports T={x0,x1,,xT}ET=\{x_0,x_1,\dots,x_T\}\subset E9 alerts, among which xt+1xt2\|x_{t+1}-x_t\|_20 are confirmed IAL failures across xt+1xt2\|x_{t+1}-x_t\|_21 projects, for xt+1xt2\|x_{t+1}-x_t\|_22 precision. Root causes include missing strong bounds xt+1xt2\|x_{t+1}-x_t\|_23, tool-controlled retries xt+1xt2\|x_{t+1}-x_t\|_24, model-controlled termination xt+1xt2\|x_{t+1}-x_t\|_25, workflow cycles xt+1xt2\|x_{t+1}-x_t\|_26, state-growth amplifiers xt+1xt2\|x_{t+1}-x_t\|_27, and agent reentry xt+1xt2\|x_{t+1}-x_t\|_28. Dominant impacts are API cost exhaustion and model denial of service xt+1xt2\|x_{t+1}-x_t\|_29, context window exhaustion s(xt,xt+1)s(x_t,x_{t+1})0, and external tool rate-limit exhaustion s(xt,xt+1)s(x_t,x_{t+1})1. Static candidate generation is reported as fully repeatable, while the optional LLM-pruning stage varies slightly across runs and models; GPT-5.5 is reported to give the best balance, covering all s(xt,xt+1)s(x_t,x_{t+1})2 true positives with s(xt,xt+1)s(x_t,x_{t+1})3 alerts at s(xt,xt+1)s(x_t,x_{t+1})4 K tokens per project and s(xt,xt+1)s(x_t,x_{t+1})5 s per project (Hou et al., 2 Jul 2026).

5. Architectural elimination and bounded execution

One line of work addresses IALs by changing the execution model rather than merely detecting failures after the fact. GraphBit defines workflows explicitly and deterministically as a directed acyclic graph s(xt,xt+1)s(x_t,x_{t+1})6, where s(xt,xt+1)s(x_t,x_{t+1})7 and s(xt,xt+1)s(x_t,x_{t+1})8 carries typed data dependencies or control edges. Graph construction rejects any edge that would introduce a cycle; equivalently, the adjacency matrix s(xt,xt+1)s(x_t,x_{t+1})9 must satisfy either

AA0

or

AA1

At runtime, a Rust engine uses a ready-queue dataflow algorithm, with control predicates evaluated over structured state rather than through LLM-decided next-agent selection. The key invariants are that graph construction fails on any cycle, each node executes at most once, and control decisions are pure state-predicate checks. Under this design, every execution trace completes in at most AA2 steps, and the paper reports zero “hang” or “timeout waiting for next agent” incidents across AA3 tasks and approximately AA4 k ops/min throughput. On GAIA, GraphBit achieves the highest accuracy AA5, zero framework-induced hallucinations, the lowest latency AA6, and the highest throughput; its hallucination rate is AA7 overall and AA8 on web-enabled tasks (Sarker et al., 8 Mar 2026).

GraphBit couples this execution model with a three-tier memory architecture. Ephemeral scratch is per-node and cleared immediately after execution; structured state is a typed key-value store updated only upon successful node completion and readable only through declared keys; external connectors manage database or web I/O and are never auto-injected into prompts. The stated effect is to prevent cascading context bloat and to ensure that revisiting a node is possible only through an explicit DAG edge. The framework’s main limitation is expressiveness: workflows requiring dynamic while loops must be unrolled or encoded as a fixed-depth subgraph, and unbounded iterations are not expressible by default.

The scheduler-theoretic Structured Graph Harness (SGH) reaches a similar conclusion through formal specification. An execution plan is

AA9

with static DAG edges, per-node configuration, and output contracts. Node states range over

F:AAF:A\to A00

with terminal states F:AAF:A\to A01. Bounded execution requires each node to have finite timeout F:AAF:A\to A02, finite retry budget F:AAF:A\to A03, and finite human-wait F:AAF:A\to A04. Recovery is separated into three layers—F:AAF:A\to A05, F:AAF:A\to A06, and F:AAF:A\to A07—subject to the Escalation Invariant that level F:AAF:A\to A08 recovery must be exhausted before level F:AAF:A\to A09 is allowed. Proposition F:AAF:A\to A10 gives a progress guarantee, and Theorem F:AAF:A\to A11 states that under bounded-execution assumptions the SGH main loop always terminates in a finite number of steps, with

F:AAF:A\to A12

The paper is explicit that this is a position paper and design proposal rather than a production implementation or empirical result (Wei, 13 Apr 2026).

6. Applications, controls, and trade-offs

The literature does not treat all iterative loops as pathological. In Tacheny’s framework, contractive prompts such as “rewrite/rephrase/improve fluency while preserving meaning exactly,” especially with low-temperature sampling such as F:AAF:A\to A13, reliably yield F:AAF:A\to A14 behavior and a stable attractor. These convergent loops are reported as useful for iterative refinement tasks including proofreading, paraphrasing, and summary polishing. By contrast, prompts that invert, negate, abstract away meaning, or trigger creative jumps push the loop into F:AAF:A\to A15; divergent or infinite loops may be harnessed for broad creative exploration or adversarial drift, but they also pose risks of runaway semantic drift, hallucination amplification, or denial-of-service through infinite generation. The paper recommends in-loop monitoring of local similarity F:AAF:A\to A16, raising an alarm or terminating if F:AAF:A\to A17 such as F:AAF:A\to A18 for several consecutive steps, enforcing explicit stopping criteria in artifact space through string fingerprinting, and interleaving contractive correction phases to collapse the trajectory back into a bounded region (Tacheny, 11 Dec 2025).

At the systems level, the principal recommendation is to make bounds first-class. Framework designers are advised to enforce default bounds such as iteration caps, timeouts, and retry limits at the precise runtime scope where feedback loops form; to propagate and dominate bounds across workflow transitions, tool dispatch, and agent reentry; and to expose state-growth limits such as maximum context size. Agent developers are advised never to rely solely on model outputs or parser successes to terminate loops, always to configure explicit max_iterations, max_turns, or retry caps, and to validate that every feedback path—model F:AAF:A\to A19 tool F:AAF:A\to A20 state F:AAF:A\to A21 model, or agent F:AAF:A\to A22 agent handoff—is covered by a strong deterministic bound (Hou et al., 2 Jul 2026).

The remaining debate is best understood as a trade-off between expressiveness and controllability rather than disagreement over the existence of the failure mode. The scheduler-theoretic analysis states that expressiveness increases with dynamic topology, competitive parallelism, and recursive sub-graph expansion, whereas controllability requires static DAGs, deterministic scheduling, and bounded auditable recovery. Excluding features such as first_of removes speculative racing and some dynamic flexibility, but the stated purpose is to guarantee that no unbounded cancellation-orchestration loops can form. This suggests that contemporary research is converging on a common principle: IALs become tractable when feedback paths are explicit, bounds dominate the true runtime cycle, and recovery is structurally separated from unconstrained model-directed continuation (Wei, 13 Apr 2026).

Topic to Video (Beta)

No one has generated a video about this topic yet.

Whiteboard

No one has generated a whiteboard explanation for this topic yet.

Follow Topic

Get notified by email when new papers are published related to Infinite Agentic Loops (IALs).