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

Uploaded Python 3

File details

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

File metadata

  • Download URL: stigmergy_langgraph-0.1.2.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.2.tar.gz
Algorithm Hash digest
SHA256 eb38b9c297d3e5f916377fc968b1adb9d65f5f1d016ae0a3191a16a799df50a5
MD5 1d4cf419f5561240df84d244be930486
BLAKE2b-256 a3b5d08834f7e11da8089187e986d0512d09e69431adb1c302fea6dcafb579b4

See more details on using hashes here.

File details

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

File metadata

File hashes

Hashes for stigmergy_langgraph-0.1.2-py3-none-any.whl
Algorithm Hash digest
SHA256 6a06ebe0736135c617d002f925c39636082eeba347549126f96a26b4ebecc585
MD5 532a310f45e94c98394798bf3c707bc5
BLAKE2b-256 56c33b5b2540102dabd751b33905cf9ed7d8cef9dfb282d8da106179c5bb50db

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