Skip to content

API Reference parrot.flows.dev_loop.toolkit

github-actions[bot] edited this page Dec 2, 2026 · 4 revisions

parrot.flows.dev_loop.toolkit

View source

DevLoopToolkit — the dev loop as tools an agent can call.

The dev loop (parrot.flows.dev_loop) could only be started three ways: DevLoopRunner.run(brief) in code, the two HTTP consoles under examples/dev_loop/, or the webhook. None of those is reachable from a conversation, so an agent asked to fix a bug could describe the pipeline but never start it.

This toolkit closes that: start_dev_loop builds the brief and launches a run, dev_loop_status reports where it got to, and dev_loop_approve resolves a HITL gate. Every public async method here becomes a tool automatically (AbstractToolkit), named devloop_<method>.

Two seams keep it useful without knowing anything about the caller's world:

  • brief_enricher — fills in what a one-line report cannot say (affected_component, the right repo, acceptance criteria). A caller with a codebase index plugs it in here; without one the toolkit still works, it just needs a fuller brief.
  • flow_builder — the approval gates are baked in at flow-construction time, not per run, so a flow is built (and cached) per approval mode.

Runs are launched in the background and the tool returns a run_id immediately. A dev-loop run takes minutes: returning its result would block the caller — and, for an agentd daemon, its socket — for the whole run.

Autonomy is decided after seeing the plan, not before. A run starts with every gate enabled, so the first thing that happens is the plan coming back for approval; approving it with then="autonomous" hands the rest of the run over, and then="ask" keeps the later gates. This is deliberate: the gates are compiled into the flow at construction time, so a run cannot gain a gate later — it can only be relieved of one. Starting locked down and loosening on request is therefore the only order that lets the choice come after the plan.

Alias AbstractToolkit

Re-exported from parrot.tools.toolkit.AbstractToolkit.

Attribute ApprovalMode

Class BriefEnricher

Fills in a brief that a one-line bug report cannot fully specify.

Implementations resolve things like "the api returns 500 on /xyz" into the repo and component that actually own the endpoint.

Method BriefEnricher.enrich

Return draft with missing fields filled in.

enrich(draft: Dict[str, Any]) -> Dict[str, Any]

Parameter Type Default Description
draft Dict[str, Any] Partial WorkBrief kwargs.

Returns: Dict[str, Any] — The same mapping, enriched. Implementations must not raise for "could not resolve" — leave the field alone and let validation report it.

Alias DevLoopRunner

Re-exported from parrot.flows.dev_loop.runner.DevLoopRunner.

Class DevLoopToolkit

Start and supervise dev-loop runs from an agent conversation.

Tool names (with tool_prefix="devloop"):

  • devloop_start_dev_loop — start a run from a bug/enhancement report
  • devloop_dev_loop_status — phase, nodes, pending gates of a run
  • devloop_dev_loop_runs — the runs this toolkit has started
  • devloop_dev_loop_approve— resolve a pending HITL gate
  • devloop_dev_loop_cancel — request cancellation of a run

Example::

toolkit = DevLoopToolkit(
    flow_kwargs={"git_toolkit": git, "repos": repos},
    brief_enricher=my_enricher,
)
agent.register_tools(toolkit.get_tools())
Parameter Type Default Description
flow_builder Optional[Callable[..., Any]] None Callable building a dev-loop flow. Defaults to :func:parrot.flows.dev_loop.flow.build_dev_loop_flow, imported lazily so constructing the toolkit stays cheap.
flow_kwargs Optional[Dict[str, Any]] None Forwarded to flow_builder (toolkits, dispatchers, repos, ...). The gate flags are set per approval mode and must not be passed here.
runner_kwargs Optional[Dict[str, Any]] None Forwarded to :class:DevLoopRunner.
brief_enricher Optional[BriefEnricher] None Optional :class:BriefEnricher.
default_reporter str 'agent' WorkBrief.reporter when the caller gives none — an agent-started run still needs an author.
default_assignee str 'unassigned' WorkBrief.escalation_assignee default.
default_approval_mode ApprovalMode 'every_step' Approval mode when the caller gives none. Defaults to "every_step" so a run starts locked down and the autonomy decision can be made after the plan is seen (see the module docstring).
gate_poll_seconds float 5.0 How often the watcher checks for gates to auto-approve on a run set to autonomous.
**kwargs Any {} Forwarded to :class:AbstractToolkit.

Attributes:

Attribute Type Description
tool_prefix Optional[str]
confirming_tools frozenset

Method DevLoopToolkit.start_dev_loop

Start a dev-loop run for a bug or enhancement, and return its id.

Runs research, development, QA and PR hand-off. This returns as soon as the run is accepted — a run takes minutes, so poll dev_loop_status instead of waiting on this call.

Approval: with approval_mode="plan" (the default) the run pauses for a human to approve the plan and then finishes on its own; with "every_step" it also pauses before the PR hand-off; with "none" it never pauses. Report the mode back to the user — it decides how autonomous the run is.

start_dev_loop(summary: str, description: str = '', kind: str = 'bug', repo: Optional[str] = None, error_text: Optional[str] = None, acceptance_commands: Optional[List[str]] = None, approval_mode: Optional[str] = None, reporter: Optional[str] = None, existing_issue_key: Optional[str] = None) -> Dict[str, Any]

Parameter Type Default Description
summary str One-line statement of the problem ("500 on /api/v1/xyz").
description str '' Everything else known: steps, expected vs actual.
kind str 'bug' bug, enhancement or new_feature.
repo Optional[str] None Repository that owns the code. Inferred when omitted and an enricher is configured.
error_text Optional[str] None Pasted stack trace / error body. Attached as an inline log source, which is what the intake and research nodes read.
acceptance_commands Optional[List[str]] None Shell commands QA runs to decide the work is done — a criterion is executed, not read, so this takes commands (pytest tests/test_xyz.py) rather than prose. The command head is allow-listed at intake.
approval_mode Optional[str] None plan | every_step | none.
reporter Optional[str] None Who is asking. Defaults to the configured reporter.
existing_issue_key Optional[str] None Attach to this Jira issue instead of creating one.

Returns: Dict[str, Any] — {"run_id", "status", "approval_mode", "gates", "brief"}.

Raises:

  • ValueError — kind/approval_mode invalid, or the brief is still incomplete after enrichment.

Method DevLoopToolkit.dev_loop_status

Report where a dev-loop run got to, and what it is waiting for.

Use the run_id that start_dev_loop returned. Pending gates are what a human has to act on: pass one to dev_loop_approve.

dev_loop_status(run_id: str) -> Dict[str, Any]

Parameter Type Default Description
run_id str The run to inspect.

Returns: Dict[str, Any] — {"run_id", "status", "phase", "nodes", "pending_gates", "error"}.

Raises:

  • KeyError — This toolkit never started run_id.

Method DevLoopToolkit.dev_loop_runs

List the dev-loop runs this agent has started.

dev_loop_runs() -> Dict[str, Any]

Returns: Dict[str, Any] — {"runs": [{"run_id", "status", "kind", "summary", "approval_mode"}]}, newest last.

Method DevLoopToolkit.dev_loop_approve

Resolve a pending approval gate so a paused run can continue.

Get gate_id from dev_loop_status, which also returns the plan the gate is asking about. resolution="rejected" aborts instead of continuing.

then is how much of the rest of the run still needs a human, and is the decision to put to the user once they have read the plan: "ask" keeps stopping at every later gate, "autonomous" lets the run finish on its own — including opening the PR. Ask before choosing "autonomous"; do not assume it.

dev_loop_approve(run_id: str, gate_id: str, resolution: str = 'approved', then: str = 'ask', comment: str = '', resolved_by: str = '') -> Dict[str, Any]

Parameter Type Default Description
run_id str The paused run.
gate_id str The gate to resolve.
resolution str 'approved' approved or rejected.
then str 'ask' ask (default) or autonomous.
comment str '' Free-text audit comment.
resolved_by str '' Who approved. Defaults to the configured reporter.

Returns: Dict[str, Any] — {"run_id", "gate_id", "resolution", "then", "sequence"}.

Raises:

  • KeyError — Unknown run, or the run has no live host.
  • ValueError — resolution or then is not a valid value.

Method DevLoopToolkit.dev_loop_cancel

Request cancellation of a running dev-loop run.

dev_loop_cancel(run_id: str, requested_by: str = '') -> Dict[str, Any]

Parameter Type Default Description
run_id str The run to cancel.
requested_by str '' Who asked. Defaults to the configured reporter.

Returns: Dict[str, Any] — {"run_id", "cancelled"}.

Raises:

  • KeyError — Unknown run, or the run has no live host.

Alias WorkBrief

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

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