Skip to content

feat: add 12 additional swarm patterns#442

Merged
khaliqgant merged 5 commits intomainfrom
feature/additional-swarm-patterns
Feb 19, 2026
Merged

feat: add 12 additional swarm patterns#442
khaliqgant merged 5 commits intomainfrom
feature/additional-swarm-patterns

Conversation

@khaliqgant
Copy link
Copy Markdown
Member

@khaliqgant khaliqgant commented Feb 18, 2026

Summary

Adds 12 new orchestration patterns to expand the workflow capabilities:

Data Processing:

  • map-reduce - Split work into chunks, process in parallel, aggregate results
  • scatter-gather - Fan out requests to workers, collect and synthesize responses

Supervision & Quality:

  • supervisor - Monitor agent watches workers, restarts on failure
  • reflection - Agent produces output, critic reviews and provides feedback
  • verifier - Producer agents submit work to verifier agents for validation

Adversarial & Validation:

  • red-team - Attacker agents probe weaknesses, defender agents respond
  • auction - Auctioneer broadcasts tasks, agents bid based on capability

Resilience:

  • escalation - Start with fast/cheap agents, escalate to more capable on failure
  • saga - Distributed transactions with compensating actions
  • circuit-breaker - Primary agent with fallback chain, fail fast and recover

Collaborative:

  • blackboard - Shared workspace where agents contribute incrementally
  • swarm - Emergent behavior from simple agent rules (neighbor communication)

Changes

  • types.ts - Added 12 new SwarmPattern union members
  • coordinator.ts - Implemented topology resolution and auto-selection heuristics
  • schema.json - Added patterns to JSON Schema enum
  • types.py - Added patterns to Python SDK
  • README.md - Documented patterns organized by category
  • swarm-coordinator.test.ts - Added topology tests for all new patterns

Test plan

  • CI passes (TypeScript compilation, tests)
  • Verify each pattern's topology is correctly built
  • Verify auto-selection heuristics work for relevant agent role configurations

🤖 Generated with Claude Code


Open with Devin

Adds the following new orchestration patterns:

Data Processing:
- map-reduce: Split work into chunks, process in parallel, aggregate
- scatter-gather: Fan out requests, collect and synthesize responses

Supervision & Quality:
- supervisor: Monitor agent monitors workers, handles failures
- reflection: Agent produces output, critic reviews for iteration
- verifier: Producer agents submit work for validation

Adversarial & Validation:
- red-team: Attacker/defender adversarial testing
- auction: Auctioneer broadcasts tasks, agents bid

Resilience:
- escalation: Tiered agents, escalate on failure
- saga: Distributed transactions with compensating actions
- circuit-breaker: Primary with fallback chain

Collaborative:
- blackboard: Shared workspace for incremental contribution
- swarm: Emergent behavior with neighbor communication

Updates:
- types.ts: Added 12 new SwarmPattern union members
- coordinator.ts: Implemented topology resolution for each pattern
- coordinator.ts: Added auto-selection heuristics for new patterns
- schema.json: Added patterns to enum
- types.py: Added patterns to Python SDK
- README.md: Documented patterns by category
- swarm-coordinator.test.ts: Added topology tests for all new patterns

Co-Authored-By: Claude Opus 4.5 <noreply@anthropic.com>
devin-ai-integration[bot]

This comment was marked as resolved.

Fixes all issues from fresh eyes review:

1. Added missing auto-selection heuristics for:
   - scatter-gather (uses fan-out topology, no specific heuristic needed)
   - auction (auctioneer role)
   - escalation (tier-* roles)
   - saga (saga-orchestrator, compensate-handler roles)
   - circuit-breaker (fallback, backup, primary roles)
   - blackboard (blackboard, shared-workspace roles)
   - swarm (hive-mind, swarm-agent roles)

2. Reordered heuristics to prevent shadowing:
   - Specific role patterns checked before generic hub patterns
   - Organized by priority: dependency → specific roles → generic → structural

3. Made reflection heuristic stricter:
   - Now requires 'critic' role specifically
   - 'reviewer' role no longer triggers reflection (too common)

4. Added edge case tests:
   - map-reduce with no reducers
   - verifier with no verifiers
   - escalation with no tier roles
   - reflection with no critic
   - swarm with hive-mind
   - red-team with multiple attackers/defenders

5. Fixed swarm efficiency:
   - Hoisted hiveMind lookup outside loop
   - Added hub property for hive-mind agent

6. Added auto-selection documentation:
   - README now documents required roles for each pattern
   - Includes priority order explanation

Co-Authored-By: Claude Opus 4.5 <noreply@anthropic.com>
devin-ai-integration[bot]

This comment was marked as resolved.

- Saga: Look for 'saga-orchestrator' role before falling back to pickHub()
  to match how other patterns handle their specific roles
- Swarm: Prevent duplicate hive-mind entries when it's also adjacent by index
  by adding !neighbors.includes(hiveMind) check

Co-Authored-By: Claude Opus 4.5 <noreply@anthropic.com>
devin-ai-integration[bot]

This comment was marked as resolved.

- map-reduce: Filter coordinator from mappers when setting edges and skip
  coordinator in the mapper loop to prevent self-edges and edge overwrites
  when the hub agent is also a mapper
- README: Reorder auto-selection table to match actual code priority
  (dag/consensus checked first, not last)

Co-Authored-By: Claude Opus 4.5 <noreply@anthropic.com>
devin-ai-integration[bot]

This comment was marked as resolved.

When escalation pattern is used with a mix of tiered and non-tiered agents,
non-tiered agents were left without edge entries, causing edges.get() to
return undefined instead of an empty array. This could cause runtime errors
in downstream consumers.

Co-Authored-By: Claude Opus 4.5 <noreply@anthropic.com>
@khaliqgant khaliqgant merged commit 4ede7fb into main Feb 19, 2026
38 of 39 checks passed
@khaliqgant khaliqgant deleted the feature/additional-swarm-patterns branch February 19, 2026 08:00
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant