Skill Index

relay/

adding-swarm-patterns

community[skill]

Use when adding new multi-agent coordination patterns to agent-relay - provides checklist for types, schema, templates, and docs updates

$/plugin install relay

details

Adding Swarm Patterns

Overview

Add new multi-agent coordination patterns to agent-relay by updating four locations: TypeScript types, JSON schema, YAML template, and markdown docs.

When to Use

  • Adding a new swarm pattern (e.g., "competitive", "auction")
  • Extending coordination capabilities for multi-agent workflows
  • Responding to user requests for new orchestration strategies

Quick Reference

FileLocationWhat to Add
types.tspackages/broker-sdk/src/workflows/types.tsAdd to SwarmPattern union type
schema.jsonpackages/broker-sdk/src/workflows/schema.jsonAdd to SwarmPattern.enum array
template.yamlpackages/broker-sdk/src/workflows/builtin-templates/Create {pattern}.yaml
pattern.mddocs/workflows/patterns/Create {pattern}.md
template.mddocs/workflows/templates/Create {pattern}.md
README.mddocs/workflows/README.mdAdd to patterns and templates tables

Implementation Checklist

1. Update TypeScript Types

// packages/broker-sdk/src/workflows/types.ts
export type SwarmPattern =
  | "fan-out"
  | "pipeline"
  // ... existing patterns ...
  | "your-new-pattern";  // Add here

2. Update JSON Schema

// packages/broker-sdk/src/workflows/schema.json
"SwarmPattern": {
  "type": "string",
  "enum": [
    "fan-out",
    "pipeline",
    // ... existing patterns ...
    "your-new-pattern"
  ]
}

3. Create YAML Template

# packages/broker-sdk/src/workflows/builtin-templates/{pattern}.yaml
version: "1.0"
name: pattern-name
description: "One-line description"
swarm:
  pattern: pattern-name
  maxConcurrency: N
  timeoutMs: N
  channel: swarm-pattern-name
agents:
  - name: lead
    cli: claude
    role: "Role description"
  # ... more agents
workflows:
  - name: workflow-name
    steps:
      - name: step-name
        agent: agent-name
        task: |
          Task description with {{task}} placeholder
        verification:
          type: output_contains
          value: STEP_COMPLETE
coordination:
  barriers:
    - name: barrier-name
      waitFor: [step1, step2]
state:
  backend: memory
  namespace: pattern-name
errorHandling:
  strategy: fail-fast

4. Create Pattern Documentation

# docs/workflows/patterns/{pattern}.md

# Pattern Name

One-sentence description.

## When to Use
- Use case 1
- Use case 2

## Structure
[ASCII diagram showing agent/step flow]

## Configuration
[YAML snippet]

## Best Practices
- Practice 1
- Practice 2

5. Create Template Documentation

# docs/workflows/templates/{pattern}.md

# Pattern Template

**Pattern:** name | **Timeout:** N minutes | **Channel:** swarm-name

## Overview
What this template does.

## Agents
| Agent | CLI | Role |
|-------|-----|------|

## Workflow Steps
1. **step** (agent) — Description

## Usage
[CLI and TypeScript examples]

## Verification Markers
- `MARKER` — Description

6. Update README

Add to both tables in docs/workflows/README.md:

  • Patterns table: | [pattern](patterns/pattern.md) | Description | Best For |
  • Templates table: | [pattern](templates/pattern.md) | pattern | Description |

Common Mistakes

MistakeFix
Forgetting schema.jsonValidation will fail if schema doesn't include the pattern
Inconsistent namingUse same name in types, schema, template filename, and docs
Missing verification markersEach step should have output_contains verification
Wrong doc linksUse relative paths: patterns/name.md not /docs/workflows/patterns/name.md

Pattern Design Guidelines

Good patterns have:

  • Clear coordination model (who talks to whom)
  • Defined failure handling (what happens if one agent fails)
  • Appropriate concurrency (parallel vs sequential)
  • Barrier synchronization for convergence points

Pattern categories:

  • Parallel: fan-out, competitive, scatter-gather
  • Sequential: pipeline, handoff, cascade
  • Hierarchical: hub-spoke, hierarchical, supervisor
  • Consensus: consensus, debate, auction
  • Graph: dag, mesh

technical

github
AgentWorkforce/relay
stars
628
license
Apache-2.0
contributors
14
last commit
2026-04-21T02:25:55Z
file
skills/adding-swarm-patterns/SKILL.md

related