Agent Process

Understanding agent workflows and processes

Process defines how agents work together – the order, flow, and coordination of tasks.

Diagram

Process Types

📋 Sequential
One by one

⚡ Parallel
All at once

👔 Hierarchical
Manager + workers


Quick Start

python
from praisonaiagents import Agent, AgentTeam

researcher = Agent(instructions="Research the topic")
writer = Agent(instructions="Write the content")

team = AgentTeam(
    agents=[researcher, writer],
    process="sequential"  # Options: sequential, workflow, hierarchical
)
team.start()

Process Types

Sequential

Agents work one after another:

Diagram

Sequential Process

🔍 Research

📊 Analyze

✍️ Write

✅ Done

python
team = AgentTeam(
    agents=[researcher, analyst, writer],
    process="sequential"
)

Parallel

Agents work at the same time:

Diagram

Parallel Process

📋 Task

🤖 Agent 1

🤖 Agent 2

🤖 Agent 3

✅ Combined

Set async_execution=True on each Task inside a workflow (or sequential) process to fan out work in parallel:

python
import asyncio
from praisonaiagents import Agent, Task, PraisonAIAgents

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

# Use the async entry point — sync .start() runs these sequentially and warns
asyncio.run(team.astart())

Hierarchical

A manager coordinates workers:

Diagram

Hierarchical Process

👔 Manager

🤖 Worker 1

🤖 Worker 2

✅ Result

python
manager = Agent(instructions="Coordinate the team")
worker1 = Agent(instructions="Handle research")
worker2 = Agent(instructions="Handle writing")

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

Complete Example

python
from praisonaiagents import Agent, AgentTeam

# Create specialized agents
researcher = Agent(
    name="Researcher",
    instructions="Research topics and gather facts",
    web=True
)

analyst = Agent(
    name="Analyst", 
    instructions="Analyze data and find insights"
)

writer = Agent(
    name="Writer",
    instructions="Write clear, engaging content"
)

# Sequential process - research → analyze → write
team = AgentTeam(
    agents=[researcher, analyst, writer],
    process="sequential",
    output="verbose"  # See what's happening
)

result = team.start("Create a report on AI trends")

Choosing a Process

ProcessWhen to UseExample
SequentialSteps depend on each otherResearch → Write → Edit
Parallel (via async_execution=True tasks, async entry point required)Independent tasksAnalyze 3 different topics
HierarchicalNeed coordinationManager assigns tasks

Best Practices


Next: Knowledge Bases

Learn how to give agents access to documents and data.