Skip to main content

stigmergy-langgraph

Drop-in replacement for LangGraph's conditional edge routing. Register agents and tasks with dependencies, and stigmergy figures out execution order using pressure signals. No more router functions that grow into unmanageable if/else trees.

9.5x faster than native LangGraph at 30 agents. LangGraph's StateGraph processes a fixed batch of nodes per step -- adding more agents doesn't make it faster. Stigmergy dispatches all available agents every tick, so throughput scales linearly with your agent pool.

Works with your existing LangGraph node functions. 8 lines to integrate.

Install

pip install stigmergy-langgraph

Usage

from stigmergy_langgraph import StigmergyRouter, PressureState

# Define your agent node functions (standard LangGraph nodes)
def writer_node(state):
    return {"output": "Draft written"}

def reviewer_node(state):
    return {"output": "Review complete"}

# Create the stigmergy router
router = StigmergyRouter(wake_threshold=0.4, decay_half_life=300)
router.register_agent("writer", writer_node)
router.register_agent("reviewer", reviewer_node)

# Add tasks with dependencies
router.add_task("draft", agent="writer", priority=0.8)
router.add_task("review", agent="reviewer", priority=0.6, deps=["draft"])

# Build and run
graph = router.build_graph(PressureState)
result = graph.invoke({
    "messages": [],
    "completed_tasks": [],
    "pending_tasks": ["draft", "review"],
    "outputs": {},
})

How It Works

Instead of hardcoded conditional edges, the StigmergyRouter:

  1. Deposits pressure signals for each task (intensity = priority)
  2. On each graph step, decays signals and evaluates pressure per agent
  3. Dispatches the highest-pressure agent whose task dependencies are met
  4. Deposits completion signals that enable downstream tasks

When to Use

Use this instead of manual conditional edges when:

  • You have 3+ agents with complex dependency graphs
  • Tasks arrive dynamically (can't hardcode the routing)
  • You want automatic parallelization of independent tasks

Stick with native LangGraph routing for simple 2-agent pipelines.

License

MIT

Metadata

Release files for stigmergy-langgraph 0.2.0

For a detailed explanation of source distributions (sdists) and built distributions (wheels), please see the package formats documentation.

Source distribution (sdist)

Source distribution for stigmergy-langgraph 0.2.0
File Size Uploaded
stigmergy_langgraph-0.2.0.tar.gz 5.3 kB Details

Built distribution (wheel)

Table of built distributions (wheels) for stigmergy-langgraph 0.2.0
File Interpreter ABI Platform
stigmergy_langgraph-0.2.0-py3-none-any.whl Python 3 none any Details

Total release size: 10.6 kB

Release files / stigmergy_langgraph-0.2.0.tar.gz

Download URL stigmergy_langgraph-0.2.0.tar.gz
Size 5.3 kB
Tags Source
SHA-256 checksum
How to use checksums
e1d3436444b4fc03d78eee9373836da259962fe3ca32abd75184e52a687858f1
BLAKE2b-256 checksum
How to use checksums
0a6e507e8b8df885f340d32fae394ee8ea57adfddeed35ca2a1cc7cbb10ef5eb
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
No
Uploaded via twine/6.2.0 CPython/3.11.14

Release files / stigmergy_langgraph-0.2.0-py3-none-any.whl

Download URL stigmergy_langgraph-0.2.0-py3-none-any.whl
Size 5.4 kB
Tags Python 3
SHA-256 checksum
How to use checksums
7ed9be9c8804a07cf41bd03117ac73caf853e8bdb043d1d8063888b1e5abbc24
BLAKE2b-256 checksum
How to use checksums
8470d2c9cba5634511898056d2682e04614451b58874a20b3d29042e23ef5711
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
No
Uploaded via twine/6.2.0 CPython/3.11.14

Release history Release notifications | RSS feed

This release

0.2.0 This release

2 release files

0.1.2

2 release files

0.1.1

2 release files

0.1.0

2 release files

Anthropic, PBC Visionary sponsor Bloomberg Visionary sponsor Hudson River Trading Visionary sponsor Meta Visionary sponsor NVIDIA Visionary sponsor Microsoft Sustainability sponsor Depot Continuous Integration AWS Cloud computing and Security Sponsor Datadog Monitoring Fastly CDN Google Download Analytics Sentry Error logging StatusPage Status page