mode field determines whether start() uses a single chat() call ("caller") or a multi-turn loop ("iterative").
Which Mode Should I Choose?
Not sure which mode fits your task? Use this guide:| Mode | Best For | Example Prompt | What Happens |
|---|---|---|---|
| No autonomy | Questions, explanations, advice | ”Explain authentication patterns” | Agent answers from knowledge — doesn’t touch files or run tools |
| Caller (default) | Single-shot automation, pipelines | ”Search for X and save to file” | Agent uses tools in one turn, returns AutonomyResult |
| Iterative | Multi-step self-correction | ”Refactor auth module and verify tests” | Agent loops with doom loop protection until done |
Quick Start
Architecture
The autonomy system spans the Core SDK and Wrapper CLI, unified through bridging: Key design decisions:- Single source of truth:
AutonomyLevelenum lives in the SDK; CLI’sAutonomyModederives from it - Bridge via env var: CLI’s
FULL_AUTOmode setsPRAISONAI_AUTO_APPROVE=truefor SDK approval - AgentTeam propagation:
AgentTeam(autonomy=...)propagates config to all managed agents - Memory integration:
run_autonomous()auto-saves sessions between iterations
Autonomy Stages
The agent automatically selects an execution stage based on task complexity:| Stage | Triggers | Behavior |
|---|---|---|
direct | Simple questions, explanations | Single response |
heuristic | File references, code blocks | Context-aware |
planned | Edit/test intent | Plan before acting |
autonomous | Multi-step, refactoring | Full iteration loop |
How Completion Works
Understanding how the agent knows when it’s “done” is key to choosing the right mode. The model decides when to stop by not requesting more tools. This is the same protocol used by ChatGPT, Claude, and all major LLM APIs.| Completion Signal | How It Works | Reliability |
|---|---|---|
| Tool completion | Model used tools, then stopped requesting more | ⭐⭐⭐ Most reliable |
| Promise tag | Model outputs <promise>DONE</promise> | ⭐⭐⭐ Explicit signal |
| Keyword detection | Model says “task completed” | ⭐⭐ Can be inconsistent |
| No-tool turns | Model produces text without tools for 2+ turns | ⭐⭐ Safety fallback |
| Max iterations | Reached the iteration limit | ⭐ Last resort |
Configuration Options
| Option | Type | Default | Description |
|---|---|---|---|
enabled | bool | True | Whether autonomy is enabled |
level | str | "suggest" | Autonomy level: suggest, auto_edit, full_auto |
mode | str | Smart default | "caller" (single chat) or "iterative" (loop). Defaults: suggest/auto_edit → "caller", full_auto → "iterative" |
max_iterations | int | 20 | Maximum iterations (iterative mode only) |
doom_loop_threshold | int | 3 | Repeated actions to trigger doom loop |
auto_escalate | bool | True | Automatically escalate complexity |
observe | bool | False | Emit observability events |
Doom Loop Detection
Prevents agents from getting stuck in repetitive failure patterns:Escalation Pipeline
When an agent can’t complete a task, it escalates:Signal Detection
Autonomy uses heuristics to detect task complexity:Use Cases
Code Refactoring
Best for: Multi-step code changesAgent plans, executes, and verifies changes autonomously.
Research Tasks
Best for: Information gatheringAgent searches, synthesizes, and reports findings.
Bug Fixing
Best for: Debugging workflowsAgent analyzes, fixes, and tests iteratively.
Content Generation
Best for: Writing and editingAgent drafts, refines, and polishes content.
Best Practices
Start with caller mode (default)
Start with caller mode (default)
Most tasks complete in a single turn. The model calls all needed tools and summarizes — no iteration loop needed. Only switch to iterative when you need multi-turn self-correction.
Use completion promises for iterative mode
Use completion promises for iterative mode
Set
completion_promise for reliable termination in iterative mode. The agent outputs <promise>DONE</promise> when finished.Keep doom loop threshold low
Keep doom loop threshold low
Keep
doom_loop_threshold at 3-5 to prevent runaway agents and wasted resources.Monitor with observe mode
Monitor with observe mode
Set
observe=True during development to track agent behavior and stage escalation.Related
Planning
Think before acting
Guardrails
Safety constraints

