Skip to main content

Multi-agent coordination through stigmergy - agents coordinate via environmental traces, not explicit messaging

Project description

Anthills ๐Ÿœ

Multi-agent coordination without explicit messaging.

Inspired by ant colonies, where simple agents leave chemical trails (pheromones) that other agents sense and respond to โ€” creating emergent swarm intelligence.

The Idea

Most multi-agent frameworks require explicit coordination: Agent A tells Agent B what to do. Message passing. Explicit protocols.

Anthills does the opposite. Agents:

  1. Perceive the shared environment (pheromone board)
  2. Think independently using Claude
  3. Act on the environment (call tools)
  4. Leave traces for other agents to sense

No explicit messaging. No central coordinator. Just local behavior creating emergent coordination.

Agent A finds research โ†’ leaves trace
Agent B senses trace โ†’ builds on it
Agent C senses both โ†’ generates code
All coordinating like an ant colony.

Why This Matters

  • Scalable: Add more agents, they self-organize
  • Resilient: Agents fail independently, others adapt
  • Simple: Each agent is dumb; intelligence emerges
  • Transparent: You can see what agents are sensing/doing

Quick Start

pip install -r requirements.txt
export ANTHROPIC_API_KEY="sk-..."
python examples/research_agents.py

How It Works

The Pheromone Board

Shared memory where agents leave traces:

pheromone.deposit("research", {
    "topic": "LLM reasoning",
    "findings": ["extended thinking works", "costs are high"],
    "source": "agent_research"
})

Agent Loop

agent = Agent(name="researcher", tools=[web_search, read_file])
while not done:
    traces = pheromone.read("research")  # Perceive
    next_action = agent.think(traces)     # Think
    result = agent.act(next_action)       # Act
    pheromone.deposit("research", result) # Leave trace

Example: Two Agents, No Explicit Messaging

Agent A (Researcher):

  • Reads pheromone board
  • Thinks: "I should research X"
  • Acts: calls web_search
  • Deposits: "Found 3 papers"

Agent B (Synthesizer):

  • Reads pheromone board
  • Senses A's deposit: "3 papers found"
  • Thinks: "I should synthesize these"
  • Acts: calls code_exec to process
  • Deposits: "Synthesis complete"

No message passing. No protocol. Just traces in the environment.

Examples

  • research_agents.py โ€” Two agents researching a topic together
  • t1d_simulation.py โ€” Type 1 Diabetes pathophysiology model (see below)
  • debug_agents.py โ€” Three agents debugging code collaboratively
  • build_agents.py โ€” Agents building a feature end-to-end

Real-World Application: Type 1 Diabetes Simulation

[NEW] Anthills models the multi-agent dynamics of Type 1 Diabetes.

The Biology

T1D emerges from anthills-like coordination failure:

BetaCells โ†” ImmuneSystem (no direct messaging)
     โ†“ (sense pheromones)
  Glucose, Insulin, Cytokines, Antigens
     โ†‘
  Local responses โ†’ Emergent autoimmunity
  1. Genetic predisposition โ€” HLA genes increase autoimmune risk
  2. Environmental trigger โ€” Viral infection breaks tolerance
  3. Beta cell autoimmunity โ€” Immune attacks insulin-producing cells (no central controller)
  4. Positive feedback โ€” Cell death โ†’ more inflammation โ†’ more attack
  5. Clinical T1D โ€” ~80% beta cell loss โ†’ insulin-dependent diabetes

Run the Simulation

python examples/t1d_simulation.py

This runs two scenarios:

  • High-risk: Genetic predisposition + viral trigger โ†’ Fast T1D onset
  • Low-risk: Genetic resistance, no trigger โ†’ Slower/no progression

The output shows day-by-day progression of glucose, insulin, inflammation, and beta cell count.

Project Structure

anthills/
โ”œโ”€โ”€ README.md
โ”œโ”€โ”€ requirements.txt
โ”œโ”€โ”€ anthills/
โ”‚   โ”œโ”€โ”€ __init__.py
โ”‚   โ”œโ”€โ”€ agent.py           # Base Agent class
โ”‚   โ”œโ”€โ”€ pheromone.py       # Shared environment
โ”‚   โ”œโ”€โ”€ tools.py           # Tool definitions
โ”‚   โ””โ”€โ”€ llm.py             # Claude integration
โ”œโ”€โ”€ examples/
โ”‚   โ”œโ”€โ”€ research_agents.py
โ”‚   โ”œโ”€โ”€ debug_agents.py
โ”‚   โ””โ”€โ”€ build_agents.py
โ””โ”€โ”€ tests/
    โ””โ”€โ”€ test_agent.py

Philosophy

This is not a general-purpose agent framework. It's a specific take: agents coordinating through environmental traces, not explicit messaging.

Use it when you want:

  • Multiple agents collaborating on complex tasks
  • Self-organization without central orchestration
  • Transparent, auditable agent behavior
  • Resilience to individual agent failures

Roadmap

  • Multi-pheromone types (strength, TTL, priority)
  • Agent memory (persistent traces)
  • Visualization (see the pheromone board in real-time)
  • Streaming agent responses
  • More tools (code execution, file I/O, external APIs)

Building This in Public

This project is being built on Twitter: @braz_builds

Daily updates on architecture, insights, and use cases.


Built with Claude + Python + Anthills vibes ๐Ÿœ

Project details


Download files

Download the file for your platform. If you're not sure which to choose, learn more about installing packages.

Source Distribution

anthills-0.1.0.tar.gz (18.9 kB view details)

Uploaded Source

Built Distribution

If you're not sure about the file name format, learn more about wheel file names.

anthills-0.1.0-py3-none-any.whl (14.6 kB view details)

Uploaded Python 3

File details

Details for the file anthills-0.1.0.tar.gz.

File metadata

  • Download URL: anthills-0.1.0.tar.gz
  • Upload date:
  • Size: 18.9 kB
  • Tags: Source
  • Uploaded using Trusted Publishing? Yes
  • Uploaded via: twine/6.1.0 CPython/3.13.7

File hashes

Hashes for anthills-0.1.0.tar.gz
Algorithm Hash digest
SHA256 2d29f1d3e19f2a1873c114c6b75711d2f6cee53c2c573e526b1e2d98179bf7ba
MD5 71c54c29c0aec1c1bd8bc5d44fd144e1
BLAKE2b-256 9f5b43dd0847c0f6e84ff22e9ebc2c2f4356b81378634bd90524b7e17b13c4e6

See more details on using hashes here.

Provenance

The following attestation bundles were made for anthills-0.1.0.tar.gz:

Publisher: publish.yml on t1dm-ai/anthills

Attestations: Values shown here reflect the state when the release was signed and may no longer be current.

File details

Details for the file anthills-0.1.0-py3-none-any.whl.

File metadata

  • Download URL: anthills-0.1.0-py3-none-any.whl
  • Upload date:
  • Size: 14.6 kB
  • Tags: Python 3
  • Uploaded using Trusted Publishing? Yes
  • Uploaded via: twine/6.1.0 CPython/3.13.7

File hashes

Hashes for anthills-0.1.0-py3-none-any.whl
Algorithm Hash digest
SHA256 111f9aebda5c0d963613f30a55fe8f712bbac9b83759933c625b09397f61a1ee
MD5 dfbd5c4765627985d6742149b1ad355b
BLAKE2b-256 296a8a22480774e39bbcded55059e3104204f0896ec72c838a3d2ec1b2022ba2

See more details on using hashes here.

Provenance

The following attestation bundles were made for anthills-0.1.0-py3-none-any.whl:

Publisher: publish.yml on t1dm-ai/anthills

Attestations: Values shown here reflect the state when the release was signed and may no longer be current.

Supported by

AWS Cloud computing and Security Sponsor Datadog Monitoring Depot Continuous Integration Fastly CDN Google Download Analytics Pingdom Monitoring Sentry Error logging StatusPage Status page