Learning path
Next moduleModule 20: Production AI engineering
Module 19
Agents and tool use
Let models act: tool calling with JSON schemas, the agent loop, context and memory, MCP, workflows versus agents, and the engineering that makes agents reliable.
- 1. Tool use and agentsExplain how tool calling works from JSON schema to executed call, run the agent loop with stopping conditions and context budgets, use MCP to connect tools, and decide when a fixed workflow beats an autonomous agent.45 min
- 2. Building reliable agentsQuantify how errors compound over agent steps, design tools agents use well, contain actions with permissions and approvals, decide when multi-agent systems pay off, and evaluate, observe, and budget agents in production.40 min
- 3. Agent memoryGive an agent memory that outlasts its context window by paging between a bounded prompt and an external store with memory tools, size the context budget, and defend memory against rot and poisoning.40 min
- 4. Model Context ProtocolExplain how MCP connects AI hosts to tools, resources, and prompts over JSON-RPC, build a stdio server and client from scratch, and design MCP servers with the right error, state, and trust boundaries.40 min
- 5. Multi-agent systemsRecognize the single-agent ceiling, choose between pipeline, fan-out, orchestrator-worker, and peer designs, compute their token and latency cost against a single agent, and build an orchestrator that hands out briefs and merges summaries.40 min
An agent is a model in a loop: it reads the context, calls a tool, sees the result, and decides what to do next. The model only proposes actions; the runtime validates, authorizes, executes, and stops them. This module covers how that loop works and how to make it reliable, safe, and affordable.
| Piece | What it does | Failure mode |
|---|---|---|
| Tool schemas | describe each tool's name, purpose, and arguments | vague names or overlapping tools, so the wrong one is picked |
| Structured output | model emits a schema-valid tool call | valid JSON with wrong values |
| Runtime | validates, authorizes, executes, appends results | side effects without checks or approval |
| Context | short-term memory, re-read every step | token cost grows quadratically; overflow |
| Long-term memory | notes stored and retrieved across tasks | stale or injected memories |
| Stopping conditions | final answer, step and cost limits | infinite loops, runaway spend |
| Evaluation and tracing | task suites, trajectories, pass^k, traces | demo-driven confidence |
| # | Lesson | You will be able to |
|---|---|---|
| 1 | Tool use and agents | trace a tool call end to end, compute context and token growth, explain MCP, and choose between workflow patterns and an agent |
| 2 | Building reliable agents | quantify compounding error, design tools and guardrails, decide on multi-agent designs, and evaluate and observe agents |
| 3 | Agent memory | size a context budget, page facts between the prompt and an external store with memory tools, and defend memory against rot and poisoning |
| 4 | Model Context Protocol | trace a JSON-RPC tool call over stdio or Streamable HTTP, build a stdlib server and client, and design server state, errors, and trust boundaries |
| 5 | Multi-agent systems | choose between pipeline, fan-out, orchestrator-worker, and swarm designs, and compute their token and latency cost against a single agent |
Interactive lab: Agent loop