AutoAgents automatically creates and manages AI agents and tasks based on high-level instructions.

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.tools import duckduckgo

# Create AutoAgents instance
agents = AutoAgents(
    instructions="Search for information about AI Agents",
    tools=[duckduckgo],
    process="sequential",
    verbose=True,
    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:

  • Creates appropriate AI agents based on your instructions
  • Assigns relevant tools to each agent
  • Breaks down tasks into manageable steps
  • Manages execution flow between agents
  • Handles agent coordination and task delegation

Features

Automatic Agent Creation

Creates specialized agents based on task requirements.

Smart Tool Assignment

Automatically assigns relevant tools to each agent.

Task Management

Breaks down complex tasks into manageable steps.

Process Optimization

Chooses optimal execution process (sequential/hierarchical).

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
    verbose=True,  # 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
    self_reflect=True,  # Enable agent self-reflection
    markdown=True  # Enable markdown formatting
)

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

API Reference

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.

Was this page helpful?