Anatomy of an AI agent
An AI agent is more than a model: it is a loop with a goal, tools, state and stopping rules..
What you will learn
- Explain: a bounded agent loop
- Apply the idea in an example: Anatomy of an AI agent
- Recognize limitations and verify the exercise outcome
An AI agent is more than a model: it is a loop with a goal, tools, state and stopping rules.
You can follow this course without an account or programming. Examples use synthetic data and AI outcomes need checking.
How it works, step by step
A bounded agent loop
An agent combines a model with tools, a goal and state. It observes the request, chooses a step, receives a result and decides whether to continue. A chatbot may only generate text; an agent may request an external action. Commercial definitions vary, so inspect actual control. Define success and stopping: a verified result, a maximum step count, repeated errors or an exhausted budget. Use narrow capabilities and minimal permissions. Useful autonomy means freedom within boundaries enforced by software.
The model proposes, the tool executes
Tool calling produces a call request with a name and arguments. The application validates the schema, permissions and limits before execution. The result returns to context for the next step. For example, get_product_stock takes a SKU and returns a quantity; its description should explain that it does not reserve products. Distinguish empty results, validation errors, missing access and timeouts. Valid JSON does not prove the arguments are correct or the action is authorized. For external effects, also consider duplicate execution.
Context is the workbench
Context includes instructions, the current request, relevant history, retrieved documents and tool results. The context window has limited capacity; reserve room for the response too. More text does not automatically improve accuracy. Irrelevant information and contradictions can hide important evidence. Summarize history carefully and preserve the origin of facts. State describes the current run, a checkpoint saves a resumable point, and persistent memory retains information across runs. These are different mechanisms managed by the application.
The visual map
Follow the solid arrows for the main flow. Dashed blue arrows supply data or context; dashed pink arrows show feedback or returning results. Colors and shapes distinguish models, stores, decisions and outputs. On smaller screens, scroll horizontally to follow the entire diagram.
A complete example
The customer asks for LX-240 stock. The agent identifies the SKU, calls get_product_stock, receives quantity=3 and answers. It does not reserve anything because the tool is read-only.
Try it yourself
- Describe the input, call, result and stopping condition.
- Record the input, source and expected outcome before running the experiment. Use only the fictional data in the example.
- Follow the diagram stages. At every step record what information is received and produced; do not confuse intermediate output with the final outcome.
- Repeat after removing necessary information or making the input ambiguous. Check whether the system clarifies, stops or invents an answer.
- Compare with the explained solution. Keep the configuration, date, result and an explanation for differences. Change one thing and retest.
An explained solution
The answer reports three units at lookup time and does not promise a reservation. A successful exercise lets you show the connection between input, stages and outcome. When information is missing, a cautious answer is more useful than invented details. Compare more than style: check conditions, sources and operations too.
When it helps and what can go wrong
An available tool need not be used unnecessarily. Choose this approach when it improves a measured need. Keep a simple baseline and compare outcomes using identical inputs. One successful example does not establish reliability in every situation.
Check your understanding
Does more autonomy always give a better result?
No. It also increases room for errors, costs and unnecessary actions.
Who executes a call proposed by the model?
The application or host service after validation. The model does not automatically gain unrestricted access.
What outcome should this exercise produce?
The answer reports three units at lookup time and does not promise a reservation.
Words to remember
- Agent: A system that can choose steps and use tools toward a goal.
- Tool calling: A structured request to use an external capability.
- Checkpoint: Saved state used to resume an execution.
Sources and your next step
To prepare: F06 — Chatbot, assistant, agent and agentic system · P01 — Prompt engineering without magic formulas · P04 — How to choose a suitable AI model