Area 03 of 08
AI Agents
Models that use tools in a loop to get things done: the agent loop, memory, MCP, multi-agent patterns, frameworks, and keeping agents safe and affordable.
Printable cheat sheet for this area
- 047
Workflows vs agents
A workflow is a fixed sequence of steps your code controls, with LLM calls filling in specific blanks; an agent lets the model decide the steps itself in a loop; most products should start with a workflow and only use an agent where the path really can't be planned in advance.
CoversWorkflows vs agents (when not to use an agent) · Flow engineering (designing the steps around the model)
- 048
Tool calling
Tool calling is how agents act, and doing it well means designing clear tools, running several calls from one turn and returning all their results together, sending errors back to the model instead of crashing, and checking every argument and permission in your own code.
- 049
The agent loop and the ReAct pattern
Every agent runs the same loop (the model looks at the situation, decides on an action, the action runs, the result is added to the context, repeat until done), and ReAct is the classic recipe for it, interleaving reasoning ("Thought"), tool use ("Action") and results ("Observation").
CoversThe Agent Loop · ReAct Pattern
- 050
Planning and reflection
Planning means the agent writes down the steps before acting and keeps the plan updated, and reflection means it checks its own work (or has it checked) and revises, both of which make long, multi-step tasks far more reliable.
CoversPlanning · Reflection
- 051
Short-term and long-term memory
Short-term memory is what an agent keeps in its context window during one conversation or task, and long-term memory is information saved outside the model (facts, preferences, past results) and looked up again in later sessions.
CoversShort-term Memory · Long-term Memory
- 052
Context engineering and compaction
Context engineering is deciding exactly what goes into the model's context window at each step (instructions, tools, retrieved knowledge, memory, history, tool results) within a budget, and context compaction is shrinking a long history into a summary so long-running agents keep working without running out of room.
CoversContext Engineering · Context Compaction
- 053
MCP: servers and clients
The Model Context Protocol (MCP) is an open standard for connecting AI apps to tools and data, so a tool written once as an MCP server can be used by any MCP client (Claude, ChatGPT, IDEs, your own agents) instead of building a custom integration for every app.
CoversMCP Servers · MCP Clients
- 054
Agent skills
An agent skill is a folder with a SKILL.md file (a name, a description and instructions, plus optional scripts and reference files) that an agent loads only when a task needs it, so agents can carry many specialised abilities without filling their context.
- 055
Harness engineering: everything around the model
An agent is a model plus a harness, the system around it (instructions, tools, context management, permissions, hooks, verification and memory), and harness engineering is designing that system so the agent works reliably; in 2026 it became the main place teams invest after prompt and context engineering.
CoversHarness engineering (agent = model + harness) · Prompt, context, harness and loop engineering: how they fit · Agent instruction files (AGENTS.md, CLAUDE.md) · Hooks and mechanical enforcement
- 056
Multi-agent handoffs and orchestrator-worker
Multi-agent systems split work between several agents, either by handing a conversation from one specialist to another (handoffs) or by having an orchestrator break a job into parts that worker sub-agents do in parallel, each with its own focused context.
CoversMulti-agent Handoffs · Orchestrator-Worker Pattern · Subagents
- 057
LangGraph, state and checkpoints
LangGraph builds agents and workflows as graphs of steps (nodes) connected by edges, with a shared state object that every step reads and updates, and checkpoints that save that state after each step so runs can pause, resume, recover from crashes and be inspected.
CoversLangGraph · State and Checkpoints
- 058
The OpenAI Agents SDK and other frameworks
The OpenAI Agents SDK is a small Python library with a few building blocks (agents with instructions and tools, a runner that executes the loop, handoffs, guardrails, sessions and tracing), and it sits among other frameworks like the Claude Agent SDK, LangGraph, CrewAI, AutoGen and LlamaIndex, each with a different focus.
CoversOpenAI Agents SDK · Other frameworks at a glance (Claude Agent SDK, CrewAI, AutoGen, LlamaIndex)
- 059
Human in the loop
Human in the loop means the agent pauses at important moments (before a risky action, when it's unsure, or to get missing information) so a person can approve, edit or reject, and the agent resumes from exactly where it stopped.
- 060
Stop conditions, errors and cost control
Agents need clear rules for when to stop (task done, step or token budget used, time up, stuck in a loop), sensible handling of tool and model errors (retry, back off, report), and cost controls so a confused agent can't run up a large bill.
CoversStop Conditions · Error handling and retries in agents · Cost and loop control
- 061
Loop engineering: agents that run on repeat
Loop engineering is designing the automated loops around agents (what triggers a run, how each result is checked, when the loop stops, what it may cost, and where humans review) so agents do useful work repeatedly without someone prompting them step by step.
CoversLoop engineering · Maker-checker (verifier) loops · Scheduled and event-triggered agent runs · Long-running autonomous agents
- 062
The A2A protocol
A2A (Agent2Agent) is an open protocol that lets independent agents, built by different teams on different frameworks, discover each other through an Agent Card, send each other tasks, and get results back, without exposing their internal prompts, tools or memory.
- 063
Coding agents and computer-use agents
Coding agents read, edit and run code in a repository using file, search and shell tools, verifying their work with tests, while computer-use and browser agents operate graphical interfaces by looking at screenshots and clicking and typing like a person.
CoversCoding agents · Vibe coding vs agentic engineering · Computer-use / browser agents
- 064
Capstone: build an agent without a framework
You build a complete agent in one file (three tools, the agent loop, stop conditions, error handling and a real Claude model, plus an offline scripted mode for tests), so you understand exactly what every agent framework does under the hood.