Skip to main content
The user sets a goal; the agent loops on environment feedback until it stops or hits a completion signal. An agent-based workflow where LLMs act autonomously within a loop, interacting with their environment and receiving feedback to refine their actions and decisions.

Quick Start

1

Install Package

First, install the PraisonAI Agents package:
2

Set API Key

Set your OpenAI API key as an environment variable in your terminal:
3

Create a file

Create a new file app.py with the basic setup:
4

Start Workflow

Type this in your terminal to run your workflow:
Requirements
  • Python 3.10 or higher
  • OpenAI API key. Generate OpenAI API key here. Use Other models using this guide.
  • Basic understanding of Python

How It Works

PhaseWhat happens
1. MonitorThe monitor agent reads the current environment state
2. Actroute() dispatches the matching action agent
3. AdaptFeedback feeds back into the loop via context=
4. StopThe loop ends when the until condition is met

Choosing an Autonomy Level

Decide how much the workflow runs without a human in the loop.

Understanding Autonomous Workflow

What is Autonomous Workflow?

Autonomous Workflow enables:
  • Continuous environment monitoring
  • Automated decision-making and action execution
  • Real-time feedback processing
  • Self-adapting behavior based on outcomes

Features

Environment Monitoring

Continuously monitor and analyze environment state.

Adaptive Actions

Execute context-aware actions based on state analysis.

Feedback Processing

Process and learn from action outcomes.

Self-Optimization

Improve performance through continuous learning.

Configuration Options

Troubleshooting

Monitoring Issues

If monitoring fails:
  • Check environment access
  • Verify state detection
  • Enable verbose mode for debugging

Adaptation Flow

If adaptation is incorrect:
  • Review feedback processing
  • Check action outcomes
  • Verify learning loop

Best Practices

The monitor agent should return only discrete states (normal, critical, optimal). Vague prose breaks route() matching and causes wrong action agents to run.
Always set max_iterations on repeat() loops. Without a ceiling, a misconfigured until condition can spin indefinitely and burn tokens.
For run_autonomous flows, set max_budget_usd and max_tokens so an unattended run can’t burn unlimited money or tokens. See Autonomy Budget.
Pass prior task outputs via context=[...] on the feedback step so the agent learns from outcomes rather than re-analysing from scratch each cycle.
Enable verbose output while tuning routes and exit conditions. Once the workflow stabilises, reduce logging for production runs.

Next Steps

AutoAgents

Learn about automatically created and managed AI agents

Mini Agents

Explore lightweight, focused AI agents
For optimal results, ensure your environment monitoring is reliable and your feedback processing logic is properly configured for effective adaptation.

Run agents in iterative self-referential loops with completion signals.

Auto-create and manage agents and tasks from high-level instructions.