In words
What it is, why it matters, and what it is like.
Why am I learning this?
Understanding the executor unlocks the rest of the agent stack. Before this page, you know what an agent is — a model that plans, calls tools, observes results, and iterates. What you don't yet know is what actually runs that loop, what enforces the rules that stop it from running forever, and where the reliability of real agent systems is decided. This concept sits directly beneath Build an AI Agent (From Scratch) — the executor is the runtime that framework's message loop plugs into. It also sets you up for Agent Memory, because the executor manages the state that memory reads and writes. And it earns you a seat at the table for Agent Communication Protocols and Agent Cards, since every agent, however it talks to others, needs an executor to stay alive. Read this and you'll never again look at an agent framework as magic — you'll see it as a disciplined loop with a safety harness.
The idea, in plain terms
An agent is a loop: decide, act, observe, repeat. A large language model makes the decisions — it reads the situation and proposes an action, like 'search the web for flight prices' or 'send this email'. But something has to actually carry that action out. Something has to call the search engine, take the result it returns, and hand it back to the model so it can decide what to do next. That something is the executor. Think of the executor as the stage manager of a play. The actor (the model) says 'I will now call the search tool'. The stage manager (the executor) actually goes offstage, makes the call, waits, and brings the result back to the actor. The stage manager also keeps the whole production from collapsing: if the phone line is down, it tries again. If the actor calls 'search' a hundred times in a row, the stage manager says 'that's enough, we're closing the show'. If something unexpected happens — the search tool returns nonsense — the stage manager catches the error and tells the actor 'try something else'. The model is the imagination; the executor is the hands. Without the executor, the model would just talk about doing things, forever, like a playwright who never leaves the study. The executor is what makes a plan real.
An analogy
Imagine you're a manager at a busy office. One of your employees, let's call her Priya, is brilliant at figuring out what needs to be done but she's terrible at details. She'll say 'We need to call three suppliers and order the parts.' She doesn't care about the phone number's country code, or what to do if the line is busy, or whether it's okay to call after 5pm. Your job is to actually do it. You have a checklist: call supplier A, note what they said. If the line is busy, wait two minutes and call again. If it's still busy after three tries, mark it as failed and move on. If the supplier says 'we don't carry that part', you write that down and tell Priya what happened, so she can adjust her plan. You also have a rule: no more than ten phone calls total, because the day has to end sometime. This is exactly what an executor does. Priya is the model, the phone is the tool, your checklist is the executor's logic. The analogy starts to break down when you notice that the executor is not a person with judgment. It does not understand the meaning of the supplier's reply. It only knows 'the tool returned a string of text' and 'I must pass this string to the model'. Where a human manager might read between the lines — 'that supplier sounds annoyed, maybe try someone else' — the executor is gloriously literal. It follows rules exactly, every time, with no boredom and no improvisation. That's a feature: predictability is what makes the executor testable. The model can be creative; the executor must be mechanical.
Definition
An agent executor is the runtime layer that drives the agent loop — it takes the model's decision, runs the chosen tool call, catches and handles errors, tracks how many iterations have happened, enforces time limits and retry rules, and passes the result back so the loop can continue until a termination condition is met.
Where this sits
You have already mastered the large language model itself — how it generates text, how attention works, how it produces one token at a time. The executor builds on that in a crucial way: the model's output is text, but the agent needs to turn that text into an action. The bridge is tool calling, and the executor is what performs that bridge. The learner's library notes on the Agent Loop point to the same core — 'the cycle at the heart of every agent: receive context, decide an action, execute it, observe the result, repeat until done' — and the executor is precisely the 'execute' and 'observe' parts of that loop. It also connects to Agent Memory, because the executor holds the running state of the conversation and decides what to keep. And it connects to Build an AI Agent (From Scratch): that course walks you through building a message loop and tool calls from first principles, and this page gives you the underlying executor that makes that loop safe and reliable.