Skip to main content
Autonomy lets agents operate independently — detecting doom loops, escalating when stuck, and optionally running in a full-auto iterative mode.
Replaces the deprecated verification_hooks=[...] kwarg — see Legacy Agent Parameters.
The string form of autonomy= must name a valid preset (full_auto, …). A typo raises ValueError at construction time with a “Did you mean …?” suggestion — see Fail-Loud Defaults. Matching is case-insensitive, whitespace-tolerant, and treats -/_ interchangeably.
Before PraisonAI PR #4186, hyphen / uppercase / padded variants were accepted by the validator but silently left autonomy disabled. Upgrade to a build that includes PR #4186 to get the behaviour shown above.
The user delegates a coding task; the agent works independently, detects doom loops, and escalates to a human when stuck.

Quick Start

1

Level 1 — Bool (simplest)

Turn on autonomy with a single flag — defaults to the safe suggest level.
2

Level 2 — String (pick a level)

Pass a level name to unlock more independence.
3

Level 3 — Config class (full control)

Use AutonomyConfig to tune iteration caps, doom-loop detection, and escalation.

Autonomy Levels


From YAML

When you set autonomy in agents.yaml, the wrapper accepts an integer 0-10 (validated by the Pydantic schema) and maps it onto the core preset before handing it to Agent(autonomy=…):
bool / str preset / dict / AutonomyConfig values in YAML are passed through unchanged, mirroring the Python API.

How It Works

Completion Signals

The loop can stop on several signals — ranked by how reliably they mean “really done”.
When you have a real acceptance criterion for “done” (e.g. “a PR exists”), use agent.run_goal(...) instead of the heuristics — it gates completion on an independent judge instead of guessing from keywords.

Configuration Options

Full list of options, types, and defaults — AutonomyConfig
The most common options at a glance:
Doom-loop stops are now approval-driven. A detected loop routes through the approval pipeline (default: stop). A legitimate repeat can continue with doom_loop=allow — see Approval → Doom-loop safety gate.
Safety controls belong together. max_iterations and doom_loop_threshold cap how long an agent runs; max_budget_usd and max_tokens cap how much it spends. Set both when running unattended — see Autonomy Budget for the spend/token kill-switch.

Common Patterns

Pattern 1 — Auto-edit mode for coding tasks

Pattern 2 — Full-auto iterative mode

Pattern 3 — Budget-bounded autonomous runs

Cap an unattended run by money or tokens so it can’t burn dollars silently.
Caps are measured from a loop-start baseline, so reusing the same agent across runs never carries prior spend into a new run’s cap.

Choosing a Cap

Pick the cap that matches what you care about most for the run.

Handling budget_exhausted

When a cap trips, the run stops with completion_reason="budget_exhausted" and a metadata payload describing the spend. The metadata dict carries the actual spend, the configured caps, and the status:
budget_action="pause" returns status="paused" and preserves the partial output so you can raise the cap and continue. budget_action="stop" returns status="stopped" — the run is killed unconditionally.

Best Practices

Start with autonomy=True (level suggest) to see what the agent proposes before giving it permission to edit files or run in a full loop. Graduate to auto_edit or full_auto when you trust the agent’s behavior.
The default threshold of 3 means 3 identical actions trigger escalation. Lower this to 2 for high-stakes tasks, or raise it to 5 for tasks where retrying the same action is expected behavior (like polling).
In full_auto mode, the agent loops until it detects completion. Set completion_promise="TASK_COMPLETE" and instruct the agent to output this signal when done, giving you clean loop termination.
For full_auto mode running unattended (nightly jobs, background workers), set max_budget_usd as a hard ceiling. Combine with budget_action="pause" so a hit cap preserves the partial output and lets you raise the cap and resume rather than restart from zero.
budget_action="pause" returns a recoverable result — the partial output is preserved and metadata["status"] is "paused". budget_action="stop" marks it terminal (status="stopped"). Pick pause when a human might raise the cap and continue; pick stop when the run should be killed unconditionally.
AutonomyConfig.sandbox is a forward-compat placeholder — no autonomy level auto-enables sandboxing and nothing reads the field. Use Agent(sandbox=…) to enable the explicit agent.execute_code() API, or AgentFlow(run_on="docker") to isolate a whole workflow in a real container. See Placement.

Autonomy Loop — deep dive into iterative autonomy mode
Autonomy Budget — cap the money and tokens a run can burn
Gate the autonomous loop on an independent acceptance-criteria judge