Skip to content
ML to LLMs
Learning path

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. 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. 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. 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. 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. 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.

PieceWhat it doesFailure mode
Tool schemasdescribe each tool's name, purpose, and argumentsvague names or overlapping tools, so the wrong one is picked
Structured outputmodel emits a schema-valid tool callvalid JSON with wrong values
Runtimevalidates, authorizes, executes, appends resultsside effects without checks or approval
Contextshort-term memory, re-read every steptoken cost grows quadratically; overflow
Long-term memorynotes stored and retrieved across tasksstale or injected memories
Stopping conditionsfinal answer, step and cost limitsinfinite loops, runaway spend
Evaluation and tracingtask suites, trajectories, pass^k, tracesdemo-driven confidence
#LessonYou will be able to
1Tool use and agentstrace a tool call end to end, compute context and token growth, explain MCP, and choose between workflow patterns and an agent
2Building reliable agentsquantify compounding error, design tools and guardrails, decide on multi-agent designs, and evaluate and observe agents
3Agent memorysize a context budget, page facts between the prompt and an external store with memory tools, and defend memory against rot and poisoning
4Model Context Protocoltrace a JSON-RPC tool call over stdio or Streamable HTTP, build a stdlib server and client, and design server state, errors, and trust boundaries
5Multi-agent systemschoose between pipeline, fan-out, orchestrator-worker, and swarm designs, and compute their token and latency cost against a single agent

Interactive lab: Agent loop

Next moduleModule 20: Production AI engineering