Coordinate swarm

From pjt222/agent-almanac · View interactive version

Coordinate swarm is an AI agent skill from the GitHub repository pjt222/agent-almanac. Apply collective intelligence coordination patterns — stigmergy, local rules, and quorum sensing — to organize distributed systems, teams, or workflows without centralized control. Covers signal design, agent autonomy boundaries, emergent behavior cultivation, and feedback loop tuning. Use when desi

How to use this skill

Skill file

Coordinate Swarm

Establish coordination across distributed agents using stigmergy (indirect communication through environment modification), local interaction rules, and quorum sensing — enabling coherent collective behavior without a central controller.

When to Use

Inputs

Procedure

Step 1: Identify the Coordination Problem Class

Classify the coordination challenge to select appropriate patterns.

  1. Map the current state: who are the agents, what do they do individually, where does coordination break down?
  2. Classify the problem:
  1. Identify the failure mode of current coordination:

Got: A clear classification of the coordination problem type and the specific failure mode to address. This determines which swarm patterns to apply.

If fail: If the problem doesn't fit a single class, it may be a composite. Decompose into sub-problems and address each with the appropriate pattern. If agents are too heterogeneous for a single coordination model, consider layered coordination — homogeneous clusters coordinated via inter-cluster stigmergy.

Step 2: Design Stigmergic Signals

Create the indirect communication channels through which agents influence each other's behavior.

  1. Define the shared environment (database, message queue, file system, physical space, shared board)
  2. Design signals that agents deposit into the environment:
  1. Define signal properties:
  1. Map signals to agent behaviors:
Signal Design Template:
┌──────────────┬───────────────────┬──────────────┬────────────────────┐
│ Signal Name  │ Deposited When    │ Decay Rate   │ Agent Response     │
├──────────────┼───────────────────┼──────────────┼────────────────────┤
│ success-trail│ Task completed OK │ 50% per hour │ Follow toward      │
│ busy-marker  │ Agent starts task │ On completion│ Avoid / pick other │
│ help-signal  │ Agent stuck >5min │ 25% per hour │ Assist if nearby   │
│ danger-flag  │ Error detected    │ 10% per hour │ Retreat & report   │
└──────────────┴───────────────────┴──────────────┴────────────────────┘

Got: A signal table mapping environmental markers to agent deposit conditions, decay rates, and response behaviors. Signals should be simple, composable, and independently meaningful.

If fail: If signal design feels overly complex, reduce to two signals: one positive (success trail) and one negative (danger flag). Most coordination problems can be bootstrapped with attract/repel dynamics. Add nuance only after the basic system is functioning.

Step 3: Define Local Interaction Rules

Specify the simple rules each agent follows, using only local information (their own state + nearby signals).

  1. Define the agent's perception radius (what can it sense?)
  2. Write 3-7 local rules in priority order:
  1. Each rule must be:
  1. Test rules mentally: if every agent follows these rules, does the desired collective behavior emerge?

Got: A prioritized rule set that each agent executes independently. When applied across the swarm, these local rules produce the target collective behavior (foraging, construction, defense, etc.).

If fail: If mental simulation doesn't produce the desired emergent behavior, the rules likely need a feedback loop — agents must be able to observe the consequences of their collective actions. Add a signal that represents the collective state (e.g., "task completion rate") and a rule that adjusts behavior based on it.

Step 4: Calibrate Quorum Sensing

Set thresholds that trigger collective state changes when enough agents agree.

  1. Identify decisions that require collective agreement (not just individual response):
  1. For each collective decision, define:
  1. Implement quorum as signal accumulation:

Got: Quorum thresholds that allow the swarm to make collective decisions without a leader. The hysteresis gap prevents rapid oscillation between states.

If fail: If the swarm oscillates between states, widen the hysteresis gap (e.g., activate at 70%, deactivate at 30%). If the swarm never reaches quorum, lower the threshold or increase the sensing window. If decisions are too slow, reduce the sensing window — but beware of premature consensus.

Step 5: Test and Tune Emergent Behavior

Validate that local rules produce the desired collective behavior, then tune parameters.

  1. Run a simulation or pilot with a small number of agents (5-10)
  2. Observe:
  1. Tune parameters:
  1. Stress test:

Got: A tuned parameter set where the swarm self-organizes toward the target behavior, recovers from perturbations, and scales gracefully.

If fail: If the swarm fails stress tests, the signal design is likely too tightly coupled. Simplify: reduce to fewer signals, increase decay rates (fresher information), and ensure agents have a robust default behavior when no signals are present. A swarm that does something reasonable with zero signals is more resilient than one that depends on signal availability.

Validation

Pitfalls

Related Skills

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.