Understanding Deep Agents
Learning objectives
By the end of this chapter, you will be able to:
- Place coding agents within the production agent taxonomy — the broad domain of agents (hybrid RAG, agentic apps) divides into **shallow** agents (the ReAct reason→act→observe loop) and **deep** agents, and deep agents split into deep-research agents and **coding agents** (Claude Code, Cursor, Devin, Gemini CLI) — and explain why the *application layer* (the 'agent harness') is where most current innovation happens.
- Explain the limitation of shallow agents — each ReAct iteration injects the tool result back into the prompt, so over many iterations the context grows until it suffers **context rot** (bloat, contradiction, pollution), degrading quality and raising cost/latency — and define what makes an agent **'deep'**: the ability to perform complex, long-running (long-horizon) tasks with quality and reliability, which reduces to **smart context management**.
- Name the four building blocks a deep agent typically shares — a **detailed system prompt**, a **planning tool**, **subagents**, and a **filesystem** — and recognize that **'deep agent' is a community/LangChain-articulated term, not an official Anthropic/Claude Code label** (Anthropic more commonly discusses 'long-running / long-horizon' agentic work, context engineering, and agents/workflows rather than defining 'deep agent' as an official term); map each block onto both Claude Code and the LangChain DeepAgents harness.
- Explain the **planning** block — an *explicit, dynamic to-do list* (tasks marked pending / in-progress / completed) that the agent rewrites as it works, whose real job is **context management** (keeping the current plan in the window to re-orient the agent), not computation — and know the current Claude Code surface (the `Task*` tools — `TaskCreate`/`TaskList`/`TaskGet`/`TaskUpdate` — with the book's `TodoWrite`/`TodoRead` now the *legacy* form, disabled by default), and that this dynamic to-do list is distinct from read-only **plan mode** (Chapter 6).
- Explain **subagents / hierarchical delegation** — an orchestrator (main agent) delegates a scoped task to a specialized subagent with its own system prompt, tools, and **isolated context window**; the subagent works independently and returns **only its final result** (not its intermediate steps), which both keeps the main context lean and enables parallelism — and connect it to the `Agent` tool (formerly `Task`), Chapter 7, and the orchestrator-workers pattern.
- Explain the **filesystem** block — writing intermediate state to disk instead of the context window, plus *selective retrieval* (`glob`/`grep`) to pull in only what a step needs — as the mechanism behind 'precise context selection'; ground it in the context-engineering 'attention budget' / three-box model (all-available ⊃ selected vs. required context), Claude Code's file tools (`Read`/`Write`/`Edit`/`Glob`/`Grep`/`NotebookEdit`) and memory (`CLAUDE.md` + auto-memory) — and recognize that 'the filesystem as a context engine' is an engineering *principle*, not a documented Claude Code feature name.
Before we start — agents, ReAct, "long-horizon," harnesses, and the four pillars
Skim this if you're comfortable with what an agent is, the idea of a context window filling up, and the subagents from Chapter 7. If any of that is fuzzy, read it first — this final chapter assembles ideas from across the whole book into one architecture.
An agent (recap). An agent is an LLM that doesn't just answer once — it decides, in a loop, to call tools (search, read a file, run a command), looks at the results, and decides what to do next, until a goal is met. Chapters 1–10 had you driving one (Claude Code). This chapter looks under the hood.
The ReAct loop. The original, foundational agent pattern is ReAct ("Reason + Act," from a 2022 paper): the model reasons about what to do, acts by calling a tool, receives the result as an observation, and loops — reason → act → observe → reason → … — until it can answer. Almost every modern agent traces back to this shape.
Shallow vs. deep. A shallow agent is a short ReAct loop — great for a handful of steps (look something up, call one tool, answer). A deep agent is built to run long — minutes, hours, even days — across many steps, adapting its plan as it goes. **Important and stated up front: "deep agent" is a community term (articulated clearly by the LangChain team), not an official Anthropic or Claude Code label. Anthropic's docs and engineering writing more commonly discuss long-running / long-horizon agentic work, context engineering, and agents/workflows**, rather than defining "deep agent" as an official term. We use "deep agent" because that's the chapter's title and the industry's word, but we'll keep it labeled as the conceptual framing it is.
"Long-horizon" and context rot. A long-horizon task is one needing many iterations of reasoning and information-gathering (implement a feature; research a topic deeply). The enemy of long-horizon work is context rot — the way an agent's context window fills with accumulated tool results until quality degrades (you met this in Chapters 1 and 9). Managing that is the whole game.
An agent harness. The book's word for the application layer built on top of a model to make a capable agent: a ready-to-use environment that supplies the default prompts, tool handling, planning, and file access so you don't wire it all from scratch. Claude Code is a harness; the LangChain DeepAgents package is another. Most current innovation is here, in the harness — not only in the base model.
The four pillars (one line each), which the chapter is organized around:
- System prompt — a big, carefully-written instruction set that gives the agent its reasoning framework.
- Planning tool — an explicit, dynamic to-do list the agent keeps rewriting.
- Subagents — specialized helpers that work in their own isolated context and hand back a summary.
- Filesystem — disk used as memory and as a way to pull in only the context a step needs.
How to read this chapter. Each numbered section ends with an > Analogy — … box that restates the idea in plain language. Lean on them or skim them as you like.
Why this chapter matters
Every earlier chapter taught you to operate Claude Code — permissions, MCP, hooks, subagents, output styles, the desktop app. This one is different: it's the capstone that explains the architecture underneath all of it. Why does Claude Code keep a to-do list? Why does it spin up subagents instead of doing everything in one thread? Why does it read and write files so aggressively, and lean on CLAUDE.md? The answer is a single design problem — keeping a finite context window useful across a long task — and four recurring moves that solve it.
Two payoffs make the abstraction worth your time. First, transfer: once you can see the four pillars, you can recognize them in any deep agent — Cursor, Devin, a deep-research agent, or one you build yourself with a harness like LangChain DeepAgents — and you'll know which pillar to reach for when an agent misbehaves on a long task. Second, it closes the loop on the book: the context engineering of Chapter 1, the subagents of Chapter 7, the planning of Chapter 6, and the skills/memory of Chapters 3 and 9 turn out to be the same four pillars, viewed from different angles. This chapter names the pattern they all belong to.
A note on sources and currency. The four-pillar framing is LangChain's (Harrison Chase's "Deep Agents" post), and we treat it as exactly that — a useful industry articulation, not Anthropic documentation. Claude Code behavior claims (the planning tools, subagents, file tools, memory) are verified against the official docs, which move fast: the planning tool the book callsTodoWrite/TodoReadis now the **Task*family** (the olderTodoWriteis disabled by default). And "the filesystem as a context engine" is an engineering principle (from Anthropic's context-engineering post), not a Claude Code feature name. Each of these is flagged inline and recorded in the source ledger.
Lesson
1. The agent taxonomy — where coding agents sit
Before defining "deep," the chapter draws a map of the agents actually running in production. Start at the top: the domain of agents covers everything from fully autonomous systems to lighter agentic applications — a common example being a hybrid RAG architecture where an LLM decides, step by step, whether to search, call a tool, or answer.
Within that domain, the foundational shape is the ReAct agent (Reason + Act). Its loop: the LLM decides whether to use a tool; if so, the system runs it and feeds the result back as an observation; the LLM then decides whether it has enough to answer, and if not, loops again. This loop "initiated the broader agent paradigm" — most modern agent architectures trace back to it.
The map then splits agents into two families:
- Shallow agents — short ReAct loops (the next section explains the limits).
- Deep agents — long-horizon systems, which themselves split into deep-research agents (Perplexity's and ChatGPT's "research" modes, Claude Code's research option, the open-source GPT Researcher) and coding agents (Claude Code, Cursor, Devin, Gemini CLI) — a specialized subset tailored to software-development workflows, and "one of the strongest demonstrations in the industry."
The chapter's sharpest framing is where the progress is coming from: base LLMs improve incrementally, but the application layer built on top of them is advancing fast. By composing agents and layering abstractions, you get capable systems — and that application layer is the agent harness (Claude Code, LangChain DeepAgents). The lesson: much of today's leap isn't a smarter model, it's harness engineering — how we wrap the model.
Analogy — vehicles on the road All agents are vehicles. A shallow ReAct agent is a bicycle: perfect for a quick errand a few blocks away, and a huge amount of the world's trips are exactly that. A deep agent is a long-haul truck built to run for days across the country — and a coding agent is that truck fitted out for one trade (a mobile workshop). The striking part isn't that engines got slightly better this year (the model); it's how much further you can go because someone built the truck around the engine (the harness).
2. Shallow agents and why they hit a wall
A ReAct agent is classed as shallow — not because it's useless (it's foundational and powerful), but because it can't sustain thorough, extended work. The reason is mechanical, and it's the engine of this whole chapter.
A ReAct agent runs on function calling: at each step the model picks a tool, the system runs it, and the result is injected back into the prompt. One or two iterations? Fine. But as iterations pile up, the context grows and grows — every observation stays in the window. That growth is context rot: bloat, contradiction, and pollution accumulate until the model's quality degrades and it can "go off the rails." And it costs you twice — more tokens mean higher latency and expense, for worse answers.
This is exactly the wall you hit on complex, long-running tasks — implementing a feature, deep research, a multi-stage workflow that needs continuous reasoning. They're a different animal from a one-shot request like "book a flight." For the short tasks, shallow agents are genuinely the right tool and run successfully in countless production systems. For long-horizon work, something has to manage the context instead of letting it balloon — and that is precisely what makes an agent "deep."
Analogy — a desk that's never cleared A shallow agent is someone who solves problems by piling every document they touch onto their desk and never filing anything. For a two-step task, the pile is tiny — no problem. But on a week-long project the desk becomes a mountain: they re-read contradictory drafts, lose the important page under junk, slow to a crawl, and start making mistakes. The fix isn't a smarter person — it's a system for clearing the desk. Deep agents are that system.
3. What makes an agent "deep" — the four pillars
There's no strict formal definition. In practice, an agent is "deep" if it can perform complex, long-running tasks with quality and reliability — and to do that it must solve the context problem from §2. So the defining challenge of a deep agent is context engineering and smart context management; without it, long-horizon execution breaks down.
When you examine modern deep-agent implementations, the same four ideas show up (this is the LangChain team's articulation, after studying many systems — and again, "deep agent" is their term, not an Anthropic one):
- A detailed system prompt — encodes instructions, constraints, and the agent's operational behavior (§7).
- A planning tool — the agent plans explicitly before and during execution, via a dynamic to-do list (§4).
- Subagents — specialized workers that run in isolated contexts, so heavy sub-work doesn't bloat the main thread and can run in parallel (§5).
- A filesystem — intermediate state is written to disk instead of being held entirely in context, preventing uncontrolled growth (§6).
We take the pillars below in the book's teaching order — planning first (§4), the detailed system prompt last (§7) — but each keeps the number it has in this list (so §4 covers Pillar 2, the planning tool, and §7 covers Pillar 1, the system prompt).
Notice that three of the four are, at heart, context-management moves: planning keeps the plan small and in view; subagents keep sub-work out of the main window; the filesystem keeps state off the context entirely. The system prompt is the one that supplies judgment. Together they're what let a deep agent run for hours without rotting.
Analogy — what makes an expedition, not a walk Anyone can take a walk (a shallow task). An expedition that lasts weeks needs four things a walk doesn't: a plan you revise as conditions change (planning tool), specialists you send ahead to scout and report back without dragging the whole party along (subagents), base camps where you stash supplies so you're not carrying everything at once (filesystem), and a field manual of principles for decisions no one anticipated (system prompt). Strip any one away and a long expedition falls apart — even with the fittest climbers (the best model).
4. Pillar 2 — explicit planning via a dynamic to-do list
The first thing every deep agent has is a planning tool. The key word is explicit: instead of planning implicitly through chain-of-thought reasoning buried in the model's head, a deep agent keeps a visible, dynamic to-do list — tasks marked pending, in progress, or completed — and rewrites it as it works. When a task fails, it doesn't blindly retry as a raw ReAct loop would; it updates the plan.
Here's the subtle, important part (straight from LangChain's analysis): the planning tool is almost a no-op computationally — calling it doesn't do much. Its real job is context management. Writing the current plan back into the context window re-orients the agent every few steps: "here's the goal, here's what's done, here's what's next." On a long task, that running summary is what keeps the model on the rails. It's the same thing you do naturally — break big work into tracked sub-tasks — formalized inside the agent.
In Claude Code. The planning tool is internal, but you can see it act. The book describes the actions as TodoWrite (creates/updates the to-do list, taking a {todos: Todo[]} parameter) and TodoRead (reads it). Drift to note: as of writing, that's the legacy surface — Claude Code's current task-tracking tools are the **Task* family (TaskCreate, TaskList, TaskGet, TaskUpdate, TaskStop), and the older TodoWrite is disabled by default**. (There's no documented command to view the internal task list — the checklist surfaces inline when Claude shows it; don't confuse it with the /tasks command, which is a different feature for the background tasks running in your session.) The concept the book teaches — an explicit, dynamic to-do list kept in context — is exactly right and current; only the tool names moved. (In LangChain DeepAgents the equivalent is a write_todos tool, wired in by a TodoListMiddleware.)
Don't confuse this with plan mode. Chapter 6's plan mode (/plan, the Shift+Tab cycle, --permission-mode plan) is a read-only permission mode — Claude explores and proposes a plan before it's allowed to edit anything, and you approve. The dynamic to-do list here is different: it's in-session task tracking the agent maintains while doing the work. One gates when editing is allowed; the other keeps a long task organized as it runs. They're complementary, not the same feature.
Analogy — the whiteboard the surgeon keeps glancing at In a long operation the team keeps a whiteboard: steps done, step in progress, steps to come. Writing on it doesn't perform surgery — it's "almost a no-op" — but every glance re-orients everyone to where they are in a hours-long procedure, so nobody loses the thread or repeats a step. The dynamic to-do list is the agent's whiteboard: cheap to update, and the thing that keeps a long job coherent.
5. Pillar 3 — subagents and hierarchical delegation
The second pillar is the one you already built in Chapter 7, now seen as part of the bigger picture. A deep agent uses subagents for hierarchical delegation: the main agent spawns specialized workers — each with its own system prompt, its own description, and its own set of tools — and hands each a scoped task.
The defining property is isolation. A subagent works in its own context window, executes independently, and returns only its final result — not the full chain of intermediate reasoning and observations. The main agent (the orchestrator) never sees the messy middle; it gets the clean answer. That does two things at once: it keeps the orchestrator's context lean (the sub-work's bloat stays quarantined), and it enables parallelism (several subagents can run at the same time). Efficiency and depth improve together.
This is delegation as it works in real life: you don't just assign a task — you give the right person the right tools and a clear brief, they go off and do it with their own equipment, and they bring back the outcome, not a transcript of every move. In Claude Code you've watched exactly this: the main agent spawning an exploration subagent to go search for, say, authentication patterns while it keeps working — built-in support for subagents and hierarchical delegation. Mechanically, delegation happens through the Agent tool (renamed from Task; Task remains an alias).
The pattern has a name in the engineering literature — orchestrator-workers: a central agent dynamically decomposes a task, delegates pieces to workers, and synthesizes their results (the subtasks are decided at runtime, not pre-scripted). Anthropic's multi-agent research write-up reports this style beating a single agent on a research eval — while using substantially more tokens (as reported, roughly an order of magnitude). Treat those numbers as reported background, not Claude Code mechanics; the durable point is the §3 one — isolation is a context-management move.
Analogy — the general contractor and the trades A general contractor renovating a house doesn't personally rewire the panel and re-plumb the bathroom. They call an electrician and a plumber — each shows up with their own tools and expertise, works in their own area, and reports back "done, inspected, here's what you need to know." The contractor never watches every wire stripped; they get the result and keep coordinating. That's hierarchical delegation: specialists in isolated workspaces, returning outcomes, leaving the orchestrator free to run the whole job.
6. Pillar 4 — the filesystem as persistent state and a context engine
The third pillar is filesystem access, and it's the most important context-management move of all. The idea: instead of holding every intermediate result in the context window, the agent writes it to disk — and later reads back only what it needs.
In Claude Code this is a concrete set of tools: Read (file contents, incl. images/PDFs/notebooks), Write (create/overwrite), Edit (precise string replacements), plus Glob (find files by pattern) and Grep (search contents by regex), and NotebookEdit. LangChain DeepAgents exposes a parallel interface — ls, read_file, write_file, edit_file, glob, grep — deliberately abstract, so the "filesystem" could be backed by local disk, Firestore, DynamoDB, anything. The interface is fixed; the storage is pluggable.
Why this matters — the three-box model of context selection. Picture three nested regions:
- All available context (the big box): every codebase, doc, web result, and database the agent could draw on — vast and messy.
- Selected context (what the agent actually pulls into its window this step — what it chose to read or search).
- Required context (the small box: what the task genuinely needs to succeed).
The whole job of context engineering is to make the selected set small while still fully covering the required set. When selection misses, you get the classic failure modes: under-retrieval (you grabbed only part of what was needed), misaligned retrieval (you searched the wrong place entirely), and context-window limits (you tried to grab too much and quality degraded). As Anthropic's context-engineering work puts it, the window is a finite attention budget that depletes with every token — so how information is structured and retrieved often matters more than the prompt itself.
The filesystem is the engine that makes good selection possible, in two moves: (1) write context out to persistent storage — intermediate results, retrieved info, notes — so it leaves the window instead of bloating it; and (2) select it back precisely with glob/grep (and targeted, paginated reads — "read_file(path, limit=100) to scan, then read the section you need") rather than re-loading everything. That's the same pair of context-engineering principles from Chapter 9 — write context out, retrieve it selectively — now recognizable as a building block of every deep agent. (Claude Code's memory is the same idea for durable state: CLAUDE.md for human-written instructions and the auto-memory subsystem for Claude-written notes that persist across sessions.)
Drift to note: "the filesystem as a context engine" is an engineering principle (from Anthropic's Effective context engineering post and LangChain's filesystem post), not a documented Claude Code feature name. Claude Code genuinely ships the file tools and the memory system; the "context engine" framing is the why, not a button.
glob/grep select back) to pull a small selected set that still covers what the task requires — keeping the window lean. Pedagogical diagram by this training, not from the book.Analogy — the detective's case room, not their pockets A detective on a months-long case doesn't carry every document in their coat. They keep a case room: everything filed on the walls and in cabinets (the filesystem / all available context), and for each interview they pull just the few folders that matter (selective retrieval viaglob/grep), leaving the rest on the wall. Stuff it all in your pockets and you can't find anything and your coat tears (context rot). The case room is the engine that lets one detective work a huge case without drowning in it.
7. Pillar 1 — the detailed system prompt (the cognitive baseline)
The fourth pillar supplies what the other three can't: judgment. "System prompts are important" is a cliché, but the practice of industry leaders shows how load-bearing it is — state-of-the-art system prompts run to hundreds of lines, heavily augmented with injected tool descriptions, and teams pour engineering effort into curating and refining them as models evolve. For a deep agent, the system prompt is "the fundamental architecture of its reasoning, identity, and operational behavior" — the cognitive baseline.
What makes one good leverages what strong LLMs are best at — pattern-matching and applying general rules to novel cases:
- A reasoning framework, not a flowchart. Instead of brittle
if/thenbranching, give a repeatable framework (e.g. understand → act → verify). This teaches the model how to approach problems, so it copes with situations no one scripted. - Heuristic principles, not exhaustive lists. A compressed rule like "always choose the simplest solution" acts like a greedy heuristic — it steers thousands of edge cases without burning tokens enumerating them.
- Language efficiency. No wasted words, no overlapping or repeating instructions that could confuse the model or push it toward contradictory behavior.
LangChain DeepAgents ships a built-in base system prompt (MIT-licensed, in its repo) that reads exactly like this — short, principled directives: read files before editing; mimic existing conventions; understand → act → verify; prefer specialized tools over shell equivalents; paginate large reads (read_file(path, limit=100)) to avoid context overflow; give brief progress updates on long tasks. You've met Claude Code's version of all this already: it ships its own carefully-engineered system prompt, which output styles can modify (Chapter 8) and the Agent SDK can replace or append to — those are the direct system-prompt surfaces. Your CLAUDE.md (Chapter 2) shapes the same pillar from a different mechanism: it's persistent project memory/context that Claude loads into the conversation (the docs note Claude "treats them as context, not enforced configuration"), not a system-prompt edit. Different levers, same cognitive baseline. The takeaway the chapter lands on: the system prompt is the cognitive baseline — over-specific hardcoding strangles the model's reasoning; vague instructions produce chaos. The art is principled middle ground.
And that's what binds the four pillars: the system prompt tells the agent how to think; the planning tool keeps it oriented; subagents let it delegate depth; the filesystem lets it manage state. Take the model's raw reasoning and wrap it in those four, and a short ReAct loop becomes a system that can work for hours — a deep agent.
Analogy — the constitution, not the to-do list The other three pillars are operations; the system prompt is the constitution. It doesn't list every action — it sets the principles a good actor applies to situations the authors never foresaw ("prefer the simplest remedy," "understand before you change things"). A rulebook that tries to script every case is unusable and still has gaps; no rules at all is chaos. A short, principled constitution is what lets a capable agent act well in genuinely new territory — which long-horizon work is full of.
The whole chapter in one image — the expedition, and the whole book
Analogy — pedagogical summary, drawing on all seven sections, and closing the book
A shallow agent is a day-hike (a ReAct loop): reason, act, observe, repeat — perfect for a quick errand, and most of the world's tasks are quick errands. But send a day-hiker on a month-long expedition (a long-horizon task) and the pack becomes a mountain of everything they ever touched — they slow, contradict themselves, and lose the trail. That's context rot, and it's why "deep" exists.
A deep agent is the expedition, properly outfitted — four pillars a walk never needed. A field manual of principles for the unforeseen (the system prompt). A route plan revised at every camp (the planning tool — cheap to update, and the thing that keeps a long journey coherent). Specialists sent ahead to scout and report back the finding, not the footsteps (subagents in isolated contexts). And base camps that hold the supplies, so you carry only what the next leg needs (the filesystem — write state out, retrieve it selectively). Three of the four exist to keep a finite pack useful over a long distance — that's context engineering, the ground everything stands on.
And that's the whole book in one frame. Context engineering (Ch 1) was the ground. CLAUDE.md and the permission gate (Ch 2–3), MCP and plugins (Ch 4), unattended GitHub runs (Ch 5), planning and parallelism (Ch 6), subagents (Ch 7), output styles (Ch 8), skills (Ch 9), and the desktop/cloud orchestration (Ch 10) were all, it turns out, pillars of the same structure — the deep agent you've been driving all along. Now you can see the architecture, name its parts, and recognize it in any harness — Claude Code, LangChain DeepAgents, or one you build yourself. **That's the point of the chapter, and the book: not just to use a deep agent, but to understand one.**
Activity — Find the four pillars in a tool you use
Ten minutes, individual, no setup required. You'll practice the §3–§7 lens — the durable takeaway of this chapter — on agents from your own world.
- Pick a deep agent you actually use (Claude Code, Cursor, a deep-research mode, Devin, …).
- Locate each of the four pillars in it. For each — system prompt, planning tool, subagents, filesystem — write one line: how does this tool surface it? (e.g. for Claude Code: the system prompt, with
CLAUDE.mdas project memory; the in-session to-do list via theTask*tools; theAgent/subagents; theRead/Write/Glob/Greptools +CLAUDE.md/auto-memory.) Mark any pillar you can't find. - Tie each pillar to a failure it prevents. Match each pillar to one §2 failure mode it guards against (context rot, going off-plan, main-context bloat, under-/misaligned-retrieval). Which pillar, if removed, would hurt your longest task most?
- Spot the context-management move. Three of the four pillars are really about managing a finite window. Which three, and what does each keep out of the main context? (Plan stays small; sub-work stays isolated; state goes to disk.)
- Name the term you'd correct. Where would you push back on loose language — e.g. someone calling "deep agent" an Anthropic feature, or "the filesystem context engine" a Claude Code button? Write the one-sentence correction.
Keep your answers — they're the lens you'll carry to the next agent you meet.
Practical exercise — Watch the four pillars run in Claude Code
~35–45 minutes. Hands-on. No new framework, nonpm, no API keys, no LangChain install — just Claude Code (which you already have),git, and a throwaway sandbox. Rather than build a deep agent, you'll drive Claude Code through a long-ish task and watch each of the four pillars do its job — turning this conceptual chapter into something you can see. (An optional read-only stretch points you at the LangChain DeepAgents base prompt to compare.)
Everything happens in a throwaway sandbox — nothing here touches the training repo.
Setup (4 min). Create a small multi-file sandbox worth exploring:
mkdir -p ~/cct-ch11-lab/src && cd ~/cct-ch11-lab
git init -q
printf 'def login(user, pw):\n return verify(user, pw)\n' > src/auth.py
printf 'def verify(u, p):\n return u == "admin" and p == "secret"\n' > src/crypto.py
printf 'def total(items):\n return sum(i["price"] for i in items)\n' > src/cart.py
printf '# Lab app\nA tiny multi-module sandbox.\n' > README.md
git add . && git commit -q -m "init deep-agent lab"
Part 1 — Pillar 2, the planning to-do list (8 min). Start claude in the sandbox and give it a deliberately multi-step task so it plans explicitly:
Audit this repo for security issues, then write a one-paragraph summary to FINDINGS.md, then suggest one fix. Track your work as a task list.
Watch the to-do list appear and update inline as Claude surfaces it — items moving pending → in progress → completed. (There's no documented viewer command for the internal list; just watch it as Claude works. The /tasks command is unrelated — it's for background processes in the session.)
Expected outcome: you see an explicit, dynamic plan, not just prose — Pillar 2's planning tool. Note the tool names in play: as of writing these are the **Task* tools** (TaskCreate/TaskUpdate/…); the book's TodoWrite/TodoRead is the legacy form. (This is the in-session to-do list — distinct from Chapter 6's read-only plan mode, which you could enter with Shift+Tab before a task to see the "propose-before-editing" behavior instead.)
Part 2 — Pillar 3, a subagent in an isolated context (8 min). Ask the main agent to delegate exploration:
Use a subagent to explore how authentication flows through this repo, and report back just a summary.
Expected outcome: the main agent spawns a subagent (the Agent tool / /agents), which explores in its own context and returns a condensed summary — you don't see its every step in the main thread. That's hierarchical delegation: depth without bloating the orchestrator (Chapter 7, now as Pillar 3). Run /context before and after to see the main window stayed comparatively lean.
Part 3 — Pillar 4, the filesystem as a context engine (12 min). Make Claude use the disk as memory and retrieve selectively:
Write your full audit notes to NOTES.md. Then, WITHOUT re-reading the whole repo, use grep/glob to find only the file that defines password checking, and propose a fix to just that file.
Expected outcome: Claude writes state out to NOTES.md (it leaves the window) and then selects back precisely with Grep/Glob (finding crypto.py's verify) instead of re-loading everything — the write-out / select-back pair from §6. cat NOTES.md to confirm the offloaded state is real. This is "precise context selection": small selected set, still covering what's required.
Part 4 — Pillar 1, the system prompt / cognitive baseline (8 min). Shift the agent's judgment and watch behavior change. Add a heuristic to CLAUDE.md:
printf '# Project rules\n- Always choose the simplest possible fix.\n- Read a file before editing it.\n- Explain your reasoning in one sentence before any change.\n' > CLAUDE.md
/clear (or restart claude), then re-ask for a fix to crypto.py.
Expected outcome: the response now follows your principles (one-sentence reasoning first; simplest fix; reads before editing) — a reasoning framework, not a flowchart. You shaped the agent's cognitive baseline (Pillar 1) via CLAUDE.md — but note the mechanism: CLAUDE.md is persistent project memory/context (Claude loads it into the conversation; it's "context, not enforced configuration"), not a system-prompt edit. The direct system-prompt levers are output styles (Chapter 8) and the Agent SDK's system-prompt API — different mechanism, same pillar.
Optional stretch — compare a real base prompt (read-only, 3 min). Open the LangChain DeepAgents base system prompt in your browser (https://github.com/langchain-ai/deepagents/blob/main/libs/deepagents/deepagents/base_prompt.md) and spot the §7 traits: understand → act → verify, "prefer specialized tools over shell equivalents," paginate large reads, brief progress updates. No install — just see how a production harness writes Pillar 1.
Success checklist
- [ ] You watched Claude maintain an explicit, dynamic to-do list on a multi-step task (Pillar 2 / planning) — and know it's the
Task*tools now, not the legacyTodoWrite. - [ ] You delegated to a subagent and saw it return a summary from an isolated context (Pillar 3), with the main window staying lean (
/context). - [ ] You made Claude write state to a file and retrieve selectively with
grep/glob(Pillar 4 / filesystem as context engine). - [ ] You changed the agent's judgment with a
CLAUDE.mdheuristic and saw behavior shift (Pillar 1 / system prompt). - [ ] You can state, in a sentence, how three of the four pillars are context-management moves.
Common pitfalls - Calling "deep agent" an Anthropic feature. It's a community/LangChain term; Anthropic's word is "long-horizon execution." Use it as a concept, not a documented product feature. - Looking for aTodoWritetool. The book's name is legacy — current Claude Code uses theTask*family (TodoWriteis disabled by default). Verify at the tools-reference docs. - Confusing the to-do list with plan mode. The dynamic to-do list tracks work during a task; plan mode is a read-only permission mode before editing. Different features (§4). - Treating "the filesystem context engine" as a button. It's a principle (write state out, retrieve selectively) implemented with ordinary file tools + memory — not a documented Claude Code feature name. - Thinking subagents are about speed only. Their first job is isolation — keeping sub-work out of the orchestrator's context; parallelism is the bonus (§5).
Knowledge check — try the quiz
Once you've read the lesson and worked the lab, take the chapter quiz from the navigation bar. Six questions: five grounded in the book chapter, one synthesis question that ties the four pillars together as context-management moves and to the orchestrator-workers pattern. Passing score is 5/6 — retake it until you're confident. (This is the final chapter — when you pass, you've completed the course.)
Further reading & enrichment sources
- LangChain — "Deep Agents" (
https://www.langchain.com/blog/deep-agents). The canonical articulation of the four pillars (detailed system prompt, planning tool, sub-agents, file system) and the source of the "deep agent" term. The framework author's own statement — treat it as LangChain's design philosophy, not Claude Code behavior. - LangChain —
deepagentsdocs & repo (https://docs.langchain.com/oss/python/deepagents/overview,https://github.com/langchain-ai/deepagents). The pillars as concrete API:create_deep_agent(), thewrite_todosplanning tool, the filesystem interface, and sub-agents (wired in as middleware). The repo evolves — verify exact feature names there. - LangChain — "How agents can use filesystems for context engineering" (
https://blog.langchain.com/how-agents-can-use-filesystems-for-context-engineering/). The source of §6's three-box model (all-available ⊃ selected vs. required context) and the under-/misaligned-retrieval failure modes. - Anthropic engineering — "Effective context engineering for AI agents" (
https://www.anthropic.com/engineering/effective-context-engineering-for-ai-agents). The strongest Anthropic anchor for this chapter: the attention budget, just-in-time context (load lightweight identifiers, retrieve at runtime), files-as-memory, and sub-agents returning condensed summaries. The "filesystem as a context engine" is a principle from here, not a Claude Code feature. - Anthropic engineering — "Building Effective AI Agents" (
https://www.anthropic.com/research/building-effective-agents) and "How we built our multi-agent research system" (https://www.anthropic.com/engineering/multi-agent-research-system). The orchestrator-workers pattern behind §5 (and the isolated-context subagents). Token/eval figures are "as reported" background, never Claude Code behavior. - Anthropic cookbook — "Orchestrator-workers" (
https://platform.claude.com/cookbook/patterns-agents-orchestrator-workers). Runnable code for a coordinator that decomposes a task, delegates to workers, and synthesizes — the §5 pattern in practice. - Anthropic docs — Subagents / Tools reference / Permission modes / Memory (
https://code.claude.com/docs/en/sub-agents,…/tools-reference,…/permission-modes,…/memory). Ground for the Claude Code mapping: theAgenttool and isolated subagents; theTask*task tools (and legacyTodoWrite); plan mode (distinct from the to-do list); and theCLAUDE.md+ auto-memory model. - "ReAct: Synergizing Reasoning and Acting in Language Models" (
https://arxiv.org/abs/2210.03629). The 2022 paper behind §1–§2's reason→act→observe loop — the foundation the whole agent paradigm traces back to.
Knowledge check
6 questions. Passing score: 5.
Instructor notes & source coverage
Source Ledger — Chapter 11: Understanding Deep Agents
Primary source (the book)
- Source PDF:
source-pdfs/11-chapter-11.pdf(20 pages; page 20 is Packt back-matter promo, not chapter content). This is the final chapter (Part 3). - Extracted source:
extracted-chapters/11-chapter-11.md(visual extraction,<!-- page N -->markers; the markers are PDF-page indices, not printed book pages). There is no usable.txtfor this chapter — see the Extraction caveat at the end. - Extraction tool: the Chapter 11 PDF is image-only (the image-only check
python -c "import pypdf; print(sum(len(p.extract_text() or '') for p in pypdf.PdfReader('source-pdfs/11-chapter-11.pdf').pages))"printed0). Extracted by rendering all 20 pages to PNG at 150 DPI with PyMuPDF (fitz) intowork/11-chapter-11-pages/and transcribing visually. Mixed-fidelity: headings, code, commands, file paths, key names, flags, tool names, and the LangChain base-prompt excerpt are verbatim; explanatory prose is captured as faithful section-by-section summaries (to avoid reproducing a copyrighted chapter at length). Treat code/commands/paths/tool-names as exact; treat prose as a structural summary, and re-open page images for exact sentence wording. - Book's main sections (from the extract, in order): "Agent taxonomy in production systems" (pp. 1–3; the ReAct reason→act→observe loop, hybrid RAG, Figure 11.1 taxonomy, Figures 11.2/11.3 flowcharts); "Shallow agents and their limitations" (pp. 3–5; function calling → context grows → context rot as bloat/contradiction/pollution; Figure 11.4) — within it "Coding agents" (pp. 5–6; Claude Code/Devin/Cursor/Gemini CLI) and "Innovation at the application layer" (pp. 6–7; the Agent Harness Note); "What makes an agent deep?" (pp. 7–8; the four building blocks; Figure 11.5 adapted from the LangChain blog); "Planning tool in Deep Agents" (pp. 8–9; explicit dynamic to-do list;
TodoWrite/TodoReadwith{todos: Todo[]}); "Subagents and hierarchical delegation" (pp. 9–11; isolated context, returns only the final result; Figures 11.6/11.7); "Filesystem access in Deep Agents" (pp. 12–14;Read/Write/Edit/Glob/Grep/NotebookEditand the LangChainls/read_file/write_file/edit_file/glob/grepinterface; the three-box model Figure 11.9); "The filesystem as a context engine" (pp. 14–15; write-out + select-back); "System prompt" (pp. 15–18; a reasoning framework not a flowchart; heuristic principles; language efficiency; the LangChain DeepAgentsbase_prompt.mdexcerpt, MIT-licensed); "Summary" (p. 19).
Enrichment sources
The lesson silently incorporates material from the official Claude Code docs, the LangChain DeepAgents materials, and Anthropic engineering/cookbook content. Per project convention, no inline > Source: / > Enrichment — … labels appear in the learner-facing lesson — the only in-lesson labelled callouts are the > Analogy — … boxes. This ledger is the single source of provenance.
Claude Code behavior (authoritative — official docs):
- [E9] Anthropic docs — Subagents —
https://code.claude.com/docs/en/sub-agents - [E10] Anthropic docs — Tools reference —
https://code.claude.com/docs/en/tools-reference - [E11] Anthropic docs — Permission modes —
https://code.claude.com/docs/en/permission-modes - [E12] Anthropic docs — Memory —
https://code.claude.com/docs/en/memory - [E15] Anthropic docs — Commands (
/tasks= background tasks; verified in the 2026-06-16 re-audit) —https://code.claude.com/docs/en/commands - [E16] Anthropic docs — Output styles (output styles modify the system prompt) —
https://code.claude.com/docs/en/output-styles - [E17] Anthropic docs — Agent SDK: modifying system prompts (the separate system-prompt API surface) —
https://code.claude.com/docs/en/agent-sdk/modifying-system-prompts
LangChain DeepAgents (authoritative for the FRAMEWORK's design + the "deep agent" term — NOT Claude Code behavior):
- [E1] LangChain blog — Deep Agents —
https://www.langchain.com/blog/deep-agents - [E2] LangChain — deepagents docs (overview) —
https://docs.langchain.com/oss/python/deepagents/overview - [E3] LangChain — deepagents repo —
https://github.com/langchain-ai/deepagents - [E4] LangChain blog — How agents can use filesystems for context engineering —
https://blog.langchain.com/how-agents-can-use-filesystems-for-context-engineering/
Concept / background (NOT Claude Code behavior — clearly labelled as background):
- [E5] Anthropic — Building Effective AI Agents —
https://www.anthropic.com/research/building-effective-agents - [E6] Anthropic engineering — Effective context engineering for AI agents —
https://www.anthropic.com/engineering/effective-context-engineering-for-ai-agents - [E7] Anthropic engineering — How we built our multi-agent research system —
https://www.anthropic.com/engineering/multi-agent-research-system - [E8] Anthropic cookbook — Orchestrator-workers —
https://platform.claude.com/cookbook/patterns-agents-orchestrator-workers - [E13] ReAct: Synergizing Reasoning and Acting in Language Models (arXiv) —
https://arxiv.org/abs/2210.03629 - [E14] GPT Researcher (open-source deep-research agent) —
https://github.com/assafelovic/gpt-researcher
This chapter is conceptual — it teaches an architecture (the "deep agent" four-pillar pattern) rather than a Claude Code surface to operate, so most of the load-bearing claims are about the framework idea and only a handful are Claude Code behavior. The book is broadly current on the concept: the taxonomy, context rot, the four building blocks, and the filesystem-as-context-engine principle all hold. The specifics that drifted are (1) the terminology — "deep agent" is a community/LangChain articulation, not an Anthropic/Claude Code label (the book itself acknowledges LangChain articulated it); and (2) the planning tool names — the book's TodoWrite/TodoRead are the legacy surface, replaced by the Task* family ([E10]). All Claude Code behavior was verified against [E9]–[E12]. Source-boundary discipline: Claude Code behavior claims rest on [E9]–[E12]; the LangChain materials [E1]–[E4] are authoritative for the framework's design and the "deep agent" term but not for Claude Code behavior; Anthropic engineering/research/cookbook [E5]–[E8] are concept/background, and the orchestrator-worker token/eval figures (≈4×/≈15×/≈90.2% from [E7]) are treated as "as reported," NOT as Claude Code behavior; ReAct [E13] is the academic foundation.
Pedagogical enrichment by the training author
Not from the book and not from the docs — written for this training, inventoried here for separate audit.
- Newcomer preface (
## Before we start — agents, ReAct, "long-horizon", harnesses, and the four pillars). Recaps what an agent is, the ReAct loop, shallow vs. deep, "long-horizon" + context rot, the agent harness, and the four pillars (one line each). States up front that "deep agent" is a community/LangChain term, not an Anthropic/Claude Code label (Anthropic more commonly discusses "long-running / long-horizon" agentic work, context engineering, and agents/workflows rather than defining "deep agent" as an official term). Grounded in [E1], [E6], [E13] and book continuity (Chapters 1, 7, 9). - Per-section analogies. Seven
> Analogy — …callouts, one per numbered section: §1 vehicles on the road (bicycle vs. long-haul truck vs. fitted-out workshop truck); §2 a desk that's never cleared; §3 what makes an expedition, not a walk; §4 the whiteboard the surgeon keeps glancing at; §5 the general contractor and the trades; §6 the detective's case room, not their pockets; §7 the constitution, not the to-do list. - Whole-chapter / whole-book analogy (
## The whole chapter in one image — the expedition, and the whole book). A sustained expedition analogy threading all seven sections, then a book capstone mapping all 11 chapters back to the four pillars / context engineering. No new claims. - Three SVG diagrams (the book's figures are taxonomy/flowchart/architecture diagrams + terminal screenshots and are not reproduced):
- Figure 11.A — the agent taxonomy as nested regions (Agents in production ⊃ shallow [ReAct loop] and deep [long-horizon]; deep ⊃ deep-research agents and coding agents; the harness as the wrapping application layer).
- Figure 11.B — the four pillars as four columns holding a roof labeled "long-horizon execution," each mapped to its Claude Code surface (system prompt +
CLAUDE.md;Task*/legacyTodoWrite; theAgenttool;Read/Write/Edit/Glob/Grep), all resting on a "context engineering" foundation; three of the four flagged as context-management moves. - Figure 11.C — the filesystem context-engine three-box model (all-available ⊃ selected vs. required), contrasting "without a filesystem" (everything dumped → overflow → rot) with "with a filesystem" (write state out to disk;
glob/grepselect a small set that covers required). - Each
figcaptionexplicitly notes it is "Pedagogical diagram by this training, not from the book." - Conceptual activity — "Find the four pillars in a tool you use." Ten-minute, individual, no-setup exercise practising the §3–§7 lens (locate each pillar in a deep agent you use; tie each to a failure it prevents; spot the three context-management moves; name the loose language you'd correct). Grounded in §2–§7.
- Practical exercise — "Watch the four pillars run in Claude Code." A ~35–45 min framework-free lab in
~/cct-ch11-lab/using only Claude Code +git— nonpm, no LangChain install, no API keys. Part 1: a deliberately multi-step task → watch theTask*to-do list update (legacyTodoWriteflagged). Part 2: delegate exploration to a subagent → it returns a summary from an isolated context (/contextbefore/after). Part 3: write state toNOTES.md, then retrieve selectively withgrep/glob. Part 4: add aCLAUDE.mdheuristic and watch behavior shift (Pillar 1). Optional read-only stretch: open the LangChain DeepAgentsbase_prompt.mdto compare. Reproduces the chapter's concepts as something the learner can see, portably.
Quiz items and learning objectives remain grounded in the book chapter and the labelled enrichment; none of the analogies, diagrams, the activity, or the exercise steps are themselves assessed.
Objective → Source Mapping
| Learning Objective | Source Section (page) | Enrichment | Confidence | Notes |
|---|---|---|---|---|
| Place coding agents within the production agent taxonomy — the broad domain of agents (hybrid RAG, agentic apps) divides into shallow (the ReAct loop) and deep agents, deep agents split into deep-research and coding agents (Claude Code, Cursor, Devin, Gemini CLI) — and explain why the application layer (the "agent harness") is where most current innovation happens. | Book "Agent taxonomy in production systems" + "Coding agents" + "Innovation at the application layer" (pp. 1–7) | [E1], [E5], [E13], [E14] | High | The taxonomy, the harness Note, and the "incremental model / fast application layer" framing are all the book's; ReAct grounded in [E13]; GPT Researcher in [E14]; the harness idea echoes [E1]. |
| Explain the shallow-agent limitation — each ReAct iteration injects the tool result back into the prompt, so context grows until it suffers context rot (bloat, contradiction, pollution), degrading quality and raising cost/latency — and define "deep": complex, long-running (long-horizon) tasks done with quality/reliability, which reduces to smart context management. | Book "Shallow agents and their limitations" + "What makes an agent deep?" intro (pp. 3–8) | [E6], [E13] | High | The function-calling → context-rot mechanism and the "context management is the whole game" thesis are the book's; the attention-budget framing echoes [E6]. |
| Name the four building blocks (detailed system prompt, planning tool, subagents, filesystem) and recognize that "deep agent" is a community/LangChain-articulated term, not an official Anthropic/Claude Code label (Anthropic more commonly discusses "long-running / long-horizon" agentic work, context engineering, and agents/workflows rather than defining "deep agent" as an official term); map each block onto Claude Code and the LangChain DeepAgents harness. | Book "What makes an agent deep?" (pp. 7–8; Figure 11.5) | [E1], [E2], [E3] | High | The four-block list is the book's (and Figure 11.5 is adapted from the LangChain blog). Terminology clarified: "deep agent" labeled a community/LangChain term throughout — see Drift #1. The framework mapping draws on [E1]–[E3]. |
Explain the planning block — an explicit, dynamic to-do list (pending / in-progress / completed) the agent rewrites as it works, whose real job is context management (re-orienting the agent), not computation — and know the current Claude Code surface (Task* — TaskCreate/TaskList/TaskGet/TaskUpdate), with the book's TodoWrite/TodoRead now legacy (disabled by default), distinct from read-only plan mode (Chapter 6). | Book "Planning tool in Deep Agents" (pp. 8–9) | [E1], [E10], [E11] | High | The explicit-dynamic-to-do-list concept ("almost a no-op" per [E1]) is the book's and current. Corrected: TodoWrite/TodoRead → the Task* family per [E10] — see Drift #2; plan-mode distinction added from [E11]. |
Explain subagents / hierarchical delegation — an orchestrator delegates a scoped task to a specialized subagent with its own system prompt, tools, and isolated context window; the subagent works independently and returns only its final result, keeping the main context lean and enabling parallelism — and connect it to the Agent tool (formerly Task), Chapter 7, and orchestrator-workers. | Book "Subagents and hierarchical delegation" (pp. 9–11; Figures 11.6/11.7) | [E7], [E8], [E9], [E10] | High | The isolated-context / returns-only-final-result delegation and the Claude Code exploration-subagent example are the book's. Completed: the Agent tool (formerly Task) from [E9]/[E10] — see Drift #4; orchestrator-workers from [E7]/[E8] (figures "as reported," Drift #5). |
Explain the filesystem block — writing intermediate state to disk plus selective retrieval (glob/grep) — as the mechanism behind "precise context selection"; ground it in the attention-budget / three-box model (all-available ⊃ selected vs. required), Claude Code's file tools (Read/Write/Edit/Glob/Grep/NotebookEdit) and memory (CLAUDE.md + auto-memory) — and recognize "the filesystem as a context engine" is an engineering principle, not a documented Claude Code feature name. | Book "Filesystem access in Deep Agents" + "The filesystem as a context engine" (pp. 12–15; Figures 11.8/11.9) | [E4], [E6], [E10], [E12] | High | The file-tools list, the LangChain ls/read_file/… interface, and the three-box model are the book's (Figure 11.9 is sourced from [E4]). Framed: "context engine" labeled a principle ([E6]/[E4]) not a feature — see Drift #3; file tools per [E10], memory per [E12]. |
Lesson Section → Source Mapping
| Lesson section | Source location | Enrichment | Confidence | Notes |
|---|---|---|---|---|
| Preface — agent recap; ReAct; shallow vs. deep; "long-horizon" + context rot; agent harness; the four pillars; "deep agent" is a community term | Concepts across the chapter (pp. 1–8) | [E1], [E6], [E13] | High | Pedagogical framing; the "deep agent is a community/LangChain term" note states Drift #1 up front. |
| "Why this chapter matters" — capstone framing (the architecture under every earlier chapter); the four-pillar pattern; the sources-and-currency note | Book intro + summary (pp. 1, 19) | [E1], [E6], [E10] | High | The capstone thesis is the lesson's synthesis; the currency note flags Drift #1, #2, #3. |
| §1 — the agent taxonomy; domain of agents / hybrid RAG; the ReAct loop; shallow vs. deep; deep-research vs. coding agents; innovation at the application layer / agent harness | Book pp. 1–7 + Figures 11.1–11.3 (diagrams) | [E1], [E5], [E13], [E14] | High | Book's taxonomy preserved; ReAct [E13]; GPT Researcher [E14]; harness Note [E1]. |
| §1 — Figure 11.A (taxonomy as nested regions) | n/a — pedagogical diagram | [E1], [E13] | n/a | Original SVG; the book's Figure 11.1 is a nested-boxes diagram, not reproduced. |
| §1 — analogy: vehicles on the road | n/a — pedagogical | n/a | n/a | Original. |
| §2 — shallow agents hit a wall; function calling → result injected back → context grows → context rot (bloat/contradiction/pollution); cost+latency; long-running vs. one-shot tasks | Book pp. 3–5 + Figure 11.4 (diagram) | [E6], [E13] | High | Entirely the book's mechanism; attention-budget framing echoes [E6]. |
| §2 — analogy: a desk that's never cleared | n/a — pedagogical | n/a | n/a | Original. |
| §3 — what makes an agent "deep"; no strict definition; complex/long-running with quality+reliability = smart context management; the four building blocks; three-of-four are context-management moves | Book pp. 7–8 + Figure 11.5 (adapted from [E1]) | [E1] | High | The four-block list is the book's (Figure 11.5 adapted from the LangChain blog); "deep agent is LangChain's term" stated (Drift #1). |
| §3 — Figure 11.B (four pillars as columns over "long-horizon execution") | n/a — pedagogical diagram | [E1] | n/a | Original SVG; each pillar mapped to its Claude Code surface. |
| §3 — analogy: what makes an expedition, not a walk | n/a — pedagogical | n/a | n/a | Original; seeds the closing whole-chapter analogy. |
§4 — explicit planning via a dynamic to-do list; pending/in-progress/completed; "almost a no-op" / context management; TodoWrite/TodoRead {todos: Todo[]} → corrected to Task*; distinct from plan mode | Book pp. 8–9 | [E1], [E10], [E11] | High | Concept + "almost a no-op" from the book/[E1]. Corrected to the Task* family (Drift #2); LangChain write_todos noted; plan-mode distinction from [E11]. |
| §4 — analogy: the whiteboard the surgeon keeps glancing at | n/a — pedagogical | n/a | n/a | Original; encodes "almost a no-op, but re-orients." |
§5 — subagents / hierarchical delegation; own system prompt/description/tools; isolated context; returns only the final result; keeps orchestrator lean + enables parallelism; the Agent tool; orchestrator-workers | Book pp. 9–11 + Figures 11.6/11.7 (diagram + screenshot) | [E7], [E8], [E9], [E10] | High | The delegation mechanics + the Claude Code exploration example are the book's. Completed: Agent tool (formerly Task) (Drift #4); orchestrator-workers + "as reported" figures (Drift #5). |
| §5 — analogy: the general contractor and the trades | n/a — pedagogical | n/a | n/a | Original; mirrors the book's craftsman/house analogy. |
§6 — filesystem access; Read/Write/Edit/Glob/Grep/NotebookEdit; LangChain ls/read_file/…; the three-box model + failure modes; write-out / select-back; attention budget; memory (CLAUDE.md + auto-memory) | Book pp. 12–15 + Figures 11.8/11.9 (screenshot + diagram from [E4]) | [E4], [E6], [E10], [E12] | High | File tools + interface + three-box model are the book's; "context engine" framed as a principle ([E6]/[E4], Drift #3); memory from [E12]. |
| §6 — Figure 11.C (three-box model, with/without a filesystem) | n/a — pedagogical diagram | [E4], [E6] | n/a | Original SVG; the book's Figure 11.9 is sourced from [E4] and is not reproduced. |
| §6 — analogy: the detective's case room, not their pockets | n/a — pedagogical | n/a | n/a | Original. |
§7 — the detailed system prompt as cognitive baseline; hundreds of lines; reasoning framework not flowchart; heuristic principles; language efficiency; the LangChain DeepAgents base_prompt.md excerpt (MIT); Claude Code's system prompt + CLAUDE.md + output styles | Book pp. 15–18 | [E1], [E2], [E3], [E12] | High | Entirely the book's section; the base_prompt.md excerpt is verbatim from [E3] (MIT); the Claude Code mapping (CLAUDE.md, Ch 8 output styles) is the lesson's continuity. |
| §7 — analogy: the constitution, not the to-do list | n/a — pedagogical | n/a | n/a | Original. |
| Whole-chapter / whole-book analogy: the expedition, and the whole book | n/a — pedagogical synthesis | n/a | n/a | Original; capstone mapping all 11 chapters to the four pillars / context engineering. |
| Activity: Find the four pillars in a tool you use | n/a — pedagogical | n/a | n/a | Original; grounded in §3–§7. |
Practical exercise: Watch the four pillars run in Claude Code (~/cct-ch11-lab/, Claude Code + git only) | Book pp. 8–18 recombined into a framework-free lab | [E3], [E9], [E10], [E12] | High — original sequencing | Each part demonstrates one pillar with real Claude Code surfaces (Task* to-do list, the Agent subagent, Grep/Glob, CLAUDE.md); the optional stretch reads the [E3] base_prompt.md. |
Unsupported / Pedagogical-Only Claims
| Item | Justification |
|---|---|
| Vehicles-on-the-road analogy (§1) | Pedagogical analogy. Restates shallow (bicycle) vs. deep (long-haul truck) vs. coding agent (fitted-out workshop truck), and "the leap is the harness around the engine, not the engine." |
| Desk-that's-never-cleared analogy (§2) | Pedagogical analogy. Restates context rot — piling every document onto the desk and never filing — and "the fix is a system for clearing the desk." |
| Expedition-not-a-walk analogy (§3) | Pedagogical analogy. Restates the four pillars as what a long expedition needs that a walk doesn't. |
| Surgeon's-whiteboard analogy (§4) | Pedagogical analogy. Restates the planning tool as "almost a no-op" that re-orients on a long procedure. |
| General-contractor-and-the-trades analogy (§5) | Pedagogical analogy. Restates hierarchical delegation — specialists in isolated workspaces returning outcomes, not transcripts. |
| Detective's-case-room analogy (§6) | Pedagogical analogy. Restates the filesystem as the context engine (file everything on the walls; pull only the few folders each interview needs). |
| Constitution-not-the-to-do-list analogy (§7) | Pedagogical analogy. Restates the system prompt as principles for the unforeseen, not a flowchart. |
| Expedition / whole-book whole-chapter analogy | Pedagogical synthesis and book capstone. No new claims; maps all 11 chapters to the four pillars. |
| Figures 11.A–11.C (SVGs) | Original SVGs. Visually restate the taxonomy, the four-pillar architecture, and the three-box filesystem context engine. The book's figures are diagrams/screenshots and are not reproduced. |
The ~/cct-ch11-lab lab (practical exercise) | Authored for this training as a framework-free, Claude-Code-+-git-only way to watch each of the four pillars act, so a conceptual chapter becomes hands-on without LangChain, npm, or an API key. |
Quiz Item → Source Mapping
| Quiz ID | Answer | Item | Source location | Enrichment | Confidence |
|---|---|---|---|---|---|
| q1 | b | The taxonomy places coding agents (Claude Code, Cursor, Devin, Gemini CLI) as a specialized subset of deep agents (domain of agents → shallow/deep → deep-research/coding), and identifies the application layer / agent harness — not only incremental model gains — as the main driver of progress. | Book pp. 1–7 (§1) | [E1], [E5], [E13] | High |
| q2 | a | ReAct "shallow" agents are limited for long-running tasks because each iteration injects the tool result back into the prompt, so context grows → context rot (bloat, contradiction, pollution) degrading quality and raising latency/cost — while remaining the right tool for few-iteration tasks. | Book pp. 3–5 (§2) | [E6], [E13] | High |
| q3 | c | "Makes an agent deep": no strict definition — reliable complex, long-running (long-horizon) work, which reduces to smart context management; four building blocks (detailed system prompt, planning tool, subagents, filesystem); and "deep agent" is a community/LangChain-articulated term, not an Anthropic/Claude Code label (Anthropic more commonly discusses "long-running / long-horizon" agentic work rather than defining "deep agent" as an official term). | Book pp. 7–8 (§3) | [E1] | High — terminology clarified (Drift #1, softened in the re-audit). |
| q4 | b | The planning tool keeps an explicit, dynamic to-do list (pending/in-progress/completed) the agent rewrites — its real job is context management ("almost a no-op"); the current Claude Code surface is the **Task* tools (TodoWrite/TodoRead legacy, disabled by default); distinct from read-only plan mode**. (The lab no longer tells learners to view the list via /tasks — see Drift #6.) | Book pp. 8–9 (§4) | [E1], [E10], [E11] | High — tool names corrected (Drift #2); plan-mode distinction added. |
| q5 | c | The filesystem acts as a "context engine" by (1) writing intermediate state to disk and (2) selecting it back precisely with glob/grep; the three-box model (all-available ⊇ selected vs. required) — make selected small while fully covering required, avoiding under-retrieval, misaligned retrieval, window overflow. Notes "context engine" is a principle, not a feature name. | Book pp. 12–15 (§6) | [E4], [E6], [E10] | High — "context engine" framed as a principle (Drift #3). |
| q6 | b | Synthesis: subagents / hierarchical delegation — an orchestrator delegates to a specialized subagent with its own system prompt, tools, and isolated context window, which returns only the final result (the Agent tool, formerly Task) — the orchestrator-workers pattern; and the unifying idea that three of the four pillars are context-management moves (plan small + in view; sub-work isolated; state to disk) under a guiding system prompt, which is what lets a finite window sustain long-horizon execution. | Book pp. 9–11 (§5) + the four-pillar synthesis | [E7], [E8], [E9], [E10] | High — the one enrichment-grounded synthesis question. Orchestrator-worker figures "as reported," not Claude Code behavior (Drift #5). |
Drift / Corrections Applied
The book is broadly current on the load-bearing concepts (the taxonomy, context rot, the four building blocks, the filesystem-as-context-engine principle), so most adjustments below are clarifications/completions/framing rather than factual errors — with one genuine correction (the planning tool names) and one terminology clarification that the book itself half-acknowledges. The book's original wording is preserved verbatim in extracted-chapters/ and is not edited.
2026-06-16 accuracy pass. Claude Code behavior verified against [E9] subagents, [E10] tools-reference, [E11] permission-modes, [E12] memory. Framework claims attributed to LangChain [E1]–[E4]; orchestrator-worker figures attributed to Anthropic [E7]/[E8] as "as reported." The adjustments below were propagated across the lesson, quiz, this ledger, and the training-output mirror. The rows record each. The book's original wording remains untouched inextracted-chapters/. 2026-06-16 re-audit (second pass —/tasks,CLAUDE.md, pillar numbering, soften "long-horizon"). Re-fetched [E10] tools-reference, [E11]/commands, [E12] memory, [E16] output-styles, and [E17] Agent SDK system-prompt docs. Four corrections propagated across lesson + quiz + this ledger + the training-output mirror: (#6)/tasksmisuse — the lesson previously told learners to "run/tasksto see the to-do list," but/tasksis documented as listing background tasks running in the session, not a viewer for the internal planning to-do list; there is no documented viewer command (the checklist surfaces inline). (#7)CLAUDE.mdvs system-prompt customization — softened the claim that editingCLAUDE.mdis "the same lever" as system prompts/output styles: per [E12]/[E16]/[E17],CLAUDE.mdis persistent project memory/context ("context, not enforced configuration," injected into the conversation), while output styles modify the system prompt and the Agent SDKsystemPromptis a separate API surface. (#8) Pillar numbering — made the numbering consistent everywhere on the canonical order 1 system prompt · 2 planning · 3 subagents · 4 filesystem (the §4–§7 lesson headings had used a sequential 1–4; now §4 = Pillar 2, §5 = Pillar 3, §6 = Pillar 4, §7 = Pillar 1, matching Figure 11.B, the §3 list, the objectives, the lab parts, and the success checklist; a one-line teaching-order note was added in §3). (soften #1) "Anthropic's own phrase is 'long-horizon execution'" relaxed to "Anthropic more commonly discusses long-running / long-horizon agentic work, context engineering, and agents/workflows rather than defining 'deep agent' as an official term" (no claim that "long-horizon execution" is a canonical official phrase). The book's original wording remains untouched inextracted-chapters/.
| Item | Book / draft position | Current / correct position | Lesson treatment |
|---|---|---|---|
| 1. "Deep agent" terminology (CLARIFICATION) | The book's title and framing treat "Deep Agents" as the operative concept, though it does note the LangChain team articulated it clearly after analyzing many implementations. | "Deep agent" / "deep agents" is a community/LangChain-articulated term, NOT an official Anthropic or Claude Code label — Anthropic's docs and engineering writing more commonly discuss "long-running / long-horizon" agentic work, context engineering, and agents/workflows rather than defining "deep agent" as an official term (the strings "deep agent"/"deep agents" return zero results in code.claude.com docs). [E1] is the term's articulation; the docs absence was verified directly. (Re-audit: softened from "Anthropic's own phrase is 'long-horizon execution'" — see the 2026-06-16 second-pass note.) | The preface states it up front; §3 + the currency note repeat it; q3's correct option says "community/LangChain-articulated term … Anthropic more commonly discusses 'long-running / long-horizon' work rather than defining 'deep agent' as an official term"; a common-pitfalls bullet keeps "don't call 'deep agent' an Anthropic feature." Figures 11.A/11.B label the roof "long-horizon execution" (describing the concept, not asserting an official term). |
**2. Planning tool — TodoWrite/TodoRead → the Task* family** (CORRECTION) | Book describes Claude Code's planning tool as TodoWrite (creates/updates the list, {todos: Todo[]}) and TodoRead (reads it). | Per [E10], TodoWrite is disabled by default (as of v2.1.142) in favor of the **Task* family — TaskCreate/TaskList/TaskGet/TaskUpdate/TaskStop**. The concept (an explicit, dynamic to-do list for context management, "almost a no-op" per [E1]) is current and correct; only the tool names moved. (There is no documented user-facing command to view the internal list — see Drift #6; an earlier draft's "viewable via /tasks" was removed.) | §4 teaches the concept, names the Task* family as current, and flags TodoWrite/TodoRead as legacy/disabled-by-default; q4's correct option + explanation carry it; Figure 11.B's pillar-2 label reads "Task* (legacy TodoWrite)"; a common-pitfalls bullet says "don't look for a TodoWrite tool — verify at tools-reference." Also distinguishes the in-session to-do list from read-only plan mode ([E11], Chapter 6). |
| 3. "Filesystem as a context engine" — principle, not a feature name (FRAMING / CLARIFICATION) | Book section "The filesystem as a context engine" can read as naming a Claude Code capability. | Claude Code genuinely ships the file tools (Read/Write/Edit/Glob/Grep/NotebookEdit, [E10]) and memory (CLAUDE.md + auto-memory, [E12]) — those are real, documented surfaces. But the **"filesystem as a context engine" / three-box / write-out-select-back framing is an engineering principle** from Anthropic's Effective context engineering post [E6] and LangChain's filesystem post [E4] — not a documented Claude Code feature name. | §6 teaches the file tools + memory as real, then explicitly states the "context engine" framing is a principle (the why), not a button; q5's explanation carries the note; a common-pitfalls bullet says "don't treat 'the filesystem context engine' as a button." Figure 11.C grounds the three-box model in [E4]/[E6]. |
4. Subagent delegation = the Agent tool (formerly Task) (COMPLETION — carried from Chapter 7) | Book describes subagents/hierarchical delegation conceptually (own system prompt, tools, isolated context, returns only the final result) without naming the current tool. | Per [E9]/[E10], delegation happens through the Agent tool (renamed from Task; Task remains an alias); the subagent runs in its own context window and returns only its final result — both confirmed by the docs. | §5 names the Agent tool (formerly Task) and confirms isolated context + returns-only-the-summary; q6's correct option says "via the Agent tool (formerly Task)"; the practical exercise Part 2 drives the Agent//agents surface. |
| 5. Orchestrator-worker token/eval figures (SOFTENING — background, not behavior) | n/a (the book does not cite these; the lesson adds them as enrichment context). | The multi-agent research write-up reports an orchestrator-worker system beating a single agent on a research eval **while using substantially more tokens (roughly an order of magnitude, as reported)** — an enrichment/background fact ([E7]/[E8]), not Claude Code behavior or a documented mechanic. The ≈4×/≈15×/≈90.2% figures are "as reported." | §5's orchestrator-workers paragraph + q6's explanation present the tradeoff with explicit "as reported / reported background, not Claude Code mechanics" wording; no hardcoded multipliers presented as fact. |
6. /tasks is not the to-do-list viewer (CORRECTION — re-audit) | An earlier draft told learners to "run /tasks to see the to-do list" (lesson §4, the activity, and lab Part 1). | Per [E15], /tasks lists what's running in the background of the current session (background processes), not the in-session planning to-do list. There is no documented user-facing command to view the internal task list ([E15] — "NOT explicitly covered"); the checklist surfaces inline when Claude shows it. The Task* tools ([E10]) maintain the list internally. | §4 now says the checklist surfaces inline and explicitly notes /tasks is a different feature (background tasks); the activity's "/tasks to-do list" → "the in-session to-do list (Task* tools)"; lab Part 1 drops "run /tasks" and says watch it inline. |
7. CLAUDE.md vs system-prompt customization (CORRECTION — re-audit) | An earlier draft said editing CLAUDE.md is "the same lever the system prompt and output styles pull" (lesson §7 + lab Part 4). | Per [E12]/[E17], CLAUDE.md is persistent project memory/context — Claude "treats them as context, not enforced configuration," injected into the conversation, not the system prompt. Per [E16], output styles modify the system prompt; per [E17], the Agent SDK systemPrompt is a separate API surface. So CLAUDE.md is not the same mechanism as system-prompt customization. | §7 reworded: output styles modify the system prompt and the Agent SDK can replace/append it (the direct surfaces), while CLAUDE.md shapes the same cognitive-baseline pillar from a different mechanism (project memory/context). Lab Part 4 reworded to "different mechanism, same pillar," dropping "same lever." |
| 8. Pillar numbering made consistent (CONSISTENCY — re-audit) | The §4–§7 lesson headings numbered the pillars sequentially (planning = Pillar 1, subagents = 2, filesystem = 3, system prompt = 4), conflicting with Figure 11.B, the §3 list, the objectives, the lab parts, and the success checklist, which all use the canonical 1 system prompt · 2 planning · 3 subagents · 4 filesystem. | One canonical order applied everywhere: Pillar 1 = detailed system prompt, 2 = planning tool, 3 = subagents, 4 = filesystem. | The §4–§7 headings renumbered to canonical (§4 = Pillar 2, §5 = Pillar 3, §6 = Pillar 4, §7 = Pillar 1 — matching the lab parts/checklist/figure); a one-line teaching-order note added in §3 ("we take them in the book's order — planning first — but each keeps its number"); the lab Part 1 "Pillar 1's planning tool" → "Pillar 2's"; lab Part 4 "(Pillar 4)" → "(Pillar 1)". |
| Source boundary (FRAMING) | n/a | Claude Code behavior rests on [E9]–[E12]; the LangChain materials [E1]–[E4] are authoritative for the framework's design and the "deep agent" term but NOT for Claude Code behavior; Anthropic engineering/research/cookbook [E5]–[E8] are concept/background (orchestrator-worker figures "as reported," never Claude Code behavior); ReAct [E13] is the academic foundation. | The lesson cites [E1]–[E8], [E13], [E14] in Further reading with explicit labels ("treat as LangChain's design philosophy, not Claude Code behavior"; "Token/eval figures are 'as reported' background, never Claude Code behavior"); behavior claims rest on the docs. |
| Canonical docs host (NOTE) | n/a | The canonical host is code.claude.com; docs.claude.com mirrors. | The lesson and Further reading cite code.claude.com / langchain.com / blog.langchain.com / anthropic.com / platform.claude.com throughout. |
Extraction caveat (image-only PDF, summarized prose)
source-pdfs/11-chapter-11.pdf is an image-only PDF — no text layer (the image-only check printed 0). The source-of-truth extracted-chapters/11-chapter-11.md was produced by rendering each of the 20 pages to PNG at 150 DPI (PyMuPDF / fitz) into work/11-chapter-11-pages/ and transcribing the images visually. Consequences a reviewer should know:
- Mixed-fidelity extract. Explanatory prose is captured as faithful summaries; headings, code, commands, file paths, key names, flags, tool names, and the LangChain
base_prompt.mdexcerpt are verbatim. Treat code/commands/paths/tool-names/the prompt excerpt as exact; treat prose as a structural summary. Re-open the page images inwork/11-chapter-11-pages/for exact sentence wording. - Page markers are reliable, but printed book page numbers are unknown —
<!-- page N -->is the PDF page index. There is no.txtmirror. needs review— page-1 "topics covered" list is truncated by the page break. Only two bullets render before the page cuts off — "Agent taxonomy in production systems" and "What makes an agent deep" — and the "Understanding Deep Agents" section heading itself is split across pages 1/2 (the word "systems" continues at the top of page 2). The section headings later in the chapter confirm the rest of the covered topics (planning tool, subagents, filesystem, system prompt), so the full bullet list clearly continued onto an uncaptured portion of the page. Cross-check the printed book if the exact "topics covered" list matters.- The book's figures are diagrams and screenshots (Figure 11.1 taxonomy nested-boxes; Figures 11.2/11.3 hybrid-RAG / ReAct flowcharts; Figure 11.4 context-accumulation panels; Figure 11.5 deep-agent architecture, adapted from the LangChain blog; Figures 11.6/11.7 subagent tree + Claude Code terminal screenshot; Figure 11.8 file-tools terminal screenshot; Figure 11.9 three-box Venn, sourced from the LangChain filesystem post) and are not reproduced (the three lesson diagrams are original SVGs).
- Page 20 is Packt back-matter promo (a "Scan the QR code /
packtpub.com/unlock" unlock offer with a QR image and Previous/Next-Section nav; the partial heading reads "…bundle, and more"), not chapter content — ignore it for sourcing. - Re-transcription, not OCR. PyMuPDF was used to render pages; no OCR engine was involved. Cross-check the printed book if exact wording/pagination matters.
Source PDF: source-pdfs/11-chapter-11.pdf
Extracted source: extracted-chapters/11-chapter-11.md