Pattern reference for dev teams shipping agents

Five runnablemulti-agent patterns.Full code. Two SDKs.

The Agent Orchestration Cookbook is a pattern reference for dev teams shipping multi-agent AI systems. It holds five patterns: Orchestrator-Worker, Routing, Retry-with-Reflection, Code Review Agent, and Hierarchical Supervisor. Each pattern ships with full code in Claude Agent SDK and LangGraph, in both Python and TypeScript, plus a control-flow eval, failure-mode notes, and a directional cost analysis.

Get the Cookbook — $79one-time · full source, run it in your repo · 30-day refund
5 patterns · two SDKs
5 Orchestration Patterns
4 paths each
Full Code · SDK + LangGraph
TS · PY
Control-Flow Eval per Pattern
18 cases
Failure-Mode + Cost Notes
Per pattern
Runs in
Python · TypeScript · Claude Agent SDK · LangGraph
01.The Problem

Every team is building agents. Almost everyone is reinventing the same patterns badly.

Your team ships its first agent. It works in the demo. It fails in three weeks of production because nobody handled the retry-with-reflection edge case where the model loops forever. You patch it. The next agent ships. Same loop happens.

Multi-agent patterns are not new. The orchestrator-worker pattern, the hierarchical-supervisor pattern, the parallel map-reduce — these are solved problems with known failure modes. The problem is the knowledge lives in Anthropic engineering blogs, LangChain Discord threads, a handful of conference talks, and the memories of senior engineers who learned the hard way.

The cookbook is what your senior engineer would build on their best week — written down, with a control-flow eval, a cost model, and failure notes. Drop the patterns into your repo. Stop reinventing.

The reinvention pattern · Symptoms
  • 01Engineer writes a multi-step agent in 4 days; works in dev
  • 02Production: agent loops forever on edge case in ticket 23
  • 03Team adds max_iterations=10 as a band-aid; ticket 47 hits limit silently
  • 04Adds reflection step that doubles token costs without measurable quality gain
  • 05Reads a blog post about supervisor patterns; rewrites half of it
  • 06Six weeks later: still no eval harness, no failure-mode docs, no cost dashboard
02.What's Inside

Six deliverables. Engineered to ship together.

01

The Five-Pattern Library

Orchestrator-Worker, Routing, Retry-with-Reflection, Code Review Agent, Hierarchical Supervisor. Each lives in its own folder with the same layout, and each README says when to use it and when not to.

02

Full Implementation Code

Each pattern in four paths: Claude Agent SDK (Python + TypeScript), LangGraph (Python + TypeScript). Real implementations, not pseudocode. The LangGraph copies run offline on a deterministic mock; the Agent SDK copies need Claude Code and an API key.

03

Control-Flow Evals

A run_eval.py and a golden.json per pattern, 18 cases across the five. They run offline on the mock and exit 0 or 1. They check the orchestration (who fired, how many times, what merged), not the quality of a model's answer.

04

Failure-Mode Notes

Five failure modes per pattern: how it breaks, how to catch it, how to mitigate it. Written as engineering notes; they are not incident reports from a named deployment.

05

Directional Cost Analysis

The cost formula for each pattern, what it scales with, and the levers in rough order of impact. A model of cost structure with no dollar figures and no latency measurements; you plug in your own prices.

06

Architecture Decision Records

One ADR per pattern: the decision, why this shape, what was rejected, and the consequences. The reasoning written down so you can defend the choice in code review.

03.The 5 Patterns

Five patterns. Every one in four implementation paths.

01

Orchestrator-Worker

3 eval cases
  • ·One ask, independent sub-asks, one merged answer
  • ·The orchestrator decomposes; one worker fires per subtask
  • ·Fan-out is sized at runtime, not hard-wired
  • ·The aggregator sorts by subtask id before merging
  • ·Eval: no dropped or duplicated worker results
02

Routing

5 eval cases
  • ·Classify one input, send it to exactly one handler
  • ·Reference categories: billing, technical, sales, general
  • ·A single conditional edge picks the one target
  • ·An unknown class falls back to the general catch-all
  • ·Eval: one router call, one handler, the right handler
03

Retry-with-Reflection

3 eval cases
  • ·Draft, critique, revise, until it passes or hits the cap
  • ·The critic returns PASS or a revision note
  • ·Hard iteration cap, set to 3 in the reference code
  • ·Stops on the first PASS
  • ·Eval: the loop terminates; draft calls equal critic calls
04

Code Review Agent

4 eval cases
  • ·One diff reviewed on four fixed aspects in parallel
  • ·Correctness, security, style, performance
  • ·Findings merged and sorted by severity
  • ·Verdict is block when any blocker finding exists
  • ·Eval: one reviewer per aspect, sorted merge, verdict
05

Hierarchical Supervisor

3 eval cases
  • ·A supervisor routes a goal to one or more teams
  • ·Each team lead coordinates its own workers
  • ·Reference teams: research and writing
  • ·Team results bubble up to one assembler
  • ·Eval: the right teams engaged, no team result dropped
+

What Every Pattern Folder Holds

same layout

README.md, ADR.md, failure-modes.md, cost-analysis.md, an eval folder with golden.json and run_eval.py, and the code under langgraph and claude-agent-sdk, each in python and typescript. A shared mock model backs the offline runs.

Five patterns ship in this release. More patterns are planned and are not in it. Additions and corrections released in the 12 months after your purchase are included. To get them, reopen the purchase page from your delivery email or sign in at redhub.ai/rig. No update email is sent.

04.Inside a Pattern

Sample: Pattern 02, Routing. Code, eval output, failure notes, cost model.

pattern · 02-routing
single-target dispatch

Routing

A router classifies one input into exactly one category, and a conditional edge dispatches it to the single matching handler. No fan-out, no merge. An unrecognized class falls back to the general catch-all, so an off-menu label cannot send the input to a handler that does not exist.

Incoming message
   │
   ▼
┌──────────────┐
│    Router    │ ← classifies into one category
│  (category)  │
└──────┬───────┘
       │  one conditional edge, one target
       ├──→ billing handler
       ├──→ technical handler
       ├──→ sales handler
       └──→ general handler    ← catch-all for an unknown class
langgraph · python · routing.py
excerpt · docstring omitted
CATEGORIES = ["billing", "technical", "sales", "general"]


def build_graph(model):
    def router(state: State) -> dict:
        # The router CLASSIFIES — it returns a bare category string, nothing else.
        raw = model.complete("router", f"Classify this message into one category: {state['message']}")
        category = raw.strip().lower()
        if category not in CATEGORIES:
            category = "general"  # fail safe: an unknown class lands on the catch-all
        return {"category": category}

    def choose_handler(state: State) -> str:
        # The conditional edge returns the NAME of the one handler node to run.
        return state["category"]

    def make_handler(category: str):
        def handler(state: State) -> dict:
            reply = model.complete("handler", f"[{category}] Reply to: {state['message']}")
            return {"reply": reply}
        return handler

    g = StateGraph(State)
    g.add_node("router", router)
    for cat in CATEGORIES:
        g.add_node(cat, make_handler(cat))
    g.add_edge(START, "router")
    # One input -> exactly one handler. The conditional edge picks the single target.
    g.add_conditional_edges("router", choose_handler, CATEGORIES)
    for cat in CATEGORIES:
        g.add_edge(cat, END)
    return g.compile()
captured stdout
exit 0
$ python patterns/02-routing/langgraph/python/routing.py
category: billing
Billing: I've pulled up your account — here's how to resolve that charge.

[trace] router calls=1 handler calls=1

$ python patterns/02-routing/eval/run_eval.py
  [PASS] billing-double-charge
  [PASS] technical-login-error
  [PASS] sales-pricing-demo
  [PASS] general-greeting
  [PASS] technical-broken-feature

5/5 cases passed

Captured from the shipped zip on 2026-10-07 with Python 3.13.7 and langgraph 1.2.5, against the deterministic mock model. PASS means the control flow held on the mock. It does not measure how accurately a real model routes.

Failure modes · 3 of the 5 in failure-modes.md
  • ·The router mis-classifies. A billing question gets labeled technical, and the handler gives a fluent answer from the wrong specialist. Catch it by evaluating the router’s choice, not the final reply.
  • ·An out-of-distribution input has no home. An off-menu label would dispatch to a node that does not exist. The reference code maps any unrecognized class to the general catch-all.
  • ·The router becomes the bottleneck. Every request pays for one router call before any work happens. Tier the router onto the cheapest model that holds your eval accuracy, or pre-filter the obvious cases.
cost-analysis.md · the cost shape
directional
cost_per_run = router_call + handler_call

Two calls per run, always: one to classify, one to handle. The cost is flat in the number of categories, because only one handler fires. No dollar figures ship; plug in your own token shapes and your provider’s current prices.

LeverEffectNote
Tier the router to a cheap modelLargest — paid on 100% of trafficVerify accuracy holds on your routing eval first
Deterministic pre-filter (keyword/regex)Skips the router call on obvious inputsOnly model-classify the ambiguous remainder
Tier handlers per categoryMatches spend to class difficultyCheap model for easy categories, strong for hard
Prompt-cache the router's category rubricCuts repeated input tokens on every classifySavings depend on cache-hit rate — verify with your provider
Collapse router + handler for trivial casesRemoves the router call entirelyOnly when one model can classify-and-answer cheaply

One pattern of five. Each one ships with the same parts: a README, code in four implementation paths, a control-flow eval, failure-mode notes, a cost analysis, and an architecture decision record.

05.Platform Coverage

Two platforms. Two languages. Four implementation paths per pattern.

Two platforms keep the scope manageable. Claude Agent SDK is Anthropic’s agent runtime: it owns the model loop and subagent delegation, so those copies need Claude Code and an API key. LangGraph is an open-source graph runtime you drive with your own model calls, so those copies take an injected model client and run offline against the included deterministic mock. Pick the path that matches your stack. Ignore the rest.

Claude Agent SDK
Python · needs Claude Code + API key
$ pip install claude-agent-sdk

Anthropic-committed stack. The SDK is the agent runtime, so these copies need Claude Code on PATH and an ANTHROPIC_API_KEY (or a logged-in subscription).

Claude Agent SDK
TypeScript · needs Claude Code + API key
$ npm install @anthropic-ai/claude-agent-sdk

The same patterns on Node, written against the TypeScript SDK. Needs Claude Code on PATH and an ANTHROPIC_API_KEY.

LangGraph
Python · runs offline on the mock
$ pip install langgraph

Provider portability. Takes an injected model client, so it runs against the included deterministic mock with no key. The shipped evals run this copy.

LangGraph
TypeScript · runs offline on the mock
$ npm install @langchain/langgraph

Provider portability on Node. The twin of the Python copy: the same injected model client and the same deterministic mock.

The patterns themselves translate. If your stack is on a different framework — OpenAI Agents SDK, Mastra, CrewAI, bare provider APIs — the architectures, failure-mode notes, and cost analysis still apply. You’ll port the code yourself, but you don’t reinvent the patterns.

06.What's Not in the Cookbook

Be honest about what the $79 buys you. And what it doesn’t.

✓
What’s in
  • Five patterns, full code in four implementation paths each.
  • A control-flow eval per pattern: 18 cases that run offline on a mock.
  • Five failure modes per pattern, each with how to catch and mitigate it.
  • A directional cost analysis per pattern: the formula and the levers.
  • Architecture decision records explaining why each pattern was designed this way.
✕
What’s out
  • Not a managed platform. No UI, no hosted runtime, no observability dashboard. The cookbook is code and documentation; deployment is your problem.
  • Not OpenAI Agents SDK, Mastra, or CrewAI. Two platforms deliberately. Patterns translate; ports are your problem.
  • Not voice agents. Different product category. See the Voice Agent Deployment Kit if that’s your scope.
  • Not fine-tuning or training. The cookbook assumes you’re using off-the-shelf models. Custom training is a separate discipline.
  • Not a RAG cookbook. None of the five patterns covers retrieval. RAG architecture is a different category with its own cookbook-shaped book somewhere out there.

The cookbook is one thing — a pattern reference for multi-agent orchestration — and it does that one thing thoroughly. The boundaries are deliberate. Other RedHub AI products cover other parts of the AI engineering stack.

07.Who This Is For

Be honest with yourself before you click buy.

✓
Buy if
  • Your team ships multi-agent features in production or is about to.
  • You’re using Claude Agent SDK, LangGraph, or considering either.
  • You’ve already reinvented at least one pattern badly.
  • You’re a senior engineer, AI/ML engineer, eng manager, or technical founder.
  • You want runnable patterns to own, not blog-post snippets to translate.
✕
Skip if
  • You’re using OpenAI Agents SDK exclusively (patterns translate, code doesn’t).
  • You haven’t shipped a single agent to production yet — start simpler.
  • You want a managed platform with a UI and dashboards.
  • You want done-for-you implementation, not a cookbook to own.
  • Nobody on your team reads TypeScript or Python.
08.Pairs Well With

Orchestrate the agents, then prove they hold.

The patterns here stitch agents together; the rest of the reliability stack proves they work. The Agent Reliability Harness stress-tests the orchestrated flow end-to-end, the Prompt Eval System scores the prompts each step depends on, and the RAG Retrieval Grader grades the retrieval feeding them.

09.Common Questions

The questions engineers actually ask before pulling out the company card.

Two platforms keep the scope manageable. Claude Agent SDK is Anthropic's agent runtime: it owns the model loop and subagent delegation, so those copies need Claude Code and an Anthropic API key. LangGraph is an open-source graph runtime you drive with your own model calls, so those copies are not tied to one provider and run offline against the included mock. OpenAI Agents SDK, Mastra, and CrewAI are not covered. The patterns themselves translate: if you're on a different stack, the architecture decision records and failure-mode notes still apply, and the port is yours.

Instant access · 12 months of updates · 30-day refund

Stop reinventing patterns.
Ship the ones that work.

$79 once. Five patterns. Full code in Claude Agent SDK and LangGraph, Python and TypeScript. Control-flow evals, failure notes, cost models. Your senior engineer’s best week, written down.

Sold by RedHub AI LLC · Secured by Stripe · redhub.ai