Stigmergy pressure-field scheduling adapter for LangGraph
Project description
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:
- Deposits pressure signals for each task (intensity = priority)
- On each graph step, decays signals and evaluates pressure per agent
- Dispatches the highest-pressure agent whose task dependencies are met
- 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
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
Built Distribution
Filter files by name, interpreter, ABI, and platform.
If you're not sure about the file name format, learn more about wheel file names.
Copy a direct link to the current filters
File details
Details for the file stigmergy_langgraph-0.2.0.tar.gz.
File metadata
- Download URL: stigmergy_langgraph-0.2.0.tar.gz
- Upload date:
- Size: 5.3 kB
- Tags: Source
- Uploaded using Trusted Publishing? No
- Uploaded via: twine/6.2.0 CPython/3.11.14
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
e1d3436444b4fc03d78eee9373836da259962fe3ca32abd75184e52a687858f1
|
|
| MD5 |
c398592ea8f20cc03a1bc8cb72dc98f9
|
|
| BLAKE2b-256 |
0a6e507e8b8df885f340d32fae394ee8ea57adfddeed35ca2a1cc7cbb10ef5eb
|
File details
Details for the file stigmergy_langgraph-0.2.0-py3-none-any.whl.
File metadata
- Download URL: stigmergy_langgraph-0.2.0-py3-none-any.whl
- Upload date:
- Size: 5.4 kB
- Tags: Python 3
- Uploaded using Trusted Publishing? No
- Uploaded via: twine/6.2.0 CPython/3.11.14
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
7ed9be9c8804a07cf41bd03117ac73caf853e8bdb043d1d8063888b1e5abbc24
|
|
| MD5 |
df6952d7c1744f733f4027ebd66c5aa0
|
|
| BLAKE2b-256 |
8470d2c9cba5634511898056d2682e04614451b58874a20b3d29042e23ef5711
|