Skip to main content

Overview

AgentRunner manages agent pipelines, coordinates startup and shutdown, and responds to bus messages. It owns the shared AgentRegistry and AgentBus for all agents in the system.

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.
AgentBus | None
default:"None"
The AgentBus instance. Creates an AsyncQueueBus if not provided.
bool
default:"True"
Whether to handle SIGINT for graceful shutdown.

Properties

bus

The bus instance for agent communication. Pass this to agents when creating them.

registry

The shared agent registry.

Methods

add_agent

Add an agent to this runner. Can be called before or after run(). When called after run() has started, the agent’s pipeline task is created and started immediately.

run

Start all agents and block until shutdown. Starts all registered agents, fires the on_ready event handler, then blocks until end() or cancel() is called. New agents can be added dynamically via add_agent() after run() has started.

end

Gracefully end all agents and shut down. Ends root agents first; parent agents propagate shutdown to their children automatically. Idempotent.

cancel

Immediately cancel all agents and shut down. Cancels root agents first; parent agents propagate cancellation to their children automatically. Idempotent.

Event Handlers