Skip to main content
Autonomy lets agents operate independently — detecting doom loops, escalating when stuck, and optionally running in a full-auto iterative mode.
from praisonaiagents import Agent

agent = Agent(
    name="Assistant",
    instructions="You are an autonomous coding assistant.",
    autonomy=True,
)

agent.start("Refactor the authentication module to use JWT tokens.")
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.
from praisonaiagents import Agent

agent = Agent(
    name="Coder",
    instructions="You are an autonomous task-completion agent.",
    autonomy=True,
)
agent.start("Write and test a Python function to merge sorted arrays.")
2

Level 2 — String (pick a level)

Pass a level name to unlock more independence.
from praisonaiagents import Agent

agent = Agent(
    name="Coder",
    instructions="You are an autonomous coding agent.",
    autonomy="full_auto",
)
agent.start("Build a REST API endpoint for user authentication.")
3

Level 3 — Config class (full control)

Use AutonomyConfig to tune iteration caps, doom-loop detection, and escalation.
from praisonaiagents import Agent, AutonomyConfig

agent = Agent(
    name="Coder",
    instructions="You are a precise autonomous agent.",
    autonomy=AutonomyConfig(
        level="auto_edit",
        max_iterations=30,
        doom_loop_threshold=5,
        auto_escalate=True,
    ),
)
agent.start("Review and improve the test coverage for the payment module.")

Autonomy Levels


How It Works

PhaseWhat happens
1. ExecuteAgent takes action toward the goal
2. Safety checkDoom loop tracker monitors for repeated identical actions
3. EscalateIf stuck, agent asks user for guidance instead of looping
4. CompleteIterative mode detects task completion signal

Configuration Options

Full list of options, types, and defaults — AutonomyConfig
The most common options at a glance:
OptionTypeDefaultDescription
levelstr"suggest""suggest", "auto_edit", or "full_auto"
max_iterationsint20Max iterations before stopping
doom_loop_thresholdint3Repeated actions before doom loop detection
auto_escalateboolTrueAutomatically escalate when stuck
completion_promisestr | NoneNoneSignal text that marks task completion

Common Patterns

Pattern 1 — Auto-edit mode for coding tasks

from praisonaiagents import Agent, AutonomyConfig

agent = Agent(
    instructions="You are a senior software engineer.",
    autonomy=AutonomyConfig(
        level="auto_edit",
        max_iterations=15,
        doom_loop_threshold=3,
    ),
)
response = agent.start("Add input validation to all API endpoints in the users module.")
print(response)

Pattern 2 — Full-auto iterative mode

from praisonaiagents import Agent, AutonomyConfig

agent = Agent(
    instructions="You are an autonomous DevOps agent.",
    autonomy=AutonomyConfig(
        level="full_auto",
        completion_promise="DEPLOYMENT_COMPLETE",
        max_iterations=50,
    ),
)
agent.start("Deploy the application to staging and run smoke tests.")

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.

Autonomy Loop — deep dive into iterative autonomy mode

Planning — plan before acting on complex requests