An interactive course on agent architecture
How AI Agents Work
An agent is not a mind that thinks all the time. It is a loop of ordinary code that calls a model, runs what the model asks for, and repeats. Every advanced idea in this course is something added to that loop.
The one loop behind every agent
- State: what your code holds
- Build context: choose what the model will see
- Call model: one computation, nothing remembered
- Model decides: an answer or a requested action
- Runtime acts: check the request, then run it
- Update state: record the result, then repeat
Two of the six steps belong to the model. The other four are code you own. Each chapter opens with this map and shows which step it extends.
Colors mean roles
Every diagram and widget uses the same colors, always with a label.
- Model The model: one call, context in, response out.
- Your code The runtime: the loop, the rules, and running tools.
- Tool Tools and the outside world.
- State State, memory, and storage.
- Context What the model sees in one call.
- Human A person: user, approver, reviewer.
What you will be able to do
By the end, you should be able to ask an AI coding system for something like this, and know exactly what you asked for:
"Build an agent with isolated subagents, durable task state, filesystem tools, human approval for dangerous actions, context compaction, and persistent project memory."
You will know what each phrase means, why you might want it, the alternatives, and what can go wrong. Chapter 21 decodes the sentence term by term.
How to use this course
- Read the parts in order. Each one builds on the loop from the parts before it.
- Use the widgets. Step through them slowly and watch what the model can see at each step.
- Answer the "Check yourself" questions before you open the answers.
- Do the design checkpoint at the end of each part. You apply that part's ideas to a new agent before you see a reference design.
- Follow Patch, the running example. It is a coding agent that gains one capability per chapter.
- Use the 31 questions as a final self-test and the glossary when a term turns vague.
Progress, ticks, and your exercise notes are saved in this browser only. Nothing is sent anywhere.
Course map
Start hereWhat separates a model from an agent.
The core loopThe loop, its tools, its state, and what the model sees.
- 01The agent loopObserve, decide, act, repeat. The loop every agent runs, and how it ends.
- 02ToolsA tool call is a structured request. The runtime decides whether and how to run it.
- 03StateConversation, runtime state, world state, persistent state. Who holds what.
- 04ContextThe model sees only what you put in front of it. Choosing that is the central design problem.
Capabilities built on the loopMemory, planning, subagents, skills, and coding agents.
- 05MemoryStorage, a write policy, retrieval, and injection. Not the model remembering.
- 06Planning and reflectionA plan is a maintained list of intended actions. Reflection is another model call.
- 07SubagentsAnother loop with its own context. When delegation helps and when it costs too much.
- 08SkillsSix things people call a skill, and what each reduces to.
- 09Coding agentsA few file and shell tools, a fast feedback loop, and a capable model.
Control and safetyWhat the agent can touch, and when a person decides.
- 10SandboxingInstructions, gates, containment, external controls. Which one actually stops the attack.
- 11Human in the loopPause, persist, ask, resume. Approval bound to one exact action.
SystemsLong-running work, communication, and architecture.
- 12Long-running agentsCheckpoints, queues, retries, idempotency. Agents turn into distributed systems.
- 13Agent communicationShared state, messages, events, queues, return values, blackboards, databases.
- 14Agent architecturesFrom one agent to hierarchies, as composable choices with costs.
QualityHow agents fail and how to measure them.
- 15ReliabilityThirteen ways agents fail: why, how to detect it, how to mitigate it.
- 16EvaluationMeasuring whole runs, not single answers.
Real systemsHermes, Deep Agents, Pi, and others as case studies.
- 17Framework case studiesHermes, Deep Agents, Pi, and others. Which general ideas each one implements.
- 17bComparison tableThe same concepts side by side across systems.
Thinking like a designerAttribute gains, own the decisions, practice designs.
- 18Model capability vs agent architectureWhen an agent gets better, which lever caused it?
- 19What AI builds vs what you designThe decisions you own even when AI writes all the code.
- 20Architecture exercisesTen design scenarios, each with one reasonable architecture.
- 21The design briefDecode the target sentence. Write a brief an AI coding system can build from.