DonggangChen

multi_agent_patterns

2
2
# Install this skill:
npx skills add DonggangChen/antigravity-agentic-skills --skill "multi_agent_patterns"

Install specific skill from multi-skill repository

# Description

Multi-agent architecture design, orchestration patterns, and agent collaboration guide.

# SKILL.md


name: multi_agent_patterns
router_kit: AIKit
description: Multi-agent architecture design, orchestration patterns, and agent collaboration guide.
metadata:
skillport:
category: architecture
tags: [agents, algorithms, artificial intelligence, automation, chatbots, cognitive services, deep learning, embeddings, frameworks, generative ai, inference, large language models, llm, machine learning, model fine-tuning, multi agent patterns, natural language processing, neural networks, nlp, openai, prompt engineering, rag, retrieval augmented generation, tools, vector databases, workflow automation] - patterns


πŸ€– Multi-Agent Patterns

Multi-agent architecture and orchestration guide.


πŸ“‹ When to use Multi-Agent?

Situation Single Agent Multi-Agent
Simple task βœ… ❌
Context limit exceeded ❌ βœ…
Different expertises ❌ βœ…
Parallel processing ❌ βœ…
Complex workflow ❌ βœ…

πŸ—οΈ Architecture Patterns

1. Orchestrator Pattern

        β”Œβ”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”
        β”‚ Orchestratorβ”‚
        β””β”€β”€β”€β”€β”€β”€β”¬β”€β”€β”€β”€β”€β”€β”˜
               β”‚
    β”Œβ”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”Όβ”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”
    β–Ό          β–Ό          β–Ό
β”Œβ”€β”€β”€β”€β”€β”€β”€β”  β”Œβ”€β”€β”€β”€β”€β”€β”€β”  β”Œβ”€β”€β”€β”€β”€β”€β”€β”
β”‚Agent 1β”‚  β”‚Agent 2β”‚  β”‚Agent 3β”‚
β”‚Coder  β”‚  β”‚Tester β”‚  β”‚Reviewerβ”‚
β””β”€β”€β”€β”€β”€β”€β”€β”˜  β””β”€β”€β”€β”€β”€β”€β”€β”˜  β””β”€β”€β”€β”€β”€β”€β”€β”˜

Usage: Complex workflows, task delegation

2. Pipeline Pattern

β”Œβ”€β”€β”€β”€β”€β”€β”€β”    β”Œβ”€β”€β”€β”€β”€β”€β”€β”    β”Œβ”€β”€β”€β”€β”€β”€β”€β”
β”‚ Parse β”‚ -> β”‚Processβ”‚ -> β”‚ Outputβ”‚
β””β”€β”€β”€β”€β”€β”€β”€β”˜    β””β”€β”€β”€β”€β”€β”€β”€β”˜    β””β”€β”€β”€β”€β”€β”€β”€β”˜

Usage: Sequential processing, data transformation

3. Specialist Pattern

        β”Œβ”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”
        β”‚   Router    β”‚
        β””β”€β”€β”€β”€β”€β”€β”¬β”€β”€β”€β”€β”€β”€β”˜
               β”‚ (task type)
    β”Œβ”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”Όβ”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”
    β–Ό          β–Ό          β–Ό
β”Œβ”€β”€β”€β”€β”€β”€β”€β”  β”Œβ”€β”€β”€β”€β”€β”€β”€β”  β”Œβ”€β”€β”€β”€β”€β”€β”€β”
β”‚  SQL  β”‚  β”‚  API  β”‚  β”‚  UI   β”‚
β”‚Expert β”‚  β”‚Expert β”‚  β”‚Expert β”‚
β””β”€β”€β”€β”€β”€β”€β”€β”˜  β””β”€β”€β”€β”€β”€β”€β”€β”˜  β””β”€β”€β”€β”€β”€β”€β”€β”˜

Usage: Domain-specific expertise

4. Debate Pattern

β”Œβ”€β”€β”€β”€β”€β”€β”€β”         β”Œβ”€β”€β”€β”€β”€β”€β”€β”
β”‚Agent Aβ”‚ <-----> β”‚Agent Bβ”‚
β”‚(Pro)  β”‚ debate  β”‚(Con)  β”‚
β””β”€β”€β”€β”€β”€β”€β”€β”˜         β””β”€β”€β”€β”€β”€β”€β”€β”˜
         \       /
          \     /
           \   /
        β”Œβ”€β”€β”€β”€β”€β”€β”€β”
        β”‚ Judge β”‚
        β””β”€β”€β”€β”€β”€β”€β”€β”˜

Usage: Decision making, option evaluation


πŸ”§ Implementation

Agent Definition

class Agent:
    def __init__(self, name, role, skills):
        self.name = name
        self.role = role
        self.skills = skills

    def process(self, task):
        # Agent logic
        pass

Orchestrator

class Orchestrator:
    def __init__(self, agents):
        self.agents = agents

    def route(self, task):
        # Determine which agent handles task
        agent = self.select_agent(task)
        return agent.process(task)

    def select_agent(self, task):
        # Routing logic
        pass

πŸ“Š Communication Patterns

Pattern Description
Direct Agent β†’ Agent
Broadcast Orchestrator β†’ All Agents
Pub/Sub Topic-based messaging
Request/Response Sync communication
Event-driven Async, event queue

⚠️ Best Practices

  1. Clear Roles: Each agent must have a clear task
  2. Minimal Overlap: No task overlap
  3. Fallback: Plan B if Agent fails
  4. Monitoring: Monitor each agent
  5. Context Sharing: Share necessary information

Multi-Agent Patterns v1.1 - Enhanced

πŸ”„ Workflow

Source: AutoGen Documentation & CrewAI

Phase 1: Role Definition

  • [ ] Persona Design: Write a clear "System Message" for each agent (What represent, what to do, what not to do).
  • [ ] Tools: Give the agent only the tools it needs (Reduces LLM hallucination risk).
  • [ ] Hierarchy: Who reports to whom? (Manager -> Worker) or (Peer-to-Peer)?

Phase 2: Interaction Pattern

  • [ ] Chat Topology: Choose between "Group Chat" (Everyone talks) vs "Nested Chats" (Subgroups).
  • [ ] Handoffs: Define clear trigger phrases for task handoffs.
  • [ ] Human-in-the-loop: Add "User Proxy Agent" or approval mechanism for critical decisions.

Phase 3: Execution & Output

  • [ ] Consolidation: Assign a "Summarizer Agent" to consolidate results.
  • [ ] Validation: Add a validator to check if output matches format (JSON/Markdown).
  • [ ] Cost Control: Set Max Turns and token limits.

Checkpoints

Phase Verification
1 Do agents interrupt each other (Broken turn-taking)?
2 Is there a risk of Infinite Loop?
3 Are complex tasks correctly divided into sub-parts?

# Supported AI Coding Agents

This skill is compatible with the SKILL.md standard and works with all major AI coding agents:

Learn more about the SKILL.md standard and how to use these skills with your preferred AI coding agent.