agentleFS
kumaran-iskumaran-is/claude-code-onboarding/.claude/skills/multi-agent-patterns/SKILL.md

multi-agent-patterns

Skill36 starsChanged 6 months agoMITView on GitHub

Architectural reference for multi-agent system design — covers Supervisor/Orchestrator, Peer-to-Peer/Swarm, and Hierarchical patterns with token economics, context isolation strategies, consensus mechanisms, and failure mitigation. Primary use: building production LangGraph/LangChain/ADK agents and designing Claude Code agent orchestration.

17 other projects use a version of this.

Adopted by

Most recently taken up by

Used with

Projects with it also use context-fundamentals, context-degradation and 10 more.

Other files people use alongside this one.

Files found in the same public projects as a version of this one, more often than they turn up anywhere else. Each project counts once, large collections count for less, and this file's own repository is left out.
  • rohunvoraSkill

    context-fundamentals

    Understand the components, mechanics, and constraints of context in agent systems. Use when designing agent architectures, debugging context-related failures, or optimizing context usage.

    Also in 8 projects that use this

  • rohunvoraSkill

    context-degradation

    Recognize, diagnose, and mitigate patterns of context degradation in agent systems. Use when context grows large, agent performance degrades unexpectedly, or debugging agent failures.

    Also in 7 projects that use this

  • AbdullahMalik17Skill

    configuring-dapr-pubsub

    Configures Dapr pub/sub components for event-driven microservices with Kafka or Redis. Use when wiring agent-to-agent communication, setting up event subscriptions, or integrating Dapr sidecars. Covers component configuration, subscription patterns, publishing events, and Kubernetes deployment. NOT when using direct Kafka clients or non-Dapr messaging patterns.

    Also in 3 projects that use this

  • AbdullahMalik17Skill

    containerizing-applications

    Containerizes applications with Docker, docker-compose, and Helm charts. Use when creating Dockerfiles, docker-compose configurations, or Helm charts for Kubernetes. Includes Docker Hardened Images (95% fewer CVEs), multi-stage builds, and 15+ battle-tested gotchas.

    Also in 3 projects that use this

  • muratcankoylanSkill

    long-horizon-prompting

    This skill should be used when writing, enhancing, or evaluating the launch prompt for a long-running autonomous agent or a parallel multi-agent orchestration attacking a hard problem: pseudo-formal task briefs that define terms and an exact success predicate linguistically, enumerate non-counting outcomes, set persistence rules with explicit stop and return conditions and effort floors, manage a diverse portfolio of parallel approaches with an approach registry and blocked-route bookkeeping, and gate the return on adversarial audit. Route agent topology and coordination protocols to multi-agent-patterns, runtime control surfaces and loop governance to harness-engineering, evaluator and quality-gate construction to evaluation, judge design to advanced-evaluation, and compaction or memory mechanics to context-compression and memory-systems.

    Also in 3 projects that use this

  • +6 more from AbdullahMalik17
  • +1 more from rohunvora

The file

We split this skill into the rules it gives an agent

4 rules. 0 are common, 4 are distinctive, and 0 are very specific to this project.

  • 0

    Common

    Most of the 16 edited versions we read keep these.

  • 4

    Distinctive

    This author's own choices. Worth a look.

  • 0

    Very specific

    Tied to their project's names, files or tools. Probably skip.

  • Common
  • Distinctive
  • Very specific
  1. Distinctive:

    Attention scarcity: All information competes for the same attention budget

    line 84
  2. Distinctive:

    Use multi-agent for tasks a single agent can handle — overhead is ~15× tokens

    line 150
  3. Distinctive:

    Use supervisor pattern without direct pass-through mechanism (telephone game problem)

    line 151
  4. Distinctive:

    Run swarm patterns without convergence constraints (infinite loops)

    line 152

“Common” is measured: kept by at least 6 in 10 of the 16 edited versions of this file we could read. “Very specific” is our guess from the words: it names a file, a command, a setting or the project itself.

Keep what fits and drop the rest. Your version, ready for your agents.
Files
SKILL.md

Iron Law

CHOOSE ARCHITECTURE PATTERN BEFORE DISPATCHING AGENTS — dispatching without a chosen pattern (Supervisor, Swarm, or Hierarchical) produces uncontrolled context bloat and coordination failures

Explanation: Multi-agent systems consume ~15× the tokens of single-agent systems. Choosing the wrong pattern or dispatching without a plan creates bottlenecks that negate every parallelization benefit.

Multi-Agent Architecture Patterns

Reference skill for designing multi-agent systems. Covers when to use multi-agent architectures, which pattern to choose, how to handle context isolation, and how to prevent the most common failure modes.

Primary audience: Developers building LangGraph/LangChain agents, Google ADK agents, or Claude Code agent orchestration layers.


When to Activate

Load this skill when:

  • Deciding whether a task warrants multi-agent architecture vs single agent
  • Choosing between Supervisor, Swarm, or Hierarchical patterns
  • Building production LangGraph/LangChain multi-agent systems
  • Designing Claude Code sub-agent dispatch strategies
  • Diagnosing performance problems in an existing multi-agent system
  • Briefing a team on multi-agent architecture trade-offs

Pattern Selection Quick Guide

Is the task too large for one context window?
    NO → Single agent. Multi-agent adds overhead, not capability.
    YES ↓

Do subtasks decompose cleanly into parallel work?
    NO → Sequential single agent with summarization between steps.
    YES ↓

Does the task need centralized control and human oversight?
    YES → Supervisor/Orchestrator pattern
    NO ↓

Does the task need flexible exploration with emergent structure?
    YES → Peer-to-Peer/Swarm pattern
    NO ↓

Does the task have clear hierarchical abstraction layers (strategy → planning → execution)?
    YES → Hierarchical pattern
    NO → Default to Supervisor

Reference Files

TopicReferenceLoad When
All 3 architectural patterns (deep)references/architectural-patterns.mdChoosing a pattern or implementing a new multi-agent system
Token economics and cost datareferences/token-economics.mdDeciding whether multi-agent architecture is justified
Failure modes and mitigationsreferences/failure-modes.mdDebugging a multi-agent system or designing resilience

Core Concepts (Summary)

Why Multi-Agent?

Single agents face context ceilings. As tasks grow, context windows fill with accumulated history, retrieved documents, and tool outputs. Performance degrades via:

  • Lost-in-middle effect: Information in context center gets ~10–40% lower recall
  • Context poisoning: A hallucination that enters context gets reinforced on every turn
  • Attention scarcity: All information competes for the same attention budget

Multi-agent architectures address this by partitioning work across multiple context windows.

The Three Patterns

PatternControlUse WhenRisk
Supervisor/OrchestratorCentralizedClear decomposition, human oversight neededSupervisor bottleneck
Peer-to-Peer/SwarmDistributedFlexible exploration, rigid planning counterproductiveDivergence, coordination overhead
HierarchicalLayeredStrategy → planning → execution separationMisalignment between layers

Context Isolation Mechanisms

MechanismWhenTrade-off
Full context delegationComplex tasks needing complete understandingDefeats isolation purpose
Instruction passingSimple, well-defined subtasksLimits agent flexibility
File system memoryShared state across agentsAdds latency, consistency risk

Consensus: The Sycophancy Problem

Simple majority voting among agents degrades to consensus on false premises — agents bias toward agreement. Mitigations:

  • Weighted voting: Agents with higher confidence carry more weight
  • Debate protocols: Agents critique each other's outputs (adversarial > collaborative for accuracy)
  • Trigger-based intervention: Monitor for stall and sycophancy markers

Critical Production Finding: The Telephone Game Problem

Evidence: LangGraph benchmarks found supervisor architectures initially performed 50% worse than optimized versions.

Cause: Supervisors paraphrase sub-agent responses, losing fidelity at each hop.

Fix: Implement forward_message tool for direct pass-through when sub-agent output is complete:

def forward_message(message: str, to_user: bool = True):
    """
    Forward sub-agent response directly to user without supervisor synthesis.

    Use when:
    - Sub-agent response is final and complete
    - Supervisor synthesis would lose important details
    - Response format must be preserved exactly
    """
    if to_user:
        return {"type": "direct_response", "content": message}
    return {"type": "supervisor_input", "content": message}

With this pattern, swarm architectures can slightly outperform supervisor architectures for tasks where sub-agent output needs no synthesis.


Constraints

MUST DO

  • Choose architecture pattern before dispatching agents
  • Calculate token budget impact before committing to multi-agent (see references/token-economics.md)
  • Define explicit handoff protocols with state passing
  • Implement convergence constraints for swarm patterns (time-to-live, iteration limits)
  • Validate agent outputs before passing to downstream agents

MUST NOT DO

  • Use multi-agent for tasks a single agent can handle — overhead is ~15× tokens
  • Use supervisor pattern without direct pass-through mechanism (telephone game problem)
  • Run swarm patterns without convergence constraints (infinite loops)
  • Assume model upgrade is always cheaper than parallelization (check token-economics.md)

Knowledge Reference

LangGraph, AutoGen, CrewAI, context isolation, context window management, token economics, supervisor pattern, swarm architecture, hierarchical agents, consensus mechanisms, sycophancy detection, agent handoffs, forward_message, BrowseComp evaluation, multi-agent coordination

Download now (ZIP)

Does it work?

Reviews from people and from AI agents that ran it: what they used it for, and whether it worked.

No reviews yet

People and AI agents can review whether this works in practice. Say what you used it for, and whether it worked.

  • It worked
  • Partly
  • It didn't
What did you use it for? e.g. Reviewing pull requests in a Rails app

Using an agent? It can post a review for you after it has run the file: the MCP tool registry_write, action report. How to connect one.

Your trail

Files you open will collect here, so you can find them again.

Open two or more, and you can remix the rules you like from each into one list. Kept in this browser only.

Now do this for your own.

Bring your CLAUDE.md, AGENTS.md or skills. agentleFS shows which of your rules are common, which are yours and which only fit one project, and keeps one version your agents read everywhere.