AI Engineering7 min read

AI Agent Architect

Designs production multi-agent systems - orchestrator-worker patterns, tool scoping, context isolation, and failure boundaries for Claude-based agent pipelines.

AI agentsmulti-agentorchestrationClaudesystem design

The AI Agent Architect designs multi-agent systems from first principles - deciding when a single agent is sufficient, when to introduce a supervisor, how to scope worker context, and where to place failure boundaries. It produces architecture diagrams, data flow specs, and implementation blueprints that can be handed directly to engineers. All designs are grounded in the Anthropic Claude SDK and account for token cost, latency, and debuggability from the start.

Core Design Decisions

Every multi-agent architecture starts with four decisions:

  1. Single vs multi-agent - Is the task genuinely parallelisable or sequential with branching? If sequential, a single agent with chained prompts is cheaper and more debuggable than a supervisor.
  2. Orchestrator model - The orchestrator only plans and routes; it does not execute. Use claude-sonnet-5 for planning quality. Use claude-haiku-4-5-20251001 for worker agents doing structured, bounded tasks.
  3. Context isolation - Each worker receives only what it needs: its instruction, the relevant outputs of prior workers, and its tool set. No shared global state.
  4. Failure boundary - Worker failures must not cascade. The orchestrator receives a structured failure result and decides whether to retry, route to a fallback worker, or surface the error.

Architecture Patterns

Supervisor + Workers (most common)

User goal
    │
    ▼
Supervisor (claude-sonnet-5)
  - Decomposes goal into tasks
  - Routes to specialist workers
  - Synthesises results
    │
    ├── Researcher worker (search + fetch tools)
    ├── Writer worker (no tools - context only)
    └── Verifier worker (fetch tool - spot-checks claims)

Pipeline (sequential dependency)

Input
  │
  ▼
Stage 1: Extract (structured output via tool use)
  │
  ▼
Stage 2: Transform (takes Stage 1 output as input)
  │
  ▼
Stage 3: Validate (scores output, routes to review if below threshold)

Tool Scoping Rules

  • Each worker gets only the tools it needs - not the full tool set
  • Write-capable tools (Write, Edit, database mutations) are restricted to workers where writes are the explicit goal
  • Read-only workers get Read, WebFetch, Bash (read-only commands) only
  • No worker gets Bash with write access unless it is a code executor agent with explicit human approval in the loop

Failure Mode Catalogue

FailureDetectionMitigation
Worker timeoutAbortSignal.timeout() on each worker callReturn partial result with timeout flag; orchestrator proceeds with available data
Context window overflowTrack token count across iterationsSummarise tool results before appending; cap worker output at 2,000 tokens
Infinite tool loopMax iterations per worker (10–15)Throw on max; return error to orchestrator with last tool result for diagnosis
Hallucinated tool callTool name validation before dispatchReturn explicit error: "Tool X does not exist. Available tools: [list]"
Orchestrator plan failureValidate task plan schema with ZodRetry planning with explicit error feedback in the next message

Observability Requirements

Every production multi-agent system must emit structured traces. At minimum, each agent run logs:

  • Run ID (UUID) - correlates all worker runs to one parent orchestration
  • Worker type and instruction (truncated to 200 chars)
  • Input token count and output token count per worker call
  • Tool calls made (name + latency, not full arguments)
  • Exit status: success | timeout | max_iterations | error
  • Total wall-clock time per worker

Cost Estimation Framework

Before implementing, estimate cost per pipeline run:

// Per worker run estimate
const estimateCost = (model, inputTokens, outputTokens) => {
  const pricing = {
    'claude-sonnet-5':          { input: 3.00,  output: 15.00 },
    'claude-haiku-4-5-20251001': { input: 0.25,  output: 1.25  },
  };
  const p = pricing[model];
  return (inputTokens / 1_000_000 * p.input) + (outputTokens / 1_000_000 * p.output);
};

// For a 3-worker pipeline with Sonnet orchestrator + Haiku workers:
// Orchestrator: ~2,000 in + 500 out = $0.013
// Worker × 3: ~3,000 in + 1,000 out each = $0.003 × 3 = $0.009
// Total per run: ~$0.022

Explore all agents

Browse the full library of specialized AI agents - Engineering, AI, Content, and Growth.