Multi agent topology

From j4flmao/agent-skills · View interactive version

Multi agent topology is an AI agent skill from the GitHub repository j4flmao/agent-skills. Use when the user asks whether to use multiple agents, supervisor-worker, agent hierarchy, pipeline of agents, handoffs or a critic/debate setup. Produces a topology diagram, role table with least-privilege tools, typed edge contracts and round caps. Not for framework runtime and checkpointing (use

How to use this skill

Skill file

Multi-Agent Topology

Purpose

A topology is the graph of who talks to whom, who decides, and what data crosses each edge. Adding agents adds latency, cost, and failure points, so the first question is whether more than one agent is needed at all. When it is, pick the simplest topology that gives each agent a narrow role, a small tool set, and a typed contract with its neighbours.

Agent Protocol

Trigger

"supervisor", "worker agents", "agent hierarchy", "agent pipeline", "handoff", "debate", "critic agent", "should this be multi-agent".

Input Context

Output Artifact

Topology diagram (Mermaid), role table, edge contracts (typed messages), termination and failure rules.

Response Format

Topology: {single|pipeline|supervisor-worker|hierarchical|handoff|debate}
Why multi-agent: {tool split | context isolation | parallelism | separation of duties}
Roles: {agent: responsibility, tools, can_write?}
Edges: {from -> to: message schema}
Termination: {condition}; max rounds={n}
Failure: {retry | reroute | escalate}

Completion Criteria

When Multiple Agents Pay Off

| Reason | Example |

|---|---|

| Tool/permission separation | Coder can write files; reviewer can only read |

| Context isolation | Research sub-agents each read many pages, return short summaries |

| Parallelism | Independent subtasks fan out and run concurrently |

| Separation of duties | Generator and independent verifier |

Poor reasons: "it mirrors a human org chart", "more agents = smarter". Multi-agent systems typically use several times more tokens than a single agent; justify the spend with measured quality gains.

Topologies

flowchart LR
  subgraph Pipeline
    A1[Extract] --> A2[Transform] --> A3[Format]
  end
  subgraph SupervisorWorker[Supervisor-worker]
    S((Supervisor)) --> W1[Worker A]
    S --> W2[Worker B]
    W1 --> S
    W2 --> S
  end
  subgraph Debate
    G[Generator] --> C{Critic}
    C -- revise --> G
    C -- accept --> J[Final]
  end

| Topology | Control | Best for | Main risk | Mitigation |

|---|---|---|---|---|

| Pipeline | Fixed order | Known stages | Error propagation | Validate between stages |

| Supervisor-worker | Central router | Dynamic delegation | Supervisor bottleneck, lossy summaries | Typed results, supervisor never executes |

| Hierarchical | Supervisors of supervisors | Very large tasks | Latency, telephone effect | Limit depth to 2 |

| Handoff (peer transfer) | Current agent passes control | Conversational triage | Ping-pong loops | Handoff count cap |

| Debate / critic | Generator + critic(s) | Quality-critical outputs | Sycophantic agreement, cost | Ground critic in tests/evidence; round cap |

| Parallel + aggregator | Fan-out/fan-in | Independent subtasks, voting | Inconsistent outputs | Deterministic merge rules |

Edge Contracts

Pass structured state, not free-form chat logs:

from __future__ import annotations

from typing import Literal

from pydantic import BaseModel, Field


class WorkOrder(BaseModel):
    task_id: str
    objective: str
    inputs: dict[str, str]
    constraints: list[str] = Field(default_factory=list)
    deadline_s: int = 300


class WorkResult(BaseModel):
    task_id: str
    status: Literal["done", "failed", "needs_human"]
    summary: str = Field(max_length=2000)
    artifacts: list[str] = Field(default_factory=list)   # file paths / ids, not blobs
    evidence: list[str] = Field(default_factory=list)    # test output, sources

Validate every message against its schema at the boundary; a malformed result is a failed task, not something to "interpret".

Supervisor Rules

  1. The supervisor routes, aggregates, and decides termination; it does not do the domain work.
  2. Workers get the minimum context for their task (objective, inputs, constraints), not the whole conversation.
  3. Results return as summaries plus artifact references, keeping the supervisor's context small.
  4. A global budget (steps, tokens, time) is owned by the supervisor and enforced on every dispatch.

Debate That Works

Anti-Patterns

Checklist

References

Use this skill with your AI agent: Open on Skill Issue to copy, download, or add to your library. Works with Claude, ChatGPT, Gemini, Cursor, Windsurf and more.