Artificial Intelligence: A Visual Learner's Series
Part 12: AI agents
How a model becomes an agent: a loop that decides, acts and checks, with tools, memory, teammates and guardrails.
The agent loop
In one line: An agent is a model in a loop: decide, act, observe, and repeat until the goal is met or a limit is hit.
"Find a time Sam and I are both free": check your calendar, check Sam's, Tuesday fails, try Wednesday, send the invite.
A workflow follows steps people wrote in advance; an agent chooses its own. Many systems sit in between.
Watch out: If the steps are known in advance, a fixed workflow is cheaper, faster and easier to test.
Tools
In one line: A tool is a named function with a description and typed inputs; the model asks for it, and the program around the model runs it.
Model asks: {"tool": "check_stock", "args": {"item": "mug"}}
Program: checks the request against the schema, runs check_stock("mug")
Model sees: 4
Model asks: {"tool": "place_order", "args": {"item": "mug", "qty": 2}}
Tools range from read-only (search, look up) to side effects (send, buy, delete), some irreversible.
Common tools: web search, running code, files, email, calendars, and computer use (clicking and typing on a screen). Standards like the Model Context Protocol (MCP) let one tool work with many agents.
Watch out: Agents choose tools by their descriptions, so a vague description leads to the wrong call.
Planning and memory
In one line: An agent thinks a step ahead, checks each result, revises its plan, and keeps notes it can find later.
Thought: The test fails. Read the error first.
Action: run_tests()
Observation: error in config file, not in the code
Thought: Not what I expected. Update the plan.
Action: open_file("config")
...
Action: run_tests() ← check the fix, don't assume it
Action: save_note("tests need the database running")
ReAct alternates thought, action and observation; plan-and-execute plans first and replans when surprised.
Short-term memory = the context window (limited); long-term memory = notes and databases outside the model, searched when needed.
Watch out: A plausible plan can still be wrong. Check results against the world, not against the plan.
Many agents
In one line: Split a big job: an orchestrator delegates pieces to workers running in parallel, and a reviewer checks the result.
Other patterns: parallel attempts (keep the best), generator and evaluator (critique and repeat), handoffs to a specialist agent.
Watch out: More agents cost more, and a reviewer built on the same model can share the writer's blind spots.
Reliable and safe
In one line: Test over many runs, limit what the agent can touch, and make a person approve the actions that matter.
Errors compound: the chance of finishing a task when every step must succeed.
| Steps in the task | Each step 95% reliable | Each step 99% reliable |
|---|---|---|
| 1 | 95% | 99% |
| 5 | 77% | 95% |
| 10 | 60% | 90% |
| 20 | 36% | 82% |
Evaluate over many tasks and runs, and inspect the trajectory (every action), not just the final answer.
Least privilege: only the tools a task needs. Budgets cap steps, time and spending.
Prompt injection: text in a web page or email can try to steer the agent, and for an agent, words can become actions.
Watch out: People shown hundreds of approval requests stop reading them, so save approvals for the actions that matter.
Self-test
Redraw the agent loop for an agent that books a restaurant table, and mark where it should stop and ask you.
Draw the tool-call round trip for a weather tool, labeling which parts the model does and which the program does.
Sketch an orchestrator with workers for planning a three-city trip, then add a reviewer and what it checks.
Draw the guard pipeline for an agent that can send email, and mark which guard stops "email my whole contact list."