Skip to main content
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:
pip install praisonaiagents duckduckgo_search
2

Set API Key

Set your OpenAI API key as an environment variable in your terminal:
export OPENAI_API_KEY=your_api_key_here
3

Create a file

Create a new file app.py with the basic setup:
from praisonaiagents import AutoAgents
from praisonaiagents import duckduckgo

# Create AutoAgents instance
agents = AutoAgents(
    instructions="Search for information about AI Agents",
    tools=[duckduckgo],
    process="sequential",
    
    max_agents=3  # Maximum number of agents to create
)

# Start the agents
result = agents.start()
print(result)
4

Start AutoAgents

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

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 17+ available tools.

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.
praisonai workflow auto "Research and write a blog post" --pattern sequential
Multiple agents work concurrently on independent subtasks.
praisonai workflow auto "Research from multiple sources" --pattern parallel
A classifier agent routes requests to specialized agents based on input type.
praisonai workflow auto "Handle different customer requests" --pattern routing
A central orchestrator dynamically delegates tasks to specialized workers.
praisonai workflow auto "Comprehensive market analysis" --pattern orchestrator-workers
One agent generates content, another evaluates it in a loop until quality criteria are met.
praisonai workflow auto "Write and refine a high-quality article" --pattern evaluator-optimizer
# Basic usage with default settings
agents = AutoAgents(
    instructions="Your high-level task description",
    tools=[tool1, tool2]
)

Advanced Usage

Configuration Options


# Create AutoAgents with advanced configuration
agents = AutoAgents(
    instructions="Research and summarize recent AI developments",
    tools=[SerperDevTool, WikipediaTools],
    max_agents=3,  # Maximum number of agents to create
      # Enable detailed logging
    process="hierarchical",  # Use hierarchical process
    memory=True,  # Enable memory for agents
    allow_delegation=True,  # Allow task delegation
    max_rpm=60,  # Maximum requests per minute
    max_execution_time=300,  # Maximum execution time in seconds
    allow_code_execution=True,  # Allow code execution
    code_execution_mode="safe",  # Use safe mode for code execution
    reflection=True,  # Enable agent self-reflection
      # Enable markdown formatting
)

Process Types

# Tasks are executed in sequence
agents = AutoAgents(
    instructions="Your task",
    process="sequential"
)
# Manager agent coordinates other agents
agents = AutoAgents(
    instructions="Your task",
    process="hierarchical",
    manager_llm="gpt-4o"  # Specify LLM for manager
)

Best Practices

# Good instruction example
agents = AutoAgents(
    instructions="""
    Research the latest developments in AI for 2024:
    1. Focus on breakthrough technologies
    2. Include real-world applications
    3. Consider future implications
    """
)
# Provide relevant tools for the task

agents = AutoAgents(
    instructions="Research task",
    tools=[
        SerperDevTool,  # For web search
        WikipediaTools,  # For background info
        CustomTool  # Your custom tool
    ]
)
# Configure resource limits
agents = AutoAgents(
    instructions="Your task",
    max_rpm=60,  # Rate limiting
    max_execution_time=300,  # Timeout
    max_agents=3  # Agent limit
)

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)

For programmatic control over agent generation:
from praisonai.auto import AutoGenerator, WorkflowAutoGenerator

# Generate agents.yaml
generator = AutoGenerator(
    topic="Research AI trends and write a report",
    agent_file="agents.yaml",
    framework="praisonai",  # or "crewai", "autogen"
    pattern="sequential",   # workflow pattern
    single_agent=False      # True for simple tasks
)
path = generator.generate(merge=False)

# Generate workflow.yaml
wf_generator = WorkflowAutoGenerator(
    topic="Build a customer support system",
    workflow_file="workflow.yaml",
    framework="praisonai"
)

# Get pattern recommendation (keyword-based, fast)
pattern = wf_generator.recommend_pattern()

# Get LLM-based recommendation with reasoning
recommendation = wf_generator.recommend_pattern_llm()
print(f"Pattern: {recommendation.pattern}")
print(f"Reasoning: {recommendation.reasoning}")
print(f"Confidence: {recommendation.confidence}")

# Generate with specific pattern
path = wf_generator.generate(pattern="routing", merge=False)

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

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"
Allow agents to delegate tasks

Methods

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

Next Steps

For optimal results, provide clear instructions and appropriate tools for your use case.