HeadlinesBriefing favicon HeadlinesBriefing.com

The Agentic Loop: Three Loops in a Trench Coat

Hacker News •
×

Agentic loops are often oversimplified, presented as a single loop when they are actually three interconnected loops.

The first is the Inference Loop, which handles API calls to Large Language Models (LLMs). It sends system prompts, user messages, and available tools, then appends the LLM's response to a chat history. LLM APIs are stateless, requiring the entire conversation to be resent with each call.

The second is the Tool Loop. LLMs can infer the usage of tools provided in the inference loop. The tool loop must then look up and execute the correct function with the parameters provided by the LLM. It also handles potential hallucinations in tool names or parameters and correlates tool calls with responses using IDs. This loop can also incorporate error handling for tool execution.

The third, the Human Loop (or Safety/Sanity Loop), is not a programmatic loop but a crucial blocking function call for approval. It allows a human or another system to approve or deny a tool call, preventing unintended actions, such as sending a message to an ex. This loop is essential for control but introduces complexity, necessitating durable execution frameworks. Together, these three loops form the foundation of agentic systems.