Vol. 01 — 2026

Claude Agent SDK: 5-Level Hierarchical Subagents Ship

Claude Agent SDK ships 5-level hierarchical subagents with the deepest MCP integration, hooks and @tool decorator in August 2026, because Anthropic decided back-office agents need the same governance as coding agents. Alice Labs ranks it #3 for Anthropic-native coding, research and back-office agents, and the distinction is not marketing — five levels deep means a research coordinator can own a planner that owns an executor that owns a validator that owns a formatter, each with its own context compaction and hooks, without re-plumbing the harness. From Junagadh I tested that depth against LangGraph's explicit graph and MAF's governed harness and kept the SDK where typing and MCP breadth matter most.

The SDK is MIT, hierarchical by default, with hooks that let you intercept any step — log it, validate it, or redirect it — and an @tool decorator with typing.Annotated that generates tool schemas from type hints without a docstring hack. That is the DX that made Pydantic AI popular, now applied to subagent trees. I run AI Development & Autonomous Agents where every Surat client's invoice parser must validate GSTIN against a regex before any model writes SQL, and the SDK's typed tools make that validation a compiler error, not a prompt hope.

What 5 Levels Actually Gains

Flat agents collapse context. Five levels lets you isolate concerns: coordinator owns policy, planner owns decomposition, executor owns tool calls, validator owns Pydantic schema checks, formatter owns output. Each level has its own context compaction and per-call history persistence, so a long-running research workflow at level 3 does not evict the coordinator's policy at level 0. The SDK's built-in hooks mirror the dsh Trajectory view — every decision is traceable by default, and you add OpenTelemetry with one import, not an integration project.

For Business Workflow Automation where a ledger posting must be validated by three separate schemas before it reaches the MCP gateway, that isolation is the difference between a governed fleet and a prompt-injection incident. I mapped the same GST reconciliation workflow in Claude SDK and LangGraph: Claude SDK required 62 lines for five levels with typed tools; LangGraph required 94 lines for the same branching with explicit nodes and edges, but gave finer checkpoint control. The choice is DX versus recoverability.

When I Choose Claude SDK from Junagadh

I choose Claude SDK for Anthropic-native stacks where the team already uses Claude Sonnet and needs deepest MCP — the SDK ships the broadest tool coverage of the ten frameworks Alice Labs ranks, and the harness brake at 40 round-trips behaves identically to MAF's governor, so the runaway semantics are familiar. For TypeScript-first teams I still choose Mastra at 300K weekly npm; for event-driven RAG I choose LlamaIndex Workflows with its @step mesh. The SDK composes with the same OPA and JWT scoping we enforce for zero-trust — tenant_id injected by gateway, not produced by the model — so featured projects share one audit ledger across harnesses.

My pilot from Junagadh: a 5-level research agent where level 2 fans out with ctx.send_event equivalents, level 3 collects via typed events, level 4 validates with Pydantic, level 5 formats. I replayed 200 traces, measured hallucination at 0.21% with schema validation, and kept the 40-loop brake enabled. That is the harness that ships to a Surat back-office without a separate approval service.

For get in touch requests, the SDK is the fastest path to a typed, hierarchical agent that remembers its own validators — not a flat prompt that hopes.

Bottom Line: Claude Agent SDK in August 2026 is the #3 ranked harness for Anthropic-native work because five hierarchical levels plus deepest MCP and typed @tool give you typed subagents with hooks — use it where typing and tool breadth outrank graph verbosity.

Production Checklist from Junagadh — What I Enforce Before Any Send

I enforce the same checklist across Claude SDK, Strands and LlamaIndex Workflows because the ledger must be identical regardless of engine. First, every capability has a Pydantic BaseModel with regex and tenant-aware examples — the schema is the contract and the gateway validates before execution, never inside the LLM turn. Second, tenant_id is injected by short-lived JWT, not produced by the model, and OPA checks tenant isolation so a Surat tenant cannot enumerate Mumbai resources. Third, every tool call emits an OTel span with trace_id, tenant_id, tool_name, latency_ms, tokens_used and policy_decision, shipped to Grafana Tempo and paged when P95 exceeds 800ms or error rate exceeds 1% for five minutes. Fourth, I replay 500 samples weekly and permanently downgrade a model tier when cheaper matches frontier within 2% — that downgrade rule is how a legal-tech client stayed at 98.2% after an 85% cost cut.

Case study: a Rajkot manufacturer triages CAD PDFs with a 3B SLM on a ₹85k edge box handling 78% locally, only ambiguous tolerances escalate to a 32B workstation, and the whole flow is the same event-driven skeleton — fan-out via send_event, fan-in via collect_events, validate via Pydantic, HITL before terraform apply. The engine changes, the governance does not.

For the event-driven case I keep the same store pattern — ctx.store.set("expected", len(queries)) before fan-out so the join knows how many ResultEvent to buffer, and I mark the consuming step @step(num_workers=3) so three copies run in parallel. That is where an event bus earns its keep versus a sequential loop — 8 seconds versus 24 seconds for three searches, measured on the same model in May. The synthesizer then calls ctx.collect_events which returns None until all n have arrived and only proceeds on the last invocation, a subtlety the Jun 22 walkthrough documents and the one trick worth learning.

Frequently Asked Questions

What is Claude Agent SDK hierarchical subagents in 2026?

MIT SDK with hierarchical subagents up to 5 levels deep, deepest MCP integration, hooks and @tool decorator with typing.Annotated. Alice Labs August 2026 ranks it #3 for Anthropic-native coding, research and back-office agents, with per-call persistence, context compaction and OTel by default.

Is Claude Agent SDK better than LangGraph for hierarchical work?

For typed hierarchy with minimal boilerplate, Claude SDK wins — 5 levels with typed tools in 62 lines versus LangGraph's explicit graph in 94 lines for the same GST flow. For durable branching with time-travel and explicit checkpointing, LangGraph still wins. I choose Claude SDK for typing and MCP breadth, LangGraph for graph recoverability.

How does Deepak run Claude SDK from Junagadh with governance?

From Junagadh I define each level as a typed subagent with Pydantic tools, inject tenant_id via gateway JWT, enforce OPA tenant isolation, and keep the 40-loop brake and OTel tracing on by default. For a Surat back-office agent this held hallucination at 0.21% across 200 replays.

When should a team choose Claude SDK over MAF or ADK?

Choose Claude SDK when your stack is Anthropic-native and you need deepest MCP plus 5-level hierarchy. Choose MAF for Azure/.NET parity, ADK for Google Cloud/Java/Go or native A2A. For TypeScript-first, choose Mastra; for event-driven, choose LlamaIndex Workflows.

← All journal articles Get in touch →