Agent class.
Overview
The agent provides 4 autonomy stages:| Stage | Name | Description | Use Case |
|---|---|---|---|
| 0 | DIRECT | No tools, immediate response | Simple questions |
| 1 | HEURISTIC | Tool selection based on signals | File references, code blocks |
| 2 | PLANNED | Lightweight planning | Edit/test/build tasks |
| 3 | AUTONOMOUS | Full autonomous loop | Multi-step, refactoring |
Quick Start
Custom Configuration
Signal Detection
The agent detects signals from prompts using fast heuristics (no LLM calls):Available Signals
| Signal | Trigger |
|---|---|
simple_question | ”what is”, “define”, “explain” |
complex_keywords | ”analyze”, “refactor”, “optimize” |
file_references | File paths like src/main.py |
code_blocks | Markdown code blocks |
edit_intent | ”edit”, “modify”, “fix” |
test_intent | ”test”, “pytest”, “verify” |
multi_step | Multiple steps or “and then” |
refactor_intent | ”refactor”, “restructure” |
Stage Recommendation
The agent recommends execution stages based on detected signals:Doom Loop Detection
The agent includes built-in doom loop detection to prevent infinite loops:CLI Usage
Use autonomy features from the command line:Best Practices
- Use Agent(autonomy=True) - Enable autonomy features on your agent
- Let the agent decide - The agent automatically selects the right stage
- Custom thresholds - Adjust doom_loop_threshold for your use case
- Check signals - Use analyze_prompt() to understand task complexity
- All agent-centric - No standalone pipeline objects needed
Escalation Components
The escalation pipeline includes several safety and control components underpraisonaiagents/escalation/:
- Doom Loop Detector — pattern-based detection of identical calls and no-progress scenarios
- Loop Guard (PR #1834) — always-on idempotency-aware tool-call guardrails initialised on every
Agent. See Loop Guard. - Pipeline orchestration — coordinates escalation triggers and recovery actions
- Observability hooks — monitoring and metrics for escalation events

