[KongchangAI]
ConceptAgent Loops / 智能体循环

Agent Loop

Agent Loop is a core operational architectural pattern in autonomous agent systems, referring to the working mechanism by which an agent completes complex tasks through continuous cyclic execution of steps such as perception, reasoning, action, and observation. In each iteration, the agent invokes a large language model for reasoning, generates action instructions, calls tools or interacts with the environment, and feeds the results as new input into the next reasoning round until the goal is achieved or a termination condition is met. This pattern is a foundational design principle for agent frameworks such as ReAct and AutoGPT.

Core Facts

Timeline (last 90 days)

Oct 25

Anthropic mentions that limiting the number of loop rounds is a common practice to prevent an Agent from falling into an infinite loop.

Unverified50%
Oct 24

The difference between an Agent Loop and a single API call in tool calling is that a single call has no tool-calling capability and can only output text, while an Agent Loop can call tools such as the file system, databases, and external APIs.

Unverified50%
Oct 24

A robust Agent Loop usually combines multiple exit conditions: a hard upper limit as a fallback, progress detection for stop-loss, and a Checker as a quality gate.

Unverified50%
Oct 24

Relying only on "the model saying it is done itself" as the Loop exit condition is the most dangerous approach, because the model may declare success prematurely or fall into an infinite loop.

Unverified50%
Oct 24

An Agent Loop's memory is not unlimited; when the task chain is very long, memory needs to be managed through summary compression, external vector database retrieval, or sub-Agent isolation to cope with context window overflow.

Unverified50%
Oct 24

An Agent Loop must include the three stages of "parse -> execute -> backfill" to handle tool calls, and an error in any stage will cause the loop to spin idle.

Unverified50%
Oct 24

The core logic of the Agent Loop is: as long as stop_reason is still tool_use, keep executing tools and returning results; the entire loop can be implemented in about 20 lines of Python code.

Unverified50%
Oct 18

Common engineering means of terminating an agent include maximum step/maximum round limits, timeout budgets, consecutive-failure counters, and failure-signal detection based on rules or model judgment.

Unverified50%
Oct 16

When a limit is triggered, execution should stop and return the partial results already completed along with a concise explanation; a justified partial answer is far better than an Agent that loops infinitely until killed externally.

Unverified50%
Oct 16

When asked to 'execute at most ten steps', the model sometimes executes thirty steps; this is an inherent limitation of current models, and the reliable approach is to enforce the maximum number of steps, timeouts, and token or cost budgets at the code level of the run loop.

Unverified50%

40 more timeline events

All Facts (20)

Verified

The underlying operational logic of an Agent Loop is an iterative cycle of 'perception–planning–action–observation.'

80%
Verified

The decision loop of an AI Agent consists of four steps: Sense, Plan, Action, and Observe, forming a closed-loop iteration.

80%
Verified

The agent flow is: send a message to the model to get a response; if the stop reason is not tool use, return the text; otherwise, iterate through the tool-call blocks, validate parameters, run the function, push the result back as a tool result, and loop.

75%
Verified

Modern AI coding agents typically adopt a plan-execute-reflect loop framework, decomposing complex tasks into sub-steps and self-correcting based on execution results.

70%
Verified

Cursor and Claude Code are both based on the same core Agent work loop: read code, make a plan, edit files, run verification, and check results.

65%
Verified

Setting a maximum number of steps, timeout duration, and cost ceiling for each Agent can prevent Agents from falling into infinite loops that consume tokens and API quotas.

65%
Verified

Each iteration cycle of an Agent consists of three phases—model inference, tool invocation, and result return—and latency accumulates at every step

65%
Verified

In workflow-type agents, the execution path is pre-designed by humans, whereas an Agent Loop lets the model autonomously plan what to do next.

65%
Unverified

在Agent Loop中如果只将工具结果塞回messages而漏掉assistant消息,模型会陷入无限循环,不断重复调用工具

90%
Unverified

Agent Prompt模板通常包含四个部分:System Message、Chat History、User Input和Agent Scratchpad

85%
Unverified

OpenAI Codex CLI本质上是一个在本地终端运行的Agent循环(ReAct Loop),每一轮迭代包含思考、行动、观察三个步骤

85%
Partially Verified

Claude Code's Agent Loop is responsible for sending user messages to the Claude model, parsing the tool-call instructions returned by the model, executing tool operations, and feeding the results back to the model for iterative execution.

65%
Unverified

An agent is essentially a large model plus tools plus a loop (Agent Loop) and is a special type of workflow; a workflow is a more foundational concept that supports mechanisms such as parallel, serial, conditional branching, and Map-Reduce.

60%
Unverified

The "Loop" in Loop Engineering and the "Loop" in Agent Loop are not the same concept: the former is a loop of multiple Skill calls and multi-Agent collaboration, while the latter is a loop of tool calls and reasoning.

60%
Unverified

In multi-step tasks, small errors at individual steps accumulate progressively into a snowball effect, where errors in early steps contaminate the input context of subsequent steps

60%
Unverified

A typical Agent execution loop includes perception, reasoning, action, and observation, forming the ReAct (Reasoning + Acting) pattern

60%
Unverified

The project uses an Agent loop (ReAct architecture) to allow the LLM to autonomously determine the next action based on the current page state, rather than executing pre-set scripts.

60%
Unverified

Anthropic mentions that limiting the number of loop rounds is a common practice to prevent an Agent from falling into an infinite loop.

50%
Unverified

The difference between an Agent Loop and a single API call in tool calling is that a single call has no tool-calling capability and can only output text, while an Agent Loop can call tools such as the file system, databases, and external APIs.

50%
Unverified

An Agent Loop must include the three stages of "parse -> execute -> backfill" to handle tool calls, and an error in any stage will cause the loop to spin idle.

50%

Source Articles