Lesson 09 of 13 · AI that takes action
Agents
An agent is a model that works in a loop: decide the next step, use a tool, look at the result, and repeat until the goal is reached. What makes something an agent rather than a chatbot, how planning and memory work, when several agents work together, why agents fail in new ways, and how much freedom to give one.
From answering to doing
| Chatbot | Tool-using assistant | Agent | |
|---|---|---|---|
| Does | Answers | Answers, using a tool or two | Works towards a goal over many steps |
| Who decides the steps | — | Mostly fixed by the app | The model, step by step |
| Example | "Explain DNS" | "What's the status of order 1042?" | "Find why checkout errors rose since yesterday and draft a fix" |
The agent loop
goal: "Find why checkout errors rose since yesterday"
┌────────────────────────────────────────────────────────────────────┐
│ THINK "Start with the error rate by service" │
│ ACT query_metrics(service=*, metric=errors, since=24h) │
│ OBSERVE payment-api errors rose at 14:05; others flat │
│ THINK "What changed at 14:05?" │
│ ACT list_deployments(service=payment-api, since=24h) │
│ OBSERVE v2.31 deployed at 14:03 │
│ THINK "Compare the error logs before and after" │
│ ACT search_logs(service=payment-api, level=error, since=14:00) │
│ OBSERVE "timeout calling fraud-check: 2s"; config change in v2.31 │
│ … │
└──── until done, or a step/time/cost limit is hit ──────────────────┘
answer: summary, evidence, suggested fix → a person decides
Each turn is the same mechanism as lesson 8 (a tool call and a result). What is new is that the model chooses the next step based on what it just learned.
A chatbot is like asking a friend a question. An agent is like asking a friend to sort out a problem: they go and look, try something, see what happens, try something else, and come back when it's fixed, or when they need your permission to do something big.
Planning and memory
- Planning: good agents first write a short plan ("1. check metrics, 2. check deployments, 3. compare logs") and revise it as results come in.
- Short-term memory is the conversation so far: every thought, call and result. Long tasks fill the context window (lesson 3), so agents summarise or drop older steps.
- Long-term memory is notes saved to a file or database ("this team deploys on Tuesdays") and loaded into future tasks. It is a product feature built around the model.
Several agents together
For big tasks, an orchestrator agent splits the work and gives parts to sub-agents with their own instructions and tools (one searches logs, one reads code, one writes the report). This keeps each context focused and lets work run in parallel. It also multiplies cost and makes failures harder to trace, so it is worth it only when the parts are truly independent.
How agents fail
| Failure | What it looks like |
|---|---|
| Compounding errors | A wrong guess in step 2 shapes steps 3–20 |
| Loops | Repeats the same failing action |
| Going off-task | Fixes something unrelated, or does more than asked |
| Overconfident "done" | Reports success without checking the result |
| Over-broad permissions | A small mistake becomes a big incident |
| Hijacked by content | Follows instructions hidden in a web page or email it read (lesson 12) |
How much freedom to give
Think of it as a dial, set per action rather than per agent:
suggest only ─► act, then show for review ─► act with approval for risky steps ─► fully automatic
(safest) (only for low-risk,
reversible work)
Good defaults: least-privilege tools, read-only first, step, time and cost limits, human approval for anything irreversible or outward-facing, and every step logged. Define how "done" is checked (tests pass, the page loads) instead of trusting the agent's own word.
Recap
- An agent is a model in a think → act → observe loop, choosing its own steps towards a goal.
- Planning and memory let it handle longer tasks; sub-agents split big ones.
- Agents fail by compounding errors, looping, overreach and hijacking.
- Limit tools and budgets, require approval for risky actions, log everything, and verify the result independently.
This site is a public version of my personal engineering knowledge hub. It intentionally excludes confidential company information and internal operational details.