Vibeleaderboard
← Glossary
Glossary · Tools and execution

Agent loop

Also: reason-act-observe loop

A cycle in which an agent observes, decides, acts, and interprets the result.

The loop turns a model call into an agent by allowing repeated interaction with state and tools. Completion detection, action limits, error handling, and tool-result interpretation determine whether the loop converges or wanders.

Put the idea to use

Suppose you ask an agent to fix a failing test. It reads the failure, chooses a change, edits the code, and runs the test again. The new result informs its next action. That repeated interaction is the loop; each result should change what the agent knows about the task.

Repeating an action is not progress by itself. Define the result that counts as success and a point at which the agent should stop or ask for help. Otherwise a tool error can send it through the same unsuccessful action repeatedly.

Background: LangChain: agents and tools.