The Agentic Loop: Three loops in a trench coat

This technical post breaks down the architecture of 'agentic' AI systems into three distinct loops: inference, tool usage, and chat history management. It provides a conceptual framework for developers building autonomous AI agents.
Why it matters
It provides a foundational understanding of how modern AI agents are engineered to perform complex, multi-step tasks.
Agent loops are often oversimplified. They’re presented as a single loop, when really it’s three loops in a trench coat that make up an “agentic” experience for a customer. I’m here to write (yes, I wrote this, insane right?) yet-another-blog about agent loops. The example code blocks are also pseudo-code and for illustrating these ideas. Also I’ve omitted streaming, which complicates the post but the shape of these stays the same.
I even made this image! The Inference Loop The most reductive way to explain Large Language Models is that they take text, and predict the next charact... err... tokens. Unlike your ex, they really do complete your sentences. This is achieved with an inference loop.
Your inference loop has three responsibilities:
Make chat completion API calls (infer the next words)
Pass a tool usage request to your tool loop (more later)
Get smarter about the news
Sign up free for a feed built around what you actually care about, Dive Deeper research on any story, and the full text of every article.
Create free accountAlready have an account? Sign in