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.0.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.0-py3-none-any.whl (5.3 kB view details)

Uploaded Python 3

File details

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

File metadata

  • Download URL: stigmergy_langgraph-0.1.0.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.0.tar.gz
Algorithm Hash digest
SHA256 30137c451c7db7e7bc32e641d6f8217de32c5c7e45a893f77b509646bf34383f
MD5 1a29209588ddba54a89c2db09d3cbfe6
BLAKE2b-256 b828a27fc6fa26df2276fa0c43ab25a84ba09a1c4d44d4c0ac53652b819e8136

See more details on using hashes here.

File details

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

File metadata

File hashes

Hashes for stigmergy_langgraph-0.1.0-py3-none-any.whl
Algorithm Hash digest
SHA256 f693be2f31839ad16d21a664480138808abc62c521ecd2ced172478a0d3458a9
MD5 a6682def2eff257ca3feec5615e325d1
BLAKE2b-256 306c0027ca4b48a898b706e830facf1447e0489f3d7e087794b898bd0fd4e15f

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