Skip to main content

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.

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

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

stigmergy_langgraph-0.1.1.tar.gz (5.2 kB view details)

Uploaded Source

Built Distribution

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

stigmergy_langgraph-0.1.1-py3-none-any.whl (5.2 kB view details)

Uploaded Python 3

File details

Details for the file stigmergy_langgraph-0.1.1.tar.gz.

File metadata

  • Download URL: stigmergy_langgraph-0.1.1.tar.gz
  • Upload date:
  • Size: 5.2 kB
  • Tags: Source
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/6.2.0 CPython/3.11.14

File hashes

Hashes for stigmergy_langgraph-0.1.1.tar.gz
Algorithm Hash digest
SHA256 93bace3c8cb390618a206b2bfdd14766412ff6ff3da8500ef85d4dec135c7688
MD5 d8a5e5518a09871179b7bed2306ea92f
BLAKE2b-256 31b67a43e997a964ff22c432e1af3aea61416fe2b7b062ec84e35cda2621d603

See more details on using hashes here.

File details

Details for the file stigmergy_langgraph-0.1.1-py3-none-any.whl.

File metadata

File hashes

Hashes for stigmergy_langgraph-0.1.1-py3-none-any.whl
Algorithm Hash digest
SHA256 3c25846b871109c718b50a3ea763b14ab2f0dbca1ec70b97ba567f2d1dc16669
MD5 d8c03febd3f2902655ed982047eea2af
BLAKE2b-256 3f09dd9ea88c614da687897e6a5f047442d1aab66bb41f46839f54fac94c63b0

See more details on using hashes here.

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