Skip to main content
Autonomy lets agents operate independently — detecting doom loops, escalating when stuck, and optionally running in a full-auto iterative mode.
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


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:
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.

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