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

Three types of processes are implemented in PraisonAI:

Sequential Process

Linear task execution in a predefined order

Hierarchical Process

Manager-coordinated task execution with dynamic assignment

Workflow Process

Complex task flows with conditional execution and state management

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"]
        }
    }
}

Advanced Features

State Management

  • Task state tracking
  • Context preservation
  • Data flow control

Error Handling

  • Graceful failure recovery
  • Alternative path execution
  • Error reporting

Monitoring

  • Progress tracking
  • Performance metrics
  • Resource utilization

Integration

  • External system coordination
  • API synchronization
  • Event handling

Async Process Execution

All process types (sequential, workflow, hierarchical) support async execution through async generators. This enables efficient handling of async tasks and parallel processing.

Async Process Methods

  • asequential: Async version of sequential process
  • aworkflow: Async version of workflow process
  • ahierarchical: Async version of hierarchical process

Example Usage:

import asyncio
from praisonaiagents import Agent, Task, PraisonAIAgents

async def main():
    # Create agents and tasks
    agents = [async_agent1, async_agent2]
    tasks = [async_task1, async_task2]

    # Initialize PraisonAIAgents with async workflow
    agents = PraisonAIAgents(
        agents=agents,
        tasks=tasks,
        process="workflow"  # or "sequential" or "hierarchical"
    )

    # Start async execution
    result = await agents.astart()
    print(result)

# Run the async workflow
asyncio.run(main())

Async Process Features:

  • Parallel task execution in workflow
  • Async task delegation in hierarchical process
  • Non-blocking task execution
  • Efficient resource utilization
  • Mixed sync/async task support

Process-Specific Async Behavior:

  1. Sequential Process:

    • Tasks are executed in order
    • Async tasks don’t block other tasks
    • Maintains sequential order while allowing async execution
  2. Workflow Process:

    • Parallel execution of independent tasks
    • Async branching and merging
    • Dynamic task scheduling
  3. Hierarchical Process:

    • Async manager delegation
    • Parallel subtask execution
    • Dynamic task assignment

Was this page helpful?