Overview
WorkerRunner runs agents to completion and acts as the host for a multi-agent session. It owns the shared WorkerBus and WorkerRegistry that back the whole session, and responds to bus messages for lifecycle coordination.
PipelineRunner is a deprecated alias for WorkerRunner; existing code that
uses it keeps working but should migrate to WorkerRunner.add_workers() attaches it to the runner’s bus and registry, so agents do not take a bus in their constructor.
Configuration
str | None
default:"None"
Unique name for this runner. Defaults to a UUID-based name. Must be unique
across all runners in a distributed setup.
WorkerBus | None
default:"None"
The
WorkerBus instance. Creates
an AsyncQueueBus if not
provided.bool
default:"True"
Whether to automatically handle SIGINT signals for graceful shutdown.
bool
default:"False"
Whether to automatically handle SIGTERM signals for graceful shutdown.
bool
default:"False"
Whether to force garbage collection after the main worker completes.
bool
default:"True"
Whether to warn about tasks left running on the shared task manager once every
worker has finished.
BaseTaskManager | None
default:"None"
Optional task manager for handling asyncio tasks. If
None, a default
TaskManager is created with the current running loop.asyncio.AbstractEventLoop | None
default:"None"
Event loop to use. If
None, uses the current running loop.Properties
bus
registry
Methods
add_workers
run(). When called after run() has started, each agent starts immediately; otherwise agents are queued and started during run setup.
get_worker
Returns: The agent, or
None if this runner has none by that name.
Only agents on the same runner have a local instance to return. One on another runner is addressable over the bus but has no object to hand back, so this returns None for it.
run
auto_end=True), the runner ends once every root agent has finished. For long-lived hosts that add and remove agents over many sessions, pass auto_end=False so the runner does not exit when no agents are left.
end
cancel
run() answers by cancelling every worker still going and waiting for it. The messages go out as the runner exits, carrying the reason given here. Idempotent; subsequent calls are ignored.