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

Sequential Process

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

Characteristics

  • Linear execution flow
  • Predictable order
  • Simple dependency management
  • Direct task progression

Usage

agents = PraisonAIAgents(
    agents=[agent1, agent2],
    tasks=[task1, task2, task3],
    process="sequential"
)

Hierarchical Process

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

Characteristics

  • Manager-driven coordination
  • Dynamic task assignment
  • Flexible execution order
  • Intelligent resource allocation

Configuration

agents = PraisonAIAgents(
    agents=[manager_agent, worker_agent1, worker_agent2],
    tasks=[task1, task2],
    process="hierarchical",
    manager_llm="gpt-4o"
)

Workflow Process

Advanced process type supporting complex task relationships and conditional execution.

Features

  • Task dependencies
  • Conditional branching
  • Loop handling
  • Context sharing
  • State management

Implementation

task_workflow = {
    "start_task": {
        "next": ["decision_task"],
        "type": "task"
    },
    "decision_task": {
        "type": "decision",
        "conditions": {
            "success": ["process_task"],
            "failure": ["error_task"]
        }
    }
}

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:




Advanced Features

State Management

Error Handling

Monitoring

Integration

Async Processing

All process types support asynchronous execution through async generators, enabling efficient parallel processing and non-blocking operations.

Core Async Methods

asequential

Async version of sequential process for non-blocking linear execution

aworkflow

Async workflow process for complex parallel task execution

ahierarchical

Async hierarchical process for distributed task management

Process-Specific Features

  • Tasks execute in order but don’t block
  • Maintains sequence while allowing async operations
  • Perfect for I/O-heavy tasks
async def main():
    agents = PraisonAIAgents(
        process="sequential",
        async_mode=True
    )
    await agents.astart()

Key Benefits

Performance

  • Efficient resource utilization
  • Reduced waiting time
  • Better throughput

Flexibility

  • Mix sync and async tasks
  • Adaptable execution patterns
  • Easy scaling

Was this page helpful?