Agent Process Types

Understanding Process Types in PraisonAI

Understanding Process Types

Process types in PraisonAI define how tasks are executed and how agents collaborate. Each process type offers different patterns for task execution and agent coordination.

Process Types Overview

Diagram

AgentFlow Patterns

🔀 route()

⚡ parallel()

🔁 loop()

AgentTeam Processes

➡️ sequential

👔 hierarchical

Sequential Process

Diagram

▶

🤖 Agent 1

🤖 Agent 2

🤖 Agent 3

✓

The simplest form of task execution where tasks are performed one after another.

Card

### Characteristics – Linear execution flow – Each task receives output from previous task – Predictable order – Simple dependency management

### Usage

python
from praisonaiagents import Agent, AgentTeam

agents = AgentTeam(
    agents=[agent1, agent2, agent3],
    tasks=[task1, task2, task3],
    process="sequential"  # Default
)
result = agents.start()

Hierarchical Process

Diagram

assign

assign

assign

report

report

report

▶

👔 Manager Agent

🤖 Worker 1

🤖 Worker 2

🤖 Worker 3

✓

Uses a manager LLM to coordinate task execution and agent assignments dynamically.

Card

### Characteristics – Manager-driven coordination using manager_llm – Dynamic task assignment to best-suited agents – Flexible execution order (manager decides) – Intelligent resource allocation

### Configuration

python
from praisonaiagents import Agent, Task, AgentTeam

agents = AgentTeam(
    agents=[researcher, writer, editor],
    tasks=[research_task, write_task, edit_task],
    process="hierarchical",
    manager_llm="gpt-4o"  # Required for hierarchical
)
result = agents.start()

### Error Recovery

Hierarchical processes include automatic error recovery mechanisms:

  1. Manager LLM parse failures retry up to 3 times with exponential backoff (2s, 4s, 8s). After 3 failures, the workflow stops and logs the final exception.
  2. Invalid task IDs are re-prompted — if the manager picks a task_id not in the workflow, the manager is asked again with the list of valid IDs (up to 3 attempts before aborting).
  3. Loop subtask file errors are now visible — failures to read a loop input file mark the task status="failed" and attach a TaskOutput with the error message instead of failing silently.
Diagram

Success

Parse Error

Yes

No

Yes

No

Yes

No

Manager Request

Parse Response

Execute Task

Retry < 3?

Exponential Backoff

❌ Stop Workflow

Valid Task ID?

✅ Task Executed

Reprompt < 3?

Re-ask Manager


Workflow Process (AgentFlow)

Diagram

route A

route B

▶

Step 1

Condition

Handler A

Handler B

Step 3

✓

Card

### Features – Sequential step execution (steps can be agents OR functions) – Conditional routing with route() – Parallel execution with parallel() – Loop iteration with loop(from_csv="file.csv") – Repeat until condition with repeat() – Callbacks and guardrails

### Implementation

python
from praisonaiagents import Agent, AgentFlow
from praisonaiagents import route, parallel, loop

researcher = Agent(instructions="Research topics")
writer = Agent(instructions="Write content")

# AgentFlow with agents as steps
flow = AgentFlow(
    steps=[
        researcher,
        route({
            "positive": [writer],
            "negative": [fallback_agent]
        })
    ]
)
result = flow.start("Research AI trends")

AgentFlow Patterns

Diagram

🔁 loop()

repeat

done

Step

Check

Done

🔀 route()

Condition

Step A

Step B

⚡ parallel()

Step

Step

Step

Sequential

Step

Step

Step

Getting Started

  1. Install PraisonAI

    Install the core package:

    Terminal
    pip install praisonaiagents
  2. Configure Environment
    Terminal
    export OPENAI_API_KEY=your_openai_key

    Generate your OpenAI API key from OpenAI Use other LLM providers like Ollama, Anthropic, Groq, Google, etc. Please refer to the Models for more information.

  3. Create Agent

    Create app.py:

    Single Agent Sequential Process
    from praisonaiagents import Agent, Task, AgentTeam
    
    # Create an agent
    researcher = Agent(
        name="Researcher",
        role="Senior Research Analyst",
        goal="Uncover cutting-edge developments in AI",
        backstory="You are an expert at a technology research group",
    
        llm="gpt-4o"
    )
    
    # Define a task
    task = Task(
        name="research_task",
        description="Analyze 2024's AI advancements",
        expected_output="A detailed report",
        agent=researcher
    )
    
    # Run the agents
    agents = AgentTeam(
        agents=[researcher],
        tasks=[task],
        output="silent",
        process="sequential"
    )
    
    result = agents.start()
    Multiple Agents Hierarchical Process
    from praisonaiagents import Agent, Task, AgentTeam
    
    # Create multiple agents 
    researcher = Agent(
        name="Researcher",
        role="Senior Research Analyst",
        goal="Uncover cutting-edge developments in AI",
        backstory="You are an expert at a technology research group",
    
        llm="gpt-4o",
    
    )
    
    writer = Agent(
        name="Writer",
        role="Tech Content Strategist",
        goal="Craft compelling content on tech advancements",
        backstory="You are a content strategist",
        llm="gpt-4o",
    
    )
    
    # Define multiple tasks
    task1 = Task(
        name="research_task",
        description="Analyze 2024's AI advancements",
        expected_output="A detailed report",
        agent=researcher
    )
    
    task2 = Task(
        name="writing_task",
        description="Create a blog post about AI advancements",
        expected_output="A blog post",
        agent=writer
    )
    
    # Run with hierarchical process
    agents = AgentTeam(
        agents=[researcher, writer],
        tasks=[task1, task2],
        output="silent",
        process="hierarchical",
        manager_llm="gpt-4o"
    )
    
    result = agents.start()



Advanced Features

Async Processing

Core Async Methods

Process-Specific Features

Key Benefits