WTF is Agentic Loop?
The core cycle of an agent: call the model, run the tools it asks for, feed results back, repeat until done.
Also called: agent loop, tool loop
TL;DR
Strip away the hype and most agents are a while-loop. The model decides the next step, your code carries it out, the result goes back to the model, and it continues until it decides the task is finished (or hits a limit).
How it works
Each iteration sends the conversation plus tool definitions to the model. If the response contains tool calls, the harness executes them, appends tool results and loops; if it contains only a final answer, the loop exits. Production loops add guardrails: max iterations, token and cost budgets, timeouts, human approval for risky actions, and context compaction when the history grows too large.
Example
messages = [{"role": "user", "content": task}]
for _ in range(MAX_STEPS):
reply = model(messages, tools=TOOLS)
messages.append(reply)
if not reply.tool_calls:
break # model says it's done
for call in reply.tool_calls:
result = run_tool(call) # your code executes
messages.append(tool_result(call, result))Origin
- Coined / introduced by
- Agent builders
- When
- 2023
- Story
- Emerged from ReAct-style agents and the 2023 wave of autonomous agent projects; standardised once tool-calling APIs became common.