Multi-Agent Design: LangGraph / Swarm / Sub-agents

AI Navigate Original / 4/27/2026

💬 OpinionIdeas & Deep AnalysisTools & Practical Usage
共有:

Key Points

  • Multi-agent: role-divided agents cooperate vs one big LLM
  • Split for specialization, cost, parallelism, privilege, testability
  • Frameworks: LangGraph, Swarm, Claude Code Sub-agents, AutoGen, CrewAI
  • Avoid over-design; run single first; cost is 4-5x; mind loops/handoffs

What Is Multi-Agent Design

A design where, instead of making one big LLM do everything, multiple agents with divided roles cooperate. Each agent has a different system prompt, tools, memory.

Why Split

  • Specialization: one body can't double as code reviewer and sales handler
  • Cost: cheap model for simple tasks, frontier for complex judgment
  • Parallelism: run multiple investigations concurrently
  • Privilege separation: separate the agent reading confidential data from the writing one
  • Testability: small roles can be unit-tested

Main Frameworks

LangGraph (LangChain)

Describe agent flows with a state-transition graph (StateGraph). Strong at complex branching/loops/conditional handoff.

  • Pro: explicit state management, easy to debug
  • Con: somewhat steep learning curve

OpenAI Swarm (Lightweight)

OpenAI's lightweight framework. Designed to "hand off" directly between agents.

  • Pro: simple, little code
  • Con: hard to write complex flows

Claude Code Sub-agents

A Claude Code feature. Calls sub-agents at the CLI level to delegate tasks. High affinity with coding work.

  • Pro: CLI-integrated, seamless file operation
  • Con: within the Claude ecosystem

Others

  • AutoGen (Microsoft): conversational multi-agent
  • CrewAI: role-based, human-team metaphor
  • Mastra: for TypeScript, lightweight

Typical Patterns

Coordinator + Specialists

A coordinator decomposes → delegates to specialist agents → integrates results.

Pipeline

Flow one-directionally: fetch → classify → summarize → output. Each step can be a different model.

Critic Loop

One body outputs → another criticizes → the original fixes, repeated. Effective for quality improvement.

Vote / Consensus

Have multiple agents solve the same problem, majority vote. For complex decision-making.

Design Principles

  1. Clarify roles: one body, one role like "code reviewer," "test writer"
  2. Make handoffs explicit: define what and how to pass, by data structure
  3. State management: separate conversation history and task memo
  4. Failure fallback: prepare an alternate route if one body fails
  5. Privilege minimization: write permission to a limited agent
  6. Audit log: trace who judged what

The Over-Design Trap

Starting with "5 agents for now" makes coordination cost explode. The iron rule: run with a single agent first, split only when need clearly arises.

Cost Estimate

A 4-body config with each 1,000 tokens × 5 turns = 20,000 tokens is standard. It tends to be 4-5x the cost of a simple "1 ChatGPT call." To cut cost:

  • Use lightweight models (Haiku, Mini) as much as possible
  • Pass summarized conversation history
  • Run parallel steps in parallel (cut wait time)

Operational Pitfalls

  • Infinite loops (forever fixing in a Critic Loop)
  • Handoff omission (needed info not conveyed to the next agent)
  • Role overlap/gap
  • Local optimization lowers overall performance

Summary

Multi-agent shows power with specialization and parallelization, but coordination cost and debug difficulty rise. Run single first, split as needed. Use LangGraph or Swarm as the main axis, and embed Claude Code Sub-agents into CLI workflows.