multi-agent-patterns: Multi-Agent Collaboration Architectures and Context Isolation

Preface

In long-running tasks, a single Agent often piles retrieval results, tool outputs, and conversation history into the same context window, leading to problems such as diluted attention, loss of intermediate information, or “pollution” of effective signals by irrelevant content. Consequently, many teams split tasks into multiple model instances for parallelism or role division. However, without a clear coordination protocol, the cost of coordination can offset the benefits of this decomposition.

The following introduces the Skill multi-agent-patterns from the repository Agent-Skills-for-Context-Engineering. During the design phase, it helps you choose architectures such as Orchestrator, Peer-to-Peer, and Hierarchical. It treats “context isolation” as the primary reason for splitting sub-Agents, rather than simply simulating organizational roles.

What is this

multi-agent-patterns is a structured guide (in SKILL.md format) focused on “Multi-Agent System Design,” maintained as part of the Context Engineering skill collection project. The official description states that this Skill should be enabled when context isolation, supervisor or swarm coordination, explicit handoffs, parallel execution are required, or when a judgment call is needed on “whether multi-Agent is truly worth it.”

Its core proposition is that sub-Agents primarily serve to isolate context—each instance processes a sub-task within a relatively clean window, preventing information degradation during repeated summary transmission (the so-called “telephone game” or “baton-dropping”).

Adjacent to this Skill’s boundary, work officially assigned to other Skills includes: task-to-model matching, pipeline shapes (project-development), hosted sandboxes and remote runtimes (hosted-agents), orchestrator KV compressed sharing (latent-briefing), and tool design exposed by various Agents (tool-design). When selecting topologies, responsibilities should not be mixed.

Core Functions

When to Enable

The official recommendation is to activate this Skill in the following situations:

  • Single Agent context limits constrain task complexity
  • Tasks can be naturally decomposed into parallelizable sub-tasks
  • Different sub-tasks require different tool sets or system prompts
  • The system needs to handle multiple domains simultaneously
  • Agent capabilities need to be scaled beyond a single context
  • Designing production-grade Agent systems with multiple specialized components

Three Dominant Architectural Patterns

Selection should be based on coordination requirements, not organizational metaphors:

Pattern Applicable Scenarios
Supervisor / Orchestrator Tasks can be clearly decomposed; cross-domain coordination or human oversight is required
Peer-to-Peer / Swarm Flexible exploration is needed; rigid planning is harmful; requirements emerge dynamically
Hierarchical Large-scale projects requiring layered abstraction for strategy, planning, and execution, where context structures differ at each layer

The design should revolve around: explicit coordination protocols, consensus mechanisms that suppress sycophancy, and failure handling to prevent cascading error propagation.

Why Multi-Agent is Needed (Argumentation from the Source Material)

Context Bottleneck: When a single window is filled with history, retrieved documents, and tool outputs, three types of degradation signals can be observed: lost-in-the-middle (weakened attention to the middle segment), attention scarcity (too many competing items), and context pollution (irrelevant content crowding out useful information). By dividing labor across multiple windows and aggregating results at the coordination layer, the burden is not placed on a single context.

Token Economics: The material emphasizes that multi-Agent systems often consume significantly more tokens than single-Agent conversations, providing a relative magnitude illustration (not an exact billing formula):

Architecture Token Multiplier Use Case
Single agent chat Baseline Simple queries
Single agent with tools Higher than baseline Tool-using tasks
Multi-agent system Much higher than baseline Complex research/coordination

The material also points out that in evaluation research, token usage, tool calls, and model selection often dominate performance variance. Measurements should be taken against a single-Agent baseline rather than defaulting to “more Agents are better.” Model upgrades are sometimes more effective than simply doubling the token budget; architecture and model selection should be complementary.

Parallelism and Specialization: Parallelizable sub-tasks are assigned to specialized Agents with fresh contexts. Wall-clock time approaches the longest sub-task rather than the sum of all steps. The coordinator can route requests to specialized instances carrying only the prompts, tools, and context necessary for that specific sub-task, avoiding the accumulation of all configurations in a general-purpose Agent’s context.

Pattern 1: Supervisor / Orchestrator

A central Agent maintains global state and trajectory, decomposes user goals, routes them to workers, and aggregates the output:

User Query -> Supervisor -> [Specialist, Specialist, Specialist] -> Aggregation -> Final Output

Trade-offs: Controllable process, facilitates human-in-the-loop; however, the supervisor’s context easily becomes a bottleneck, supervisor failure affects workers, and the “telephone game” exists—where the supervisor paraphrases sub-Agent responses, losing details. The material notes that in LangGraph-style benchmarks, supervisor architectures can be significantly weaker than optimized versions when unoptimized (around the 50% magnitude, subject to the official cited benchmark statements).

Mitigating the Telephone Game: Implement forward_message to allow sub-Agents to hand complete answers directly to the user when appropriate, skipping supervisor secondary synthesis. Official example:

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}

If sub-Agents can respond directly to the user, the material leans towards considering a swarm when feasible to eliminate translation errors.

Pattern 2: Peer-to-Peer / Swarm

Removes central control; Agents communicate directly according to predetermined protocols. Control is transferred to another Agent via explicit handoff. Illustration (from material snippet):

def transfer_to_agent_b():
    return agent_b  # Handoff via function return

agent_a = Agent(
    name="Agent A",
    functions=[transfer_to_agent_b]
)

Trade-offs: No single point of failure, favorable for breadth scaling; however, as the number of Agents increases, coordination complexity and divergence risks rise. Additionally, the lack of central state requires stronger convergence constraints (the material continues to expand on this topic beyond the truncation point).

Pattern 3: Hierarchical

Used for large-scale decomposition with multi-layer abstraction: high layers handle strategy and planning, low layers handle execution. Each layer maintains a context structure matched to its granularity (see the complete SKILL.md in the repository for details).

Installation and Activation

This Skill is published as a generic Agent Skill (SKILL.md). The official path is:

https://github.com/muratcankoylan/Agent-Skills-for-Context-Engineering/tree/main/skills/multi-agent-patterns

The collection’s root directory states it is applicable to scenarios like building Agents from scratch, optimizing performance, debugging context issues, and designing multi-Agent architectures. How various hosts (Cursor, Codex CLI, Claude Code, etc.) register this directory as a loadable Skill is subject to the Skills documentation of the product you are using; no unified installation command or version number is provided in the retrieved material, so no configuration fields are invented here.

Activation logic follows Skill metadata: when a task involves multi-Agent topology, isolation, coordination, and parallel decision-making, simply load the corresponding description for multi-agent-patterns in your conversation or Agent configuration.

Typical Usage (Design Process)

Combining the official “When to Activate” and architecture sections, a reproducible design sequence is as follows:

  1. Determine if multi-Agent is truly needed: If the complexity can still be handled by a single context, or if the problem belongs to the task-model matching phase of project-development, do not apply this Skill’s topological suggestions yet.
  2. Identify parallelism and tool differences: Are sub-tasks independent and parallelizable? Do they require different tools or system prompts? If so, select one of the three patterns.
  3. Add degradation prevention for supervisor architectures: If using a Supervisor, evaluate whether a forward_message direct path must be retained for final answers to avoid detail loss from supervisor paraphrasing.
  4. Define handoff protocols for swarms: Use explicit transfer_to_* or equivalent mechanisms to define control transfers, avoiding ambiguity about “who speaks next.”
  5. Evaluate costs against baselines: Compare tokens, tool calls, and task completion quality against a single-Agent baseline. The material emphasizes that multi-Agent should not be assumed to be superior by default.

Applicable Scenarios and Notes

Who it suits: Developers designing or refactoring production-grade multi-component Agent systems; teams needing context partitioning in high-retrieval, multi-domain parallel, or long-trajectory tasks.

Limitations and Pitfalls:

  • Token usage and call counts are usually significantly higher than single Agent; budgeting and baseline evaluation are required.
  • Supervisor architectures require special handling for the telephone game and supervisor single-point-of-failure issues.
  • Swarms require protocols and convergence constraints; otherwise, they tend to diverge.
  • Tool lists, sandbox runtimes, KV latent sharing, etc., should be delegated to corresponding Skills to avoid mixing all infrastructure details in one conversation.

Consistent with the evolution direction of tools like Cursor and Codex, multi-Agent is becoming a common capability, but architectural patterns are reusable. This Skill provides a consensus language at the level of selection and isolation strategy, not a replacement for specific framework implementations.

Conclusion

multi-agent-patterns converges multi-Agent design into “Context Isolation + Three Coordination Patterns + Explicit Protocols and Failure Handling,” and reminds us to validate architectural choices with single-Agent baselines and token realities. For complete text, hierarchical mode details, and advanced topics following the truncation, please refer to the official repository:

https://github.com/muratcankoylan/Agent-Skills-for-Context-Engineering/tree/main/skills/multi-agent-patterns

羽毛球分组比赛记分
小程序二维码

欢迎使用《羽毛球分组比赛记分》微信小程序

Xiaoye