Source: raw/claude-cookbooks-main/patterns/agents/README.md, raw/claude-cookbooks-main/patterns/agents/prompts/research_lead_agent.md, raw/claude-cookbooks-main/patterns/agents/prompts/research_subagent.md, raw/claude-cookbooks-main/patterns/agents/prompts/citations_agent.md

The patterns/agents/ directory of the Anthropic Cookbook ships the reference implementation for “Building Effective Agents” (Erik Schluntz, Barry Zhang). Beyond the basic-workflow notebooks, three production-shaped prompt artifacts live in patterns/agents/prompts/: a research lead agent, a research subagent, and a citations agent. Together they form the canonical orchestrator-subagent research pattern Anthropic ships — a lead that plans and delegates, parallel subagents that execute focused research, and a separate citations pass that adds attributions without rewriting the report.

Key Takeaways

  • Three-role architecture: research lead (planner + synthesizer), parallel research subagents (one task each), citations agent (read-only annotator). Each role is a separate prompt artifact.
  • The lead explicitly classifies every query as depth-first (multiple perspectives on one issue), breadth-first (distinct sub-questions), or straightforward (single focused investigation) — and uses that classification to size the subagent fan-out.
  • Subagent fan-out is bounded: 1 subagent for simple queries, 2-3 standard, 3-5 medium, 5-10 high-complexity (max 20). “Never create more than 20 subagents unless strictly necessary” is a hard rule in the prompt.
  • Subagent ground-truth-only contract: each subagent gets a single, extremely detailed <task> description, executes a 5-10 (max 15) tool-call OODA loop, and reports back facts only. Lead never delegates the final report to a subagent.
  • Subagent budget discipline encoded in the prompt: under-5 calls for simple, ~5 medium, ~10 hard, up to 15 for multi-part — with a hard 20-call / 100-source upper limit before termination.
  • The lead writes the final report itself, then passes it (citation-free) to the citations agent. Citations agent contract: never modify the text, only add citations — whitespace must be preserved exactly or the result is rejected.
  • Parallel tool calls are mandated for subagent dispatch: “You MUST use parallel tool calls for creating multiple subagents (typically running 3 subagents at the same time).”
  • Source-quality reasoning is baked into the subagent prompt: flag aggregators vs originals, speculation language (“could”, “may”), passive voice with nameless sources, marketing spin, and cherry-picked data — return concerns alongside facts to the lead.
  • Internal-tool priority: when Slack/Asana/GDrive/Gmail/Calendar tools are available, the prompt treats them as user-intended and forces the lead and subagents to use them before public web search.
  • Termination discipline: lead stops research the moment further work has “diminishing returns” and writes the report immediately. Subagents stop at task completion, not budget exhaustion.
  • The README itself is thin — patterns/agents/README.md only lists the basic-workflow notebooks (Prompt Chaining, Routing, Parallelization, Orchestrator-Subagents, Evaluator-Optimizer). The substantive design content is in the three .md prompt files, not the README.

Details

Lead Agent — Planner, Delegator, Synthesizer

The lead agent prompt (research_lead_agent.md) opens with a <research_process> block that forces a four-step discipline before any delegation:

  1. Assessment and breakdown — identify main concepts, list specific facts needed, note temporal/contextual constraints, infer what form the final answer should take (detailed report? entity list? perspective analysis? visual?).
  2. Query type determination — explicitly classify as depth-first, breadth-first, or straightforward. The prompt gives 2-3 worked examples per type so the classifier has anchors. This classification drives subagent count.
  3. Detailed research plan — for depth-first, define 3-5 methodological approaches and how findings will be synthesized; for breadth-first, enumerate distinct sub-questions with crisp boundaries to prevent overlap; for straightforward, plan the most direct path plus verification.
  4. Methodical plan execution — deploy subagents in parallel where possible, default to 3 subagents for most queries.

The <subagent_count_guidelines> block is load-bearing — it’s an explicit anti-overhead rule: “Prefer fewer, more capable subagents over many overly narrow ones. More subagents = more overhead. Only add subagents when they provide distinct value.”

The <delegation_instructions> block enforces several rules:

  • Every subagent task description must include: a single core objective, expected output format, relevant background, key questions, suggested starting points, source-quality guidelines, specific tools to use, and scope boundaries.
  • The lead does NOT conduct primary research itself except for trivial calculations or critical-question gap-fills. “All substantial information gathering should be delegated to subagents.”
  • The lead writes the final report itself. “NEVER create a subagent to generate the final report.”

The <answer_formatting> block adds a clean handoff to the citations stage: “Do not include ANY Markdown citations, a separate agent will be responsible for citations. Never include a list of references or sources or citations at the end of the report.”

Research Subagent — Focused Investigator

The subagent prompt (research_subagent.md) is shorter and tighter. It assumes the lead has already done the planning work and the subagent’s job is to execute one <task> well.

Load-bearing design rules:

  • Research budget per complexity tier — under 5 tool calls for simple tasks, ~5 medium, ~10 hard, up to 15 for very difficult/multi-part. “Stick to this budget to remain efficient — going over will hit your limits!”
  • Minimum 5 distinct tool calls for the OODA loop on non-trivial tasks. Maximum 10. Never repeat identical queries.
  • web_fetch is mandatory after web_search — “use web search to run queries, then use web_fetch to get complete information using the URLs of the most promising sources.” Search snippets alone are insufficient.
  • Internal tools take priority when available (Google Drive, Gmail, Calendar, Slack, etc.). “The user intentionally enabled them, so you MUST use these internal tools during the research process.”
  • Source-quality skepticism is encoded in the prompt under <think_about_source_quality>: flag predictions (“could”, “may”), narrative-driven speculation, future tense with quoted superlatives, financial projections, news aggregators vs originals, false authority, marketing language, and cherry-picked data. Return concerns alongside facts.
  • Hard upper limit: 20 tool calls / 100 sources. Beyond that, the subagent is terminated.
  • The subagent never writes the final report. It returns a “detailed, condensed, complete, accurate report to the lead researcher” via the complete_task tool.

The prompt also bans one specific anti-pattern explicitly: evaluate_source_quality — “It is broken and using it will not work.”

Citations Agent — Annotator, Not Editor

The citations agent (citations_agent.md) is the shortest of the three and the most constrained. Its single job: take the lead’s finished report (inside <synthesized_text> tags), add citations using a specified format, and output the result inside <exact_text_with_citation> tags.

The contract is brutal about preservation:

  • “Do NOT modify the <synthesized_text> in any way — keep all content 100% identical, only add citations.”
  • “Pay careful attention to whitespace: DO NOT add or remove any whitespace.”
  • “Text without citations will be collected and compared to the original report from the <synthesized_text>. If the text is not identical, your result will be rejected.”

The citation guidelines are equally tight: cite key facts and substantive claims only (not common knowledge), prefer end-of-sentence placement, span complete thoughts (not phrase fragments), avoid sentence fragmentation, and never duplicate citations to the same source within one sentence.

Why This Three-Role Split

Architecturally, the split exists because each role has a different optimization target and a different failure mode if you collapse them:

  • Lead writes the report because synthesis across parallel subagent outputs is the highest-value task and requires the full picture. Delegating it to a subagent loses the cross-source reasoning.
  • Subagents do not write the report because they only see their own task slice. If they wrote, you’d get N partial reports the lead has to re-stitch — same work, lower quality.
  • Citations agent does not synthesize because it has the lead’s full report but no source-discovery context. Letting it edit prose introduces drift between the synthesized claim and the cited source. The whitespace-preservation rule is the structural guarantee.

This is the same shape Will (Anthropic Applied AI) describes in Decomposing an Agent — keep a subagent only when it has a distinct context, a distinct optimization target, and an output that won’t trivially be re-done by the parent. Collapse otherwise.

Try It

  • Use the lead prompt as a starting template for any research agent you’re building — copy research_lead_agent.md into your own prompt and adapt the <research_process> and <subagent_count_guidelines> blocks to your domain. The depth-first / breadth-first / straightforward classifier transfers cleanly to any planning agent.
  • Adopt the subagent ground-truth-only contract for any tool-using subagent you write: explicit research budget, mandatory web_fetch after web_search, internal-tools-first, source-quality skepticism block, hard tool-call ceiling. These five rules cut tail-latency and source-quality failures in production.
  • Wire the citations agent as a post-processing stage for any report-producing agent that needs verifiable attributions — the no-rewrite contract + whitespace preservation gives you a clean, testable handoff. Reject any output where the text outside <exact_text_with_citation> doesn’t match the input.
  • Read both prompts in full before designing your own multi-agent system. The README at patterns/agents/README.md only points to the basic-workflow notebooks; the design content is in the three .md prompt files.