Skip to main content

Pheromone-field coordination for LLM multi-agent systems

Project description

stigmergy-scheduler

Your multi-agent system doesn't need a manager. It needs a pressure field.

Most agent orchestration boils down to three bad options: polling on timers (wasteful), hardcoded if/else routing (brittle), or burning an LLM call to pick who goes next (slow and expensive). All three put coordination logic outside the system it's coordinating.

Stigmergy replaces them with a single primitive: a pressure field. Events deposit signals. Signals decay over time. When accumulated pressure crosses a threshold, the agent wakes and does the work. Dependencies resolve themselves through completion signals. Failed tasks create retry pressure automatically.

Based on arXiv:2601.08129. 7.9x faster than sequential execution at scale (100 tasks, 20 agents, real LLM calls).

Install

pip install stigmergy-scheduler              # core (in-memory backend)
pip install stigmergy-scheduler[redis]       # with Redis backend

Quick start

from stigmergy import StigmergyScheduler, TaskSpec, DispatchResult

scheduler = StigmergyScheduler(wake_threshold=0.4)

async def dispatch(agent_id, task):
    result = await my_llm_call(task.description)
    return DispatchResult(success=True, output=result)

scheduler.set_dispatcher(dispatch)

await scheduler.add_task(TaskSpec(
    id="draft", description="Write first draft",
    agent_id="writer", priority=0.8,
))
await scheduler.add_task(TaskSpec(
    id="review", description="Review the draft",
    agent_id="reviewer", dependencies=["draft"], priority=0.6,
))

await scheduler.run()  # blocks until all tasks complete

You provide a dispatch function. Stigmergy handles the tick loop, signal decay, dependency resolution, error recovery, and metrics.

Framework integrations

Already using a framework? Drop stigmergy in as a scheduling layer:

Low-level field (build your own scheduler)

The StigmergyScheduler is batteries-included, but you can use the pressure field directly for custom scheduling:

from stigmergy import PheromoneField, InMemoryFieldBackend

field = PheromoneField(InMemoryFieldBackend())

await field.deposit("agent-1", "work_claim", 0.8, {"task": "market research"})
pressure = await field.read_pressure("agent-2")
evaporated = await field.decay()

Scheduler API

Method Description
StigmergyScheduler(wake_threshold, tick_interval, ...) Create scheduler with tunable pressure thresholds
scheduler.set_dispatcher(fn) Set the async function called when an agent wakes
await scheduler.add_task(TaskSpec(...)) Queue a task with dependencies and priority
await scheduler.inject_urgent(TaskSpec(...)) Force-wake an agent immediately
await scheduler.run() Block until all tasks complete or stop() is called
scheduler.start() Run in background, returns asyncio.Task
scheduler.stop() Graceful shutdown after current tick
scheduler.get_metrics() Snapshot of ticks, completions, failures, pressure map

Core concepts

Signals are the atomic unit. Each has an agent_id, signal_type, intensity (-1.0 to 1.0), metadata, and optional target_agent_id.

PheromoneField is the shared state space implementing four self-organisation mechanisms: positive feedback (amplify), negative feedback (decay), randomness (stochastic decay), and multiple interactions (emergence from many agents).

Decay strategies: ExponentialDecay (default), LinearDecay, StepDecay, StochasticDecay.

Backends: InMemoryFieldBackend (testing/single-process), RedisFieldBackend (production/multi-process).

Author

Built by Warwick McIntosh at Production Grade.

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_scheduler-0.1.2.tar.gz (19.6 kB view details)

Uploaded Source

Built Distribution

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

stigmergy_scheduler-0.1.2-py3-none-any.whl (13.9 kB view details)

Uploaded Python 3

File details

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

File metadata

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

File hashes

Hashes for stigmergy_scheduler-0.1.2.tar.gz
Algorithm Hash digest
SHA256 9d756fbadf4040469c863a3dadef95f706c109740348acf59ca87ca9a8977b66
MD5 85f7123a2101f3b930b030ad77004c31
BLAKE2b-256 236cd0d249b1b0be7aeedc61f1743fd6d511c0635d079384d33db559576a3655

See more details on using hashes here.

File details

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

File metadata

File hashes

Hashes for stigmergy_scheduler-0.1.2-py3-none-any.whl
Algorithm Hash digest
SHA256 bcc5f6ed2ecbad8914a1a099a7ccb222cadfa7313701aaa697636390b2960044
MD5 aed900172e85c8d3f5a2b3b8e9b08342
BLAKE2b-256 ecaa0877957ed0032eb9c35e685457ac7513fe9e3463cc40cb9debc21c0d1761

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