Skip to content

API Reference parrot.flows.dev_loop.agent_pool

github-actions[bot] edited this page Nov 5, 2026 · 4 revisions

parrot.flows.dev_loop.agent_pool

View source

Dev-agent pool: round-robin dispatch, retry, and aggregation (FEAT-323).

DevAgentPool materializes a :class:DevAgentPoolConfig into concrete dispatcher instances (via the Module 3 builder), assigns each wave's tasks to workers round-robin, dispatches them in parallel with a synthetic node_id="development.wN" (so each sub-agent gets its own Redis stream — see FlowStreamMultiplexer), retries a failed task exactly once on a different worker, and aggregates the per-worker outputs into a single :class:DevelopmentOutput.

See sdd/specs/dev-loop-multiple-dev-agents.spec.md §2 "New Public Interfaces" and §3 "Module 4" for the authoritative design.

NOTE: unlike agent_builder.py, this module imports directly from the .dispatcher/.models submodules rather than the parrot.flows.dev_loop package. agent_pool is imported transitively by nodes/development.py (reached via the package's own __init__.py -> flow.py -> factories.py -> nodes/development.py chain), so importing the package here — while it is still mid-initialization — would raise ImportError: cannot import name ... from partially initialized module. Submodule-direct imports avoid that cycle.

Class DevAgentPool

Materializes a dev-agent pool and dispatches waves of tasks across it.

Parameter Type Default Description
config DevAgentPoolConfig The pool configuration this pool was built from.
workers List[PoolWorker] Materialized workers, in stable worker_id order.
pool_max int The effective cap applied when this pool was built.

Method DevAgentPool.build

Expand config.agents by count, cap at pool_max, and build workers.

build(config: DevAgentPoolConfig, dispatcher_builder: Callable[[DevAgentSpec], Tuple[DevLoopCodeDispatcher, BaseModel]], pool_max: int) -> 'DevAgentPool'

Parameter Type Default Description
config DevAgentPoolConfig The pool configuration (backends + replica counts).
dispatcher_builder Callable[[DevAgentSpec], Tuple[DevLoopCodeDispatcher, BaseModel]] A (DevAgentSpec) -> (dispatcher, profile) callable — typically functools.partial(build_dispatcher, redis_url=..., max_concurrent=..., stream_ttl_seconds=...).
pool_max int Hard cap on the total number of workers (across all specs combined). Excess replicas are dropped with a warning.

Returns: 'DevAgentPool' — A new :class:DevAgentPool with workers numbered development.w1..wN in expansion order (specs in declared order, replicas of the same spec consecutive).

Method DevAgentPool.run_wave

Dispatch one wave of tasks across the pool, round-robin, with retry.

run_wave(tasks: List[TaskRef], *, research: ResearchOutput, run_id: str, cwd_for: Callable[[str], str], escalate: bool = False, session_host: Optional[Any] = None) -> WaveResult

Parameter Type Default Description
tasks List[TaskRef] The dispatchable tasks for this wave (see TaskScheduler.next_wave()).
research ResearchOutput Shared research output (wrapped per-task in a :class:TaskScopedBrief).
run_id str The flow run id.
cwd_for Callable[[str], str] worker_id -> cwd resolver.
escalate bool False FEAT-377 TASK-1912 — when True, every worker's FIRST-attempt dispatch in this wave also uses worker.spec.escalation_model (when set), not just the within-wave retry (which already escalates unconditionally per worker). Set by DevelopmentNode when this wave is itself a QA repair-loop redispatch (attempt >= 2) — the caller, not this method, decides when that applies.
session_host Optional[Any] None The run's SessionHost, forwarded to every dispatch in this wave (see :meth:_dispatch_one).

Returns: WaveResult — class:WaveResult with completed/failed tasks and one class:WorkerSummary per worker that took part in this wave.

Raises:

  • ValueError — If the pool has no workers.

Alias DevAgentPoolConfig

Re-exported from parrot.flows.dev_loop.models.DevAgentPoolConfig.

Alias DevAgentSpec

Re-exported from parrot.flows.dev_loop.models.DevAgentSpec.

Alias DevLoopCodeDispatcher

Re-exported from parrot.flows.dev_loop.dispatchers.DevLoopCodeDispatcher.

Alias DevelopmentOutput

Re-exported from parrot.flows.dev_loop.models.DevelopmentOutput.

Alias DispatchExecutionError

Re-exported from parrot.flows.dev_loop.dispatchers.DispatchExecutionError.

Alias DispatchLabels

Re-exported from parrot.flows.dev_loop.models.DispatchLabels.

Alias DispatchOutputValidationError

Re-exported from parrot.flows.dev_loop.dispatchers.DispatchOutputValidationError.

Attribute INTERNAL_ERROR_PREFIX

Class PoolWorker

A single materialized dev-agent slot in the pool.

Parameter Type Default Description
worker_id str
spec DevAgentSpec
dispatcher DevLoopCodeDispatcher
profile BaseModel

Fields:

Field Type Default Description
worker_id str Synthetic node id, e.g. "development.w1". Stable for the lifetime of the pool.
spec DevAgentSpec The :class:DevAgentSpec this worker was built from.
dispatcher DevLoopCodeDispatcher The concrete dispatcher instance for spec.agent.
profile BaseModel The dispatch profile instance for spec.agent.

Alias ResearchOutput

Re-exported from parrot.flows.dev_loop.models.ResearchOutput.

Alias TaskRef

Re-exported from parrot.flows.dev_loop.task_scheduler.TaskRef.

Alias TaskScopedBrief

Re-exported from parrot.flows.dev_loop.models.TaskScopedBrief.

Class WaveResult

Outcome of dispatching one wave of tasks across the pool.

Parameter Type Default Description
completed Dict[str, DevelopmentOutput] dict()
failed List[str] list()
worker_summaries List[WorkerSummary] list()

Fields:

Field Type Default Description
completed Dict[str, DevelopmentOutput] field(default_factory=dict) task_id -> DevelopmentOutput for every task that eventually succeeded (first try or retry).
failed List[str] field(default_factory=list) TASK-NNN ids that failed twice (original + retry).
worker_summaries List[WorkerSummary] field(default_factory=list) One :class:WorkerSummary per worker that participated in this wave.

Alias WorkerSummary

Re-exported from parrot.flows.dev_loop.models.WorkerSummary.

Function aggregate_outputs

Merge every wave's outputs into a single :class:DevelopmentOutput.

aggregate_outputs(results: List[WaveResult], incomplete: List[str]) -> DevelopmentOutput

Parameter Type Default Description
results List[WaveResult] One :class:WaveResult per wave dispatched by the pool.
incomplete List[str] TASK-NNN ids that never completed (failed twice, or were transitively skipped by the scheduler).

Returns: DevelopmentOutput — The aggregated output: files_changed deduplicated preserving first-seen order, commit_shas in arrival order, summary built from per-worker summaries (one merged :class:WorkerSummary per worker_id across all waves), plus incomplete_tasks.

Function is_internal_error

Whether a _dispatch_one error string reports a bug on our side.

is_internal_error(error: Optional[str]) -> bool

Parameter Type Default Description
error Optional[str] The error string from a dispatch attempt, if any.

Returns: bool — True when the failure was an internal error, not a failed dispatch.

Attribute logger

Architecture

Clients

Bots & Agents

Memory

Knowledge

Tools & Toolkits

Flows

Experts

Skills

Stores & Loaders

MCP & A2A

Server & APIs

Integrations

Outputs & A2UI

Prompts

Security

Operations

Migration

SDD Tooling

LLM Wiki

Deployment

Decisions

API Reference

Clone this wiki locally