Skip to content

API Reference parrot.flows.dev_loop.agent_builder

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

parrot.flows.dev_loop.agent_builder

View source

Reusable dev-agent dispatcher builder + pool env parsing (FEAT-323).

Extracts the DevAgentSpec -> (dispatcher, profile) mapping that used to live inline in examples/dev_loop/server.py (the DEV_LOOP_DEVELOPMENT_ AGENT if/elif block) into a reusable, testable function so a DevAgentPool (TASK-1860) can materialize N dispatchers instead of just one. Also provides the DEV_LOOP_DEV_AGENTS / DEV_LOOP_DEV_ISOLATION / DEV_LOOP_DEV_POOL_MAX env-var parsers.

See sdd/specs/dev-loop-multiple-dev-agents.spec.md §3 "Module 3" for the authoritative design. The per-backend model defaults and env-var names here are copied verbatim from examples/dev_loop/server.py (lines ~454-585) so the single-agent path keeps byte-identical observable behaviour.

Alias ClaudeCodeDispatchProfile

Re-exported from parrot.flows.dev_loop.ClaudeCodeDispatchProfile.

Alias ClaudeCodeDispatcher

Re-exported from parrot.flows.dev_loop.ClaudeCodeDispatcher.

Alias CodexCodeDispatchProfile

Re-exported from parrot.flows.dev_loop.CodexCodeDispatchProfile.

Alias CodexCodeDispatcher

Re-exported from parrot.flows.dev_loop.CodexCodeDispatcher.

Attribute ConfigGetter

Attribute DEFAULT_LLM_MAX_TURNS

Type: int

Attribute DEFAULT_LLM_TURNS_PER_FILE

Type: int

Alias DevAgentPoolConfig

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

Alias DevAgentSpec

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

Alias DevLoopCodeDispatcher

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

Attribute ENV_LLM_MAX_TURNS

Type: str

Attribute ENV_LLM_TURNS_PER_FILE

Type: str

Alias GeminiCodeDispatchProfile

Re-exported from parrot.flows.dev_loop.GeminiCodeDispatchProfile.

Alias GeminiCodeDispatcher

Re-exported from parrot.flows.dev_loop.GeminiCodeDispatcher.

Alias GoogleCodingDispatchProfile

Re-exported from parrot.flows.dev_loop.GoogleCodingDispatchProfile.

Alias GoogleCodingDispatcher

Re-exported from parrot.flows.dev_loop.GoogleCodingDispatcher.

Alias GoogleCompatCodeDispatchProfile

Re-exported from parrot.flows.dev_loop.GoogleCompatCodeDispatchProfile.

Alias GoogleCompatCodeDispatcher

Re-exported from parrot.flows.dev_loop.GoogleCompatCodeDispatcher.

Alias GrokCodeDispatchProfile

Re-exported from parrot.flows.dev_loop.GrokCodeDispatchProfile.

Alias GrokCodeDispatcher

Re-exported from parrot.flows.dev_loop.GrokCodeDispatcher.

Alias LLMCodeDispatchProfile

Re-exported from parrot.flows.dev_loop.LLMCodeDispatchProfile.

Alias LLMCodeDispatcher

Re-exported from parrot.flows.dev_loop.LLMCodeDispatcher.

Attribute LLM_TURNS_CEILING

Type: int

Attribute LLM_TURNS_FIXED

Type: int

Alias MoonshotCodeDispatchProfile

Re-exported from parrot.flows.dev_loop.MoonshotCodeDispatchProfile.

Alias MoonshotCodeDispatcher

Re-exported from parrot.flows.dev_loop.MoonshotCodeDispatcher.

Alias NovaCodeDispatchProfile

Re-exported from parrot.flows.dev_loop.NovaCodeDispatchProfile.

Alias NovaCodeDispatcher

Re-exported from parrot.flows.dev_loop.NovaCodeDispatcher.

Alias ZaiCodeDispatchProfile

Re-exported from parrot.flows.dev_loop.ZaiCodeDispatchProfile.

Alias ZaiCodeDispatcher

Re-exported from parrot.flows.dev_loop.ZaiCodeDispatcher.

Function build_dispatcher

Materialize a DevAgentSpec into a dispatcher + dispatch profile.

Mirrors the DEV_LOOP_DEVELOPMENT_AGENT if/elif block in examples/dev_loop/server.py (lines ~454-585), parametrized by spec instead of a single global env var. spec.model (when non-empty) always wins over the backend's env-var/hardcoded default.

build_dispatcher(spec: DevAgentSpec, *, redis_url: str, max_concurrent: int, stream_ttl_seconds: int, config_getter: ConfigGetter = _default_config_getter) -> Tuple[DevLoopCodeDispatcher, BaseModel]

Parameter Type Default Description
spec DevAgentSpec The dev-agent spec (backend + optional model override).
redis_url str Redis URL passed to every dispatcher constructor.
max_concurrent int Concurrency cap for this dispatcher's semaphore.
stream_ttl_seconds int Redis stream TTL passed to every dispatcher.
config_getter ConfigGetter _default_config_getter (key, fallback) -> Any callable used to resolve per-backend model/behaviour env vars. Defaults to conf.config.get; tests inject a fake for isolation.

Returns: Tuple[DevLoopCodeDispatcher, BaseModel] — A (dispatcher, profile) tuple.

Raises:

  • ValueError — If spec.agent is not one of the known backends (should not happen given DevAgentSpec's Literal type, but guards against future drift).

Attribute logger

Function parse_pool_env

Parse DEV_LOOP_DEV_AGENTS / DEV_LOOP_DEV_ISOLATION into a config.

parse_pool_env(config_getter: ConfigGetter) -> Optional[DevAgentPoolConfig]

Parameter Type Default Description
config_getter ConfigGetter (key, fallback) -> Any callable.

Returns: Optional[DevAgentPoolConfig] — class:DevAgentPoolConfig, or None when the env var is absent/empty, its JSON is malformed, or it fails Pydantic validation (e.g. unknown backend, empty agents list) — this is a degradation signal, never an exception.

Function resolve_pool_max

Resolve the DEV_LOOP_DEV_POOL_MAX cap on total pool concurrency.

resolve_pool_max(config_getter: ConfigGetter, *, default: int = 4) -> int

Parameter Type Default Description
config_getter ConfigGetter (key, fallback) -> Any callable.
default int 4 Fallback cap when unset/unparsable.

Returns: int — The resolved cap, always >= 1.

Function scaled_max_turns

Return the turn budget for a task that declares declared_files files.

scaled_max_turns(base: int, declared_files: Optional[int], *, per_file: int = DEFAULT_LLM_TURNS_PER_FILE, ceiling: int = LLM_TURNS_CEILING) -> int

Parameter Type Default Description
base int The configured flat budget (the floor).
declared_files Optional[int] Files the task lists under "Files to Create / Modify"; None/non-positive (unknown) keeps base.
per_file int DEFAULT_LLM_TURNS_PER_FILE Turns added per declared file.
ceiling int LLM_TURNS_CEILING Hard upper bound (the profile field's own limit).

Returns: int — base clamped to ceiling when the count is unknown, otherwise min(ceiling, max(base, LLM_TURNS_FIXED + per_file * declared_files)).

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