tools / swarm.py

Fire-and-forget background task dispatch to swarm nodes with optional blocking await.

Tool: delegate_to_swarm

Args

Execution

  1. For each task, spawn a _swarm_worker coroutine with 2 retries and exponential backoff.
  2. POST to node["client"].post("/v1/chat/completions", {messages:[system: persona, user: instruction + input_data]}).
  3. On success, write the response into scratchpad at output_key.
  4. Record success/failure with the per-node circuit breaker.

Registry

_swarm_task_registry tracks asyncio.Task objects by id and auto-cleans via a done callback.