Practical Guides Β· knowledge base from X

Building your first AI agent team with Claude Opus 5.5 (SDK, roles, budget)

A hands-on course on multi-agent teams with the Claude Agent SDK and Opus 5.5: orchestrator + specialists + critic, context isolation, parallelism, least privilege, handoffs, effort per role, caps on depth/concurrency/spend, an elapsed-time clock and anti-early-stop β€” based on Anthropic's documentation, not demo folklore.

✍️ Khairallah AL-Awady · @eng_khairallah1
πŸ”— Read the original on X Β· X Article Β· published 29 Sep 2026
πŸ“Š 265 likes Β· 787 bookmarks Β· 469k views
Summary and adaptation in English; content and results belong to the author.

Part of the manual Automation with AI agents β€” the complete manual

Claimed result

  • Anthropic result (Opus 5.5 prompting guide): with an elapsed-time budget, a team of agents keeps answer quality comparable to a single agent but finishes sooner.
  • Opus 5.5: 66.4% on Terminal-Bench 4.0 vs 55.8% for Claude Fable 5.1 (a bigger model); about 40% cheaper than Opus 5 on typical workloads; an early tester completed a 680,000-line migration in under a day.
  • Prices cited: $4/MTok input, $20/MTok output (down from Opus 5's 5/25); cache reads $0.20/MTok.
  • Thesis: most "multi-agent" setups today are expensive chaos (vague roles, full permissions, zero caps, half-passed context) that fails in production and the model gets blamed β€” the problem is the architecture.

Proof: medium-high. Anchored to Anthropic guides/SDK and public metrics; it's not a revenue case study of the author's. High engagement (787 bookmarks, ~469k views).

The key idea

Four real benefits of delegating to subagents (Agent SDK documentation): 1. Context isolation β€” every subagent has a fresh conversation; only the final message returns to the parent (a researcher can read 50 pages without bloating the orchestrator). 2. Parallelization β€” N independent sub-tasks take as long as the slowest, not the sum. 3. Specialized instructions β€” a system prompt tailored to the role, without noise on the orchestrator. 4. Tool restriction β€” a reviewer that shouldn't edit doesn't receive Edit.

Three Opus 5.5 behaviors that change the math of teams: lower cost (teams multiply tokens); default effort of medium that matches/beats Opus 5 high on coding/knowledge, with subagents typically at low; time awareness (it uses elapsed time to optimize parallelism).

Rule zero: most tasks don't need a team. A team adds overhead, API calls, tokens and new ways to fail. Use a team only if at least one of the four benefits does real work. Otherwise: a single well-prompted agent wins on speed and cost.

Anatomy: orchestrator (plans, delegates, integrates β€” it's the only one you talk to) + narrow specialists (researcher / writer / analyst) + critic (the one almost everyone skips: reviews against a standard and sends work back). Without a critic: fast, self-confident garbage.

Step-by-step playbook

Step 1 β€” Claude Agent SDK setup

  • Python β‰₯ 3.10 or Node β‰₯ 18; an API key from the Claude Console.
  • The key goes into the process environment; the SDK does not load .env by itself.
  • If you're building a product for third parties: Anthropic does not allow claude.ai login/rate limits without approval β€” use API key authentication.

Step 2 β€” The orchestrator alone first

The most common mistake: designing five agents before one works. Run the orchestrator alone, check that the task is achievable, note where it struggles, where it spends tokens, which pieces were independent β†’ those become parallel specialists; where quality wobbles β†’ the critic's job.

Step 3 β€” The first specialist (AgentDefinition)

Critical fields: - prompt = the specialist's system prompt (role, standards, output format, boundaries β€” like briefing a contractor). - description = what the orchestrator reads to decide when to delegate. Vague β†’ it doesn't use it, or uses it badly. Write it as a precise rule. To force an agent: "Use the researcher agent to check each claim." - The orchestrator must have Agent in allowed_tools (subagents are invoked via the Agent tool).

Step 4 β€” Least privilege for every role

A tool missing from the list doesn't exist in the session (no permission prompt, no error). Typical Anthropic combinations: | Role | Tools | |---|---| | Read-only analysis | Read, Grep, Glob | | Testing | Bash, Read, Grep | | Code changes | Read, Edit, Write, Grep, Glob |

Critic β†’ read-only (if it can edit, it "fixes" silently instead of reporting). Researcher β†’ search/fetch, no Write. Only the one producing the file has Write. Opus 5.5 tried to get around boundaries ~85% less than Opus 5 in containment tests: declared limits carry more weight β€” a reason to set them, not to skip them.

Step 5 β€” Solving the handoff

The subagent does not see the parent's history, tool results or system prompt. The only content passed is the Agent tool's prompt string. "Now write it up" with no context = a blind writer. Every path, decision, constraint and piece of evidence must be in the delegation message. Instruct the orchestrator accordingly; if you need verbatim output, tell it to keep it as is (the parent may summarize).

Step 6 β€” Real parallelism

Subagents run in the background by default: the orchestrator can launch several and keep going. Three researchers on three frameworks = parallel; one writer that needs all three reports = sequential afterwards. Tell the orchestrator explicitly what can run together. Custom tools with readOnlyHint=True can run in parallel with other read-only ones β€” only if they don't modify anything.

Step 7 β€” Critic + a cap on the cycle

Every draft β†’ critic; FAIL β†’ back to the writer with the exact list; repeat until PASS. Cap at 3 rounds, then return the best draft with the remaining objections. A clear exit = a system; without one = a loop that burns budget.

Step 8 β€” Effort per role

Levels: low, medium, high, xhigh, max. On Opus 5.5 thinking is always on; effort controls how much it reasons. AgentDefinition.effort: - Researchers / simple workers β†’ low - Writer and critic β†’ medium - Orchestrator β†’ medium (high if the evals improve) - xhigh for agentic work over ~30 min; max only if you've measured a real gain. Do a sweep on your own evals; don't copy settings from old models.

Step 9 β€” Caps on depth, concurrency, spend

Claude decides by itself when to spawn; subagents can spawn subagents. Without limits: an unexpected tree and an unexpected bill.

Cap Default Advice
CLAUDE_CODE_MAX_SUBAGENT_SPAWN_DEPTH 3 layers 1 (specialists don't spawn)
CLAUDE_CODE_MAX_CONCURRENT_SUBAGENTS 20 tune for your case
max_budget_usd / maxBudgetUsd no limit always set it before pressing Enter

At the cap: the SDK refuses new spawns, stops background work and exits with error_max_budget_usd.

Step 10 β€” Give the team a clock

Recommended format: elapsed 340s / 1200s; a budget a bit above the time you want; if you can't predict the duration, show only elapsed + a pacing instruction. The budget is advisory (pacing, not a hard stop): the real timeout goes in your own code.

Step 11 β€” Prevent early stopping

Opus 5.5 tends to end its turn with a text update instead of a tool call β†’ in an unattended loop the work stops. Patterns to forbid explicitly in the system prompt: a summary announcing the next step with no tool call; an offer to continue "unless you object"; a list of decisions that don't really block; treating a milestone as a good point to report. A checklist updated by the model; if the harness sends auto-continue, stop after 2–3 so it doesn't loop forever.

A complete example team

The orchestrator plans/delegates; 3 researchers in parallel at low effort with search tools only; a writer working only from verified findings; a read-only critic; depth/concurrency/spend/wall-clock capped; early-stop patterns named.

Mistakes that kill teams

  1. Five agents before one works.
  2. Vague descriptions ("helps with research").
  3. Thin handoffs.
  4. No critic.
  5. Full permissions everywhere.
  6. No spending cap (default unlimited).
  7. Trusting the advisory clock without a hard timeout.
  8. Irreversible actions (sending emails, publishing, spending, deleting) without human approval β€” drafting yes, sending no.

Final truth: a team doesn't fix a process you don't understand. If you can't describe the steps, five agents won't help any more than one. The code takes an afternoon to write; clear thinking about the process is the real work.

Tools and costs

Element Detail
Claude Agent SDK Python/TS, the same loop as Claude Code
Opus 5.5 $4/M input, $20/M output, cache $0.20/M
Effort a cost lever per role (low on workers)
max_budget_usd cap mandatory on every run
Depth/concurrency env vars avoids runaway trees and bills
Claude Console API key product auth

Limitations

  • It's not a customer-acquisition playbook: it's agent-team engineering.
  • It depends on the Anthropic API and on eval/cap discipline; without them costs explode.
  • The code snippets in the original article are illustrative (in the raw, partly omitted as empty blocks): consult the up-to-date SDK docs.
  • Opus 5.5 / Fable 5.1 / prices may change; always check the console.
  • A "team" doesn't replace product sense or a clear human process.
← More guides in β€œAutomation with AI agents”