Mini Agents

Run multi-step workflows in a few lines with one Agent per role, coordinated by AgentTeam

Mini agents run multi-step workflows in a few lines — one Agent per role, coordinated by AgentTeam.

python
from praisonaiagents import Agent, AgentTeam

researcher = Agent(name="Researcher", instructions="Research topics briefly.")
writer = Agent(name="Writer", instructions="Summarise findings.")
team = AgentTeam(agents=[researcher, writer])
team.start("Research and summarise quantum computing.")

The user describes a goal; the team runs each agent in sequence and returns a combined result.

Diagram

👤 User

AgentTeam

🔍 Research Agent

📝 Summary Agent

How It Works

Diagram
Mini AgentsAgentUserMini AgentsAgentUserRequestProcess requestResult Agent–>>User: Response

Quick Start

Create multiple AI agents that can work together in just a few lines of code!

Code

  1. Install Package

    First, install the PraisonAI Agents package:

    bash
    pip install praisonaiagents duckduckgo_search
  2. Set API Key

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

    bash
    export OPENAI_API_KEY="${OPENAI_API_KEY:?Set OPENAI_API_KEY in your shell}"
  3. Create Your Agents
    Single Agent
    from praisonaiagents import Agent, AgentTeam
    summarise_agent = Agent(instructions="Summarise Photosynthesis")
    agents = AgentTeam(agents=[summarise_agent])
    agents.start()
    Multiple Agents
    # Agent with Internet Search Tool
    from praisonaiagents import Agent, AgentTeam
    research_agent = Agent(instructions="Research about AI 2024", tools=[Tools.internet_search])
    summarise_agent = Agent(instructions="Summarise research agent's findings")
    agents = AgentTeam(agents=[research_agent, summarise_agent])
    agents.start()
  4. Run Your Agents

    Execute your agents by running:

    bash
    python app.py

No Code

  1. Install Package

    First, install the PraisonAI Agents package:

    bash
    pip install praisonaiagents duckduckgo_search
  2. Set API Key

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

    bash
    export OPENAI_API_KEY="${OPENAI_API_KEY:?Set OPENAI_API_KEY in your shell}"
  3. Create Your Agents
    Single Agent
    # Create a new file `agents.yaml` with the following content:
    agents:  # Canonical
      summarise_agent
        instructions: Summarise Photosynthesis
    Multiple Agents
    # Create a new file `agents.yaml` with the following content:
    # Agent with Internet Search Tool
    agents:  # Canonical
      research_agent
        instructions: Research about AI 2024
        tools:
          - internet_search
      summarise_agent
        instructions: Summarise research agent's findings
  4. Run Your Agents

    Execute your agents by running:

    bash
    python app.py


Understanding Mini AI Agents

What are Mini AI Agents?

Mini AI Agents are simplified yet powerful AI agents that can: – Work together to accomplish tasks – Use tools like internet search – Process and summarize information – Execute tasks sequentially

Key Components

Available Tools

Custom Instructions

Basic
# Simple instructions
research_agent = Agent(
    instructions="Research about climate change"
)
Advanced
# Detailed instructions
research_agent = Agent(
    instructions="""
    You are a research agent focused on gathering information about:
    1. Latest AI developments in 2024
    2. Major breakthroughs in machine learning
    3. New AI applications in industry

    Provide detailed and accurate information from reliable sources.
    """
)

Best Practices

Agent Instructions

Write clear and specific instructions:

python
# Good
Agent(instructions="Research and analyze the latest AI developments in 2024")

# Too vague
Agent(instructions="Research AI")
Tool Usage

Provide tools only to agents that need them:

python
# Research agent needs search
research_agent = Agent(
    instructions="Research AI",
    tools=[Tools.internet_search]
)

# Summary agent doesn't need search
summary_agent = Agent(
    instructions="Summarize findings"
)

Common Patterns

Research and Analysis

python
# Research agent
researcher = Agent(
    instructions="Research latest developments in quantum computing",
    tools=[Tools.internet_search]
)

# Analysis agent
analyst = Agent(
    instructions="Analyze and explain the research findings in simple terms"
)

agents = AgentTeam(agents=[researcher, analyst])

Information Processing

python
# Data collector
collector = Agent(
    instructions="Collect information about renewable energy",
    tools=[Tools.internet_search]
)

# Summarizer
summarizer = Agent(
    instructions="Create a concise summary of the collected information"
)

# Report writer
writer = Agent(
    instructions="Write a detailed report based on the summary"
)

agents = AgentTeam(agents=[collector, summarizer, writer])

Troubleshooting

Next Steps

Related