Skip to main content
The user gives a high-level goal; AutoAgents analyses complexity, spawns agents, assigns tools, and executes the workflow. AutoAgents automatically creates and manages AI agents and tasks based on high-level instructions. It now features dynamic agent count based on task complexity and supports multiple workflow patterns including orchestrator-workers and evaluator-optimizer.

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 AutoAgents

Run your AutoAgents:
Requirements
  • Python 3.10 or higher
  • OpenAI API key. Generate OpenAI API key here. Use Other models using this guide.

How It Works

What tools does the planner see?

The --auto planner sees a live inventory of your installed tools, not a fixed list. The planner prompt’s Available Tools: ... line is filled by get_available_tools(), which reads directly from the canonical ToolResolver. Whatever the resolver can see, the planner can plan with — install a tool package and it shows up automatically. If the resolver is unavailable (import failure or an air-gapped environment), the planner falls back to a small frozen list so --auto still produces a valid plan.
Grow the planner’s tool list by installing a tool package (pip install "praisonai-tools" or pip install "praisonaiagents[tools]") or by dropping a tools.py into your working directory with PRAISONAI_ALLOW_LOCAL_TOOLS=true. The --auto planner picks it up automatically because get_available_tools() reads from the live ToolResolver.

Understanding AutoAgents

What are AutoAgents?

AutoAgents automatically:
  • Analyzes task complexity to determine optimal agent count (1-4 agents)
  • Creates appropriate AI agents based on your instructions
  • Assigns relevant tools to each agent
  • Recommends workflow patterns (sequential, parallel, routing, orchestrator-workers, evaluator-optimizer)
  • Manages execution flow between agents
  • Handles agent coordination and task delegation

Features

Dynamic Agent Count

Analyzes task complexity and creates 1-4 agents as needed. Simple tasks get fewer agents.

Smart Tool Assignment

Automatically assigns relevant tools to each agent from every tool the ToolResolver can currently see — local tools.py, praisonaiagents.tools, the praisonai-tools package, wrapper ToolRegistry registrations, and core SDK plugins.

Workflow Patterns

Supports 6 patterns: sequential, parallel, routing, loop, orchestrator-workers, evaluator-optimizer.

Pattern Recommendation

Automatically recommends the best workflow pattern based on task characteristics.

Workflow Patterns

Agents work one after another, passing output to the next.
Multiple agents work concurrently on independent subtasks.
A classifier agent routes requests to specialized agents based on input type.
A central orchestrator dynamically delegates tasks to specialized workers.
One agent generates content, another evaluates it in a loop until quality criteria are met.

Advanced Usage

Configuration Options

Process Types

Best Practices

Troubleshooting

Tool Assignment Issues

If tools aren’t being assigned correctly:
  • Check tool compatibility
  • Verify tool names
  • Enable verbose mode for debugging

Performance Issues

If execution is slow:
  • Reduce max_agents
  • Adjust max_rpm
  • Consider process type

AutoGenerator API (Python)

Fixed in PR #2147: WorkflowAutoGenerator.generate() and JobWorkflowAutoGenerator.generate() were non-functional in all previous releases due to a NameError on _models_cache. These examples now work as shown.
Fixed in PR #2738: WorkflowAutoGenerator(framework="crewai", ...) now correctly writes framework: crewai into the generated workflow YAML. Earlier versions silently overrode the kwarg to praisonai — if you worked around this by hand-editing the YAML, you can drop that workaround on v4.6.134+.
The framework= kwarg is honoured end-to-end — the value you pass is the value written to the YAML:
For programmatic control over agent generation:

Async usage

For long-running servers and async pipelines, use async with and agenerate():
async with is preferred over relying on __del__. The destructor was removed in PR #1736 because it leaked sockets in long-running servers. Use the context manager, or call await gen.aclose() explicitly.

AutoGenerator Parameters

topic
str
required
The task/topic for agent generation
agent_file
str
default:"agents.yaml"
Output YAML file name
framework
str
default:"praisonai"
Framework: “praisonai”, “crewai”, or “autogen”
pattern
str
default:"sequential"
Workflow pattern: “sequential”, “parallel”, “routing”, “orchestrator-workers”, “evaluator-optimizer”
single_agent
bool
default:"False"
If True, generate a single agent instead of a team

WorkflowAutoGenerator Parameters

topic
str
required
The task/topic for workflow generation
workflow_file
str
default:"workflow.yaml"
Output YAML file name
framework
str
default:"praisonai"
Framework: “praisonai”, “crewai”, or “autogen”
single_agent
bool
default:"False"
If True, generate a single agent workflow

Methods

generate(pattern, merge)
method
Generate the YAML file. merge=True merges with existing file.
recommend_pattern()
method
Keyword-based pattern recommendation (fast, no API call)
recommend_pattern_llm()
method
LLM-based pattern recommendation with reasoning and confidence score
agenerate(...)
async method
Async equivalent of generate(). Uses LiteLLM async (preferred) or AsyncOpenAI (fallback). Same arguments and return value as generate().
close() / aclose()
method
Explicit cleanup of the underlying OpenAI client. Prefer with / async with context managers instead.

AutoAgents API (Runtime)

Main Parameters

instructions
str
required
High-level task description for the agents
tools
List[Any]
List of tools available to the agents
max_agents
int
default:"3"
Maximum number of agents to create
process
str
default:"sequential"
Process type: “sequential” or “hierarchical”

Optional Parameters

verbose
bool
default:"False"
Enable detailed logging
memory
bool
default:"True"
Enable agent memory
allow_delegation
bool
default:"False"
⚠️ Deprecated — use handoffs= instead. Allow agents to delegate tasks.

Methods

start()
method
Start the agents synchronously
astart()
method
Start the agents asynchronously

Next Steps

Examples

Explore more examples in our examples directory

Custom Tools

Learn how to create custom tools for your agents
For optimal results, provide clear instructions and appropriate tools for your use case.

Build multi-agent teams by hand for full control over roles and tasks.

Understand how agents plan and sequence steps before executing.