feat: add 12 additional swarm patterns#442
Merged
khaliqgant merged 5 commits intomainfrom Feb 19, 2026
Merged
Conversation
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>
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>
- 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>
- 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>
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>
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Summary
Adds 12 new orchestration patterns to expand the workflow capabilities:
Data Processing:
map-reduce- Split work into chunks, process in parallel, aggregate resultsscatter-gather- Fan out requests to workers, collect and synthesize responsesSupervision & Quality:
supervisor- Monitor agent watches workers, restarts on failurereflection- Agent produces output, critic reviews and provides feedbackverifier- Producer agents submit work to verifier agents for validationAdversarial & Validation:
red-team- Attacker agents probe weaknesses, defender agents respondauction- Auctioneer broadcasts tasks, agents bid based on capabilityResilience:
escalation- Start with fast/cheap agents, escalate to more capable on failuresaga- Distributed transactions with compensating actionscircuit-breaker- Primary agent with fallback chain, fail fast and recoverCollaborative:
blackboard- Shared workspace where agents contribute incrementallyswarm- Emergent behavior from simple agent rules (neighbor communication)Changes
types.ts- Added 12 new SwarmPattern union memberscoordinator.ts- Implemented topology resolution and auto-selection heuristicsschema.json- Added patterns to JSON Schema enumtypes.py- Added patterns to Python SDKREADME.md- Documented patterns organized by categoryswarm-coordinator.test.ts- Added topology tests for all new patternsTest plan
🤖 Generated with Claude Code