Multi-Agent Systems

How multiple agents can work together

Multiple agents working together can solve complex problems that one agent can’t handle alone.

Diagram

Multi-Agent Team

📋 Task

🔍 Researcher

📊 Analyst

✍️ Writer

✅ Result


Quick Start

python
from praisonaiagents import Agent, AgentTeam

# Create specialized agents
researcher = Agent(instructions="Research topics thoroughly")
writer = Agent(instructions="Write clear summaries")

# Combine into a team
team = AgentTeam(agents=[researcher, writer])
team.start()

Why Multiple Agents?


Workflow Patterns

Sequential (Pipeline)

Agents work one after another:

Diagram

Sequential

🔍 Research

📊 Analyze

✍️ Write

python
from praisonaiagents import Agent, AgentTeam

researcher = Agent(instructions="Research the topic")
analyst = Agent(instructions="Analyze the research")
writer = Agent(instructions="Write the final report")

team = AgentTeam(
    agents=[researcher, analyst, writer],
    process="sequential"  # One after another
)
team.start()

Parallel

Agents work at the same time:

Diagram

Parallel

📋 Task

🔍 Agent 1

📊 Agent 2

✍️ Agent 3

✅ Combined

Run agents at the same time by setting async_execution=True on each Task inside a workflow (or sequential) process, and start the team with await team.astart() — the sync team.start() runs them sequentially and warns:

python
import asyncio
from praisonaiagents import Agent, Task, AgentTeam

team = AgentTeam(
    agents=[agent1, agent2, agent3],
    tasks=[
        Task(description="First analysis", agent=agent1, async_execution=True),
        Task(description="Second analysis", agent=agent2, async_execution=True),
        Task(description="Third analysis", agent=agent3, async_execution=True),
    ],
    process="workflow"  # parallel fan-out via async_execution on tasks
)

asyncio.run(team.astart())   # async entry point — sync .start() would run sequentially and warn

Hierarchical

A manager delegates to workers:

Diagram

Hierarchical

👔 Manager

🤖 Worker 1

🤖 Worker 2

🤖 Worker 3

python
team = AgentTeam(
    agents=[manager, worker1, worker2],
    process="hierarchical"
)

Complete Example

python
from praisonaiagents import Agent, AgentTeam

# Research agent with web search
researcher = Agent(
    name="Researcher",
    instructions="Find the latest information on the topic",
    web=True  # Can search the web
)

# Analyst agent
analyst = Agent(
    name="Analyst",
    instructions="Analyze findings and identify key insights"
)

# Writer agent
writer = Agent(
    name="Writer",
    instructions="Create a clear, engaging summary"
)

# Create the team
team = AgentTeam(
    agents=[researcher, analyst, writer],
    process="sequential"
)

# Run the team
result = team.start("Research AI trends in 2025")
print(result)

Agent Communication

Agents share information automatically:

Diagram

Communication

Output

Output

🤖 Agent 1

🤖 Agent 2

🤖 Agent 3

MethodDescription
Output PassingOne agent’s result → next agent’s input
Shared MemoryAll agents access common memory
ContextAgents see what others have done

Best Practices

Start with 2-3 Agents

Don’t overcomplicate. Add more agents only when needed.

Clear Roles

Each agent should have one specific job.

Sequential First

Start with sequential, then try parallel if needed.

Test Each Agent

Make sure each agent works alone before combining.


Next: Agent Process

Learn about different workflow processes.