Where a request enters the system, and what separates an agent from a chatbot or a fixed workflow.
Learn · Build · Measure
A coding agent, taken apart one piece at a time
Tiny Agents is me learning how AI agents actually work by building a small coding agent from first principles, across 36 five-minute lessons. The diagram below is the progress tracker: every box is a piece of the architecture, and it stays locked until I’ve worked through the lessons behind it.
5 / 36 lessons written0 in progress0 of 12 components live
The architecture
Click or Tab to a box · Esc clears
- User & taskin progress3 lessons
- Modelin progress4 lessons
The LLM decides what to do next. It never executes anything itself — it only asks.
- Agent loopin progress3 lessons
observe → decide → act → observe → … → stop. The one idea everything else hangs off.
- Tool beltlocked3 lessons
The actions the harness is willing to execute, and how their interfaces are designed for a model.
- Code searchlocked2 lessons
Finding the few relevant files instead of pushing a whole repository through the context window.
- Edit & patchlocked1 lesson
How a model turns an intention into a file change: whole-file, search/replace, diff or structured patch.
- Environmentlocked3 lessons
Build, tests and dependencies. The compiler is an oracle: actions here produce objective feedback.
- Guardrailslocked3 lessons
Sandboxing, approvals and the points where autonomy should stop and a human or a check takes over.
- Context & memorylocked3 lessons
What gets placed in the window each turn — and the several different things "memory" actually means.
- Patternslocked8 lessons
Chaining, routing, fan-out, orchestrator–workers, evaluator–optimizer, handoffs. All of Part III.
- Tracinglocked1 lesson
You need the whole trajectory — every model call, tool call and output — not just the final answer.
- Evaluationlocked2 lessons
Outcome, intermediate actions, efficiency, safety and robustness are separate measurements.
The curriculum
36 lessons · 5 parts
Part I — What actually is an agent?
- 01Chatbot vs workflow vs agentWhy calling an LLM isn't an agent; what "model controls the loop" means.
- 02The agent loop
observe → decide → act → observe → … → stop. This is the central concept for everything else. - 03The augmented LLMHow an ordinary model becomes useful through tools, retrieval and state.
- 04Tools and function callingThe model doesn't "run Python": it emits a special token the harness reads as a request, and runs it.
- 05What is the agent harness?Why the model and the agent are different things. The harness owns tools, context, permissions, execution and the loop.
- 06Where does planning live?Explicit plans vs implicit/receding-horizon planning; why agents don't necessarily need a separate planner.
Part II — Take apart a coding agent
- 07A coding agent from first principlesUser → repo → model → inspect files → edit → run → inspect errors → edit again.
- 08The coding-agent tool belt
read,grep/search, edit/patch, shell, test, git, browser/MCP. - 09Agent–computer interfaces (ACI)Why designing good tools for an LLM is analogous to designing a good IDE for a human.
- 10How the agent finds relevant codeWhy stuffing an entire repository into context performs badly.
- 11Repo maps and code retrievalSymbols, dependency graphs, semantic search, targeted file loading. Aider is a particularly nice concrete example.
- 12How agents modify filesWhole-file generation vs search/replace vs unified diffs vs structured patch tools.
- 13The compiler/test suite as an oracleThe crucial coding-agent advantage: actions produce objective feedback.
- 14The debugging loopRun → error → diagnose → modify → rerun. Why this makes coding highly agent-friendly.
- 15The environmentDependencies, build system, test setup, configuration and repository instructions such as
AGENTS.md. - 16SandboxingWhy you shouldn't give an autonomous LLM unrestricted shell/network/filesystem access.
- 17Approvals and permissionsRead automatically; perhaps ask before destructive/network/external actions.
- 18Long-running coding agentsCheckpoints, context compaction, summaries, state and recovering after failed approaches.
Part III — Generic agent architectures
- 19Prompt chainingFixed pipeline: A → B → C. Useful, but technically a workflow rather than an autonomous agent.
- 20RoutingOne model/classifier decides which specialist/prompt/tool handles a request.
- 21ParallelisationFan-out/fan-in: ask multiple workers or independently solve pieces of a problem.
- 22Orchestrator → workersOne model dynamically decomposes a task and delegates unpredictable subtasks. Particularly relevant to coding.
- 23Evaluator → optimizerOne agent generates; another critiques; generation repeats.
- 24Multi-agent systemsWhy "more agents" isn’t automatically better and often just adds coordination problems.
- 25Agents-as-tools vs handoffsA manager calling a specialist versus transferring control to another agent.
- 26LLM orchestration vs code orchestrationWhich decisions should be probabilistic and which should remain deterministic code.
Part IV — Context, memory and infrastructure
- 27The context window is working memoryWhy agent "intelligence" depends heavily on what information gets placed in context.
- 28Context engineeringSelecting instructions, history, tool outputs and retrieved material at every turn.
- 29Memory isn't one thingConversation state, scratchpad/work state, semantic memory, episodic memory and persistent user memory.
- 30MCPA standard interface to external tools — and "code mode", where the model writes code against it.
- 31TracingWhy you need the full trajectory — model calls, tool calls and outputs — not merely the final answer.
- 32Human-in-the-loop and guardrailsWhere autonomy should stop and deterministic checks or humans take over.
Part V — Why some agents are much better than others
- 33How to evaluate an agentOutcome success, intermediate actions, efficiency, safety and robustness are separate things.
- 34SWE-bench and coding-agent evalsRepo + issue + executable tests gives you unusually strong ground truth.
- 35How coding agents get trainedRL on real software environments, tool use, executable rewards, instruction following and preference signals.
- 36Build the architecture yourselfDraw a coding agent and then generalize it into a research/customer-support/scientific agent. This is your "exam."