<!-- source: https://deepwiki.com/MervinPraison/PraisonAI/3.2-process-strategies -->

# Process Strategies

- README.md
- src/praisonai-agents/praisonaiagents/agents/agents.py
- src/praisonai/README.md

## Purpose and Scope

This document describes the four execution strategies available in PraisonAI for coordinating multi-agent task execution: **sequential**, **parallel**, **hierarchical**, and **workflow**. Each strategy determines how tasks are distributed across agents, when they execute, and how results flow between them.

For advanced workflow patterns (routing, loops, conditionals) within the workflow process type, see [Workflow System](/MervinPraison/PraisonAI/3.1-workflow-system). For planning-based execution, see [Planning System](/MervinPraison/PraisonAI/3.3-planning-system).

## Overview of Process Types

PraisonAI's `AgentTeam` class supports four process strategies, configured via the `process` parameter:

The process type is set during `AgentTeam` initialization and determines which execution method is invoked in the `Process` class.

**Sources:** [README.md2368-2445](https://github.com/MervinPraison/PraisonAI/blob/ab80807b/README.md?plain=1#L2368-L2445) [src/praisonai-agents/praisonaiagents/agents/agents.py200-429](https://github.com/MervinPraison/PraisonAI/blob/ab80807b/src/praisonai-agents/praisonaiagents/agents/agents.py#L200-L429)

## Process Type Configuration

### AgentTeam Initialization

```

```

The `process` parameter defaults to `"sequential"` if not specified. The value is stored in `self.process` and used by `run_all_tasks()` or `arun_all_tasks()` to invoke the appropriate execution method.

**Sources:** [src/praisonai-agents/praisonaiagents/agents/agents.py200-429](https://github.com/MervinPraison/PraisonAI/blob/ab80807b/src/praisonai-agents/praisonaiagents/agents/agents.py#L200-L429) [src/praisonai-agents/praisonaiagents/agents/agents.py1177-1197](https://github.com/MervinPraison/PraisonAI/blob/ab80807b/src/praisonai-agents/praisonaiagents/agents/agents.py#L1177-L1197)

## Sequential Process

### Overview

Sequential execution runs tasks one after another in order. Each task has access to the results of previous tasks via automatic context passing. This is the default process type and is ideal for linear workflows where each step depends on the previous one.

### Task Flow Setup

When tasks are added to `AgentTeam` with `process="sequential"`, the framework automatically establishes the sequential flow:

```

```

This setup occurs in the `AgentTeam.__init__()` method when the sequential process is detected:

**Sources:** [src/praisonai-agents/praisonaiagents/agents/agents.py476-482](https://github.com/MervinPraison/PraisonAI/blob/ab80807b/src/praisonai-agents/praisonaiagents/agents/agents.py#L476-L482)

### Execution Flow

The sequential execution iterates through tasks in order, waiting for each to complete before starting the next:

```

```

**Sources:** [src/praisonai-agents/praisonaiagents/agents/agents.py1190-1192](https://github.com/MervinPraison/PraisonAI/blob/ab80807b/src/praisonai-agents/praisonaiagents/agents/agents.py#L1190-L1192) [src/praisonai-agents/praisonaiagents/agents/agents.py849-863](https://github.com/MervinPraison/PraisonAI/blob/ab80807b/src/praisonai-agents/praisonaiagents/agents/agents.py#L849-L863)

### Context Passing

Results from previous tasks are automatically added to subsequent tasks' context via the `context` field. The `process_task_context()` helper function extracts results from completed tasks:

**Key behavior:**

- Only includes results from tasks with status="completed"
- Extracts task.result.raw content
- Filters out empty or failed tasks

**Sources:** [src/praisonai-agents/praisonaiagents/agents/agents.py111-170](https://github.com/MervinPraison/PraisonAI/blob/ab80807b/src/praisonai-agents/praisonaiagents/agents/agents.py#L111-L170) [src/praisonai-agents/praisonaiagents/agents/agents.py983-1001](https://github.com/MervinPraison/PraisonAI/blob/ab80807b/src/praisonai-agents/praisonaiagents/agents/agents.py#L983-L1001)

### Configuration Example

```

```

**Sources:** [README.md536-551](https://github.com/MervinPraison/PraisonAI/blob/ab80807b/README.md?plain=1#L536-L551) [src/praisonai/README.md536-551](https://github.com/MervinPraison/PraisonAI/blob/ab80807b/src/praisonai/README.md?plain=1#L536-L551)

## Parallel Process

### Overview

Parallel execution runs multiple tasks concurrently, maximizing throughput when tasks are independent. Tasks do not wait for each other and execute simultaneously based on available resources.

### Execution Model

Unlike sequential, parallel execution starts all tasks at once without dependencies:

```

```

**Sources:** [README.md2368-2445](https://github.com/MervinPraison/PraisonAI/blob/ab80807b/README.md?plain=1#L2368-L2445)

### Async Execution Support

Parallel execution supports both synchronous and asynchronous tasks. The `arun_all_tasks()` method handles mixed execution modes:

**Key implementation details:**

- Async tasks are collected in async_tasks_to_run list
- Sync tasks trigger a flush of pending async tasks
- asyncio.gather() executes async tasks concurrently
- Sync tasks run in executor to avoid blocking

**Sources:** [src/praisonai-agents/praisonaiagents/agents/agents.py839-863](https://github.com/MervinPraison/PraisonAI/blob/ab80807b/src/praisonai-agents/praisonaiagents/agents/agents.py#L839-L863)

### Use Cases

Parallel execution is optimal when:

- Tasks are independent (no sequential dependencies)
- Speed is critical (leverage concurrency)
- Multiple agents can work simultaneously
- Results can be aggregated after completion

**Example:** Multiple research agents gathering data from different sources, then a single aggregator combines results.

**Sources:** [README.md830-838](https://github.com/MervinPraison/PraisonAI/blob/ab80807b/README.md?plain=1#L830-L838)

## Hierarchical Process

### Overview

Hierarchical execution uses a manager agent to coordinate worker agents. The manager receives the initial request, breaks it into subtasks, delegates to workers, and synthesizes the final result. This enables dynamic task creation and complex coordination.

### Architecture

```

```

**Sources:** [README.md2368-2445](https://github.com/MervinPraison/PraisonAI/blob/ab80807b/README.md?plain=1#L2368-L2445)

### Manager Agent Configuration

The manager agent is configured via the `manager_llm` parameter, which defaults to the `OPENAI_MODEL_NAME` environment variable or `"gpt-4o-mini"`:

**Sources:** [src/praisonai-agents/praisonaiagents/agents/agents.py439-440](https://github.com/MervinPraison/PraisonAI/blob/ab80807b/src/praisonai-agents/praisonaiagents/agents/agents.py#L439-L440)

### Dynamic Task Creation

In hierarchical mode, the `Process.hierarchical()` method can yield new `Task` objects dynamically. The `AgentTeam` detects this and adds them to the task registry:

```

```

**Sources:** [src/praisonai-agents/praisonaiagents/agents/agents.py1193-1197](https://github.com/MervinPraison/PraisonAI/blob/ab80807b/src/praisonai-agents/praisonaiagents/agents/agents.py#L1193-L1197) [src/praisonai-agents/praisonaiagents/agents/agents.py864-876](https://github.com/MervinPraison/PraisonAI/blob/ab80807b/src/praisonai-agents/praisonaiagents/agents/agents.py#L864-L876)

### Execution Flow

```

```

**Sources:** [src/praisonai-agents/praisonaiagents/agents/agents.py1193-1197](https://github.com/MervinPraison/PraisonAI/blob/ab80807b/src/praisonai-agents/praisonaiagents/agents/agents.py#L1193-L1197)

## Workflow Process

### Overview

Workflow process enables advanced control flow patterns including routing, parallel execution, loops, and conditionals. Unlike the simple parallel/sequential models, workflow allows complex decision trees and iteration.

### Relation to Workflow System

The `process="workflow"` setting activates the workflow execution engine. For detailed documentation on workflow patterns (`route()`, `parallel()`, `loop()`, `repeat()`), see [Workflow System](/MervinPraison/PraisonAI/3.1-workflow-system).

**Key distinction:**

- Process type determines the execution engine used
- Workflow patterns define the control flow within that engine

**Sources:** [README.md811-877](https://github.com/MervinPraison/PraisonAI/blob/ab80807b/README.md?plain=1#L811-L877)

### Workflow Execution

The workflow process uses the `Process.workflow()` or `Process.aworkflow()` generator to yield tasks in the order determined by workflow control structures:

```

```

**Sources:** [src/praisonai-agents/praisonaiagents/agents/agents.py1187-1189](https://github.com/MervinPraison/PraisonAI/blob/ab80807b/src/praisonai-agents/praisonaiagents/agents/agents.py#L1187-L1189) [src/praisonai-agents/praisonaiagents/agents/agents.py819-837](https://github.com/MervinPraison/PraisonAI/blob/ab80807b/src/praisonai-agents/praisonaiagents/agents/agents.py#L819-L837)

### Workflow Patterns

```

```

**Workflow patterns enable:**

- Routing: Classifier agent routes to specialist agents
- Parallel: Multiple agents work concurrently on different subtasks
- Loop: Agent processes each item in a list
- Repeat: Evaluator-optimizer pattern for iterative refinement

**Sources:** [README.md811-877](https://github.com/MervinPraison/PraisonAI/blob/ab80807b/README.md?plain=1#L811-L877) [README.md1369-1405](https://github.com/MervinPraison/PraisonAI/blob/ab80807b/README.md?plain=1#L1369-L1405)

### Configuration Example

```

```

**Sources:** [README.md1342-1405](https://github.com/MervinPraison/PraisonAI/blob/ab80807b/README.md?plain=1#L1342-L1405)

## Process Execution Implementation

### Process Class Integration

The `Process` class (imported from `praisonaiagents.process.process`) encapsulates the execution logic for each process type. `AgentTeam` creates a `Process` instance and invokes the appropriate method:

```

```

**Process initialization:**

```

```

**Sources:** [src/praisonai-agents/praisonaiagents/agents/agents.py1179-1197](https://github.com/MervinPraison/PraisonAI/blob/ab80807b/src/praisonai-agents/praisonaiagents/agents/agents.py#L1179-L1197) [src/praisonai-agents/praisonaiagents/agents/agents.py811-876](https://github.com/MervinPraison/PraisonAI/blob/ab80807b/src/praisonai-agents/praisonaiagents/agents/agents.py#L811-L876)

### Task Status Management

Task status is tracked via the `TaskStatus` enum and the `task.status` attribute:

The status determines whether a task's results are included in subsequent tasks' context.

**Sources:** [src/praisonai-agents/praisonaiagents/agents/agents.py22-28](https://github.com/MervinPraison/PraisonAI/blob/ab80807b/src/praisonai-agents/praisonaiagents/agents/agents.py#L22-L28) [src/praisonai-agents/praisonaiagents/agents/agents.py473](https://github.com/MervinPraison/PraisonAI/blob/ab80807b/src/praisonai-agents/praisonaiagents/agents/agents.py#L473-L473)

### Async vs Sync Execution

Both `run_all_tasks()` (sync) and `arun_all_tasks()` (async) support all process types. The async version uses `asyncio.gather()` for concurrent execution and `loop.run_in_executor()` for sync tasks:

**Key pattern for mixed async/sync:**

```

```

**Sources:** [src/praisonai-agents/praisonaiagents/agents/agents.py839-863](https://github.com/MervinPraison/PraisonAI/blob/ab80807b/src/praisonai-agents/praisonaiagents/agents/agents.py#L839-L863)

## Process Selection Guidelines

### Decision Matrix

### Configuration Trade-offs

**Sequential:**

- ok Simple configuration
- ok Automatic context passing
- x Slower for independent tasks
- x No concurrency

**Parallel:**

- ok Maximum speed for independent tasks
- ok Simple concurrent execution
- x No automatic dependencies
- x Manual result aggregation

**Hierarchical:**

- ok Dynamic task creation
- ok Intelligent coordination
- x Manager overhead
- x More complex debugging

**Workflow:**

- ok Maximum flexibility
- ok Advanced patterns
- x More complex configuration
- x Steeper learning curve

**Sources:** [README.md2368-2445](https://github.com/MervinPraison/PraisonAI/blob/ab80807b/README.md?plain=1#L2368-L2445)

## Related Configuration

### Variables and Context

All process types support variable substitution and context management:

- Variables: Global variables set via AgentTeam(variables={...}) are applied to all tasks
- Context: Task context can include strings, lists, Task objects, or knowledge base queries

**Sources:** [src/praisonai-agents/praisonaiagents/agents/agents.py436](https://github.com/MervinPraison/PraisonAI/blob/ab80807b/src/praisonai-agents/praisonaiagents/agents/agents.py#L436-L436) [src/praisonai-agents/praisonaiagents/agents/agents.py1114-1116](https://github.com/MervinPraison/PraisonAI/blob/ab80807b/src/praisonai-agents/praisonaiagents/agents/agents.py#L1114-L1116)

### Callbacks

Process execution supports callbacks at the task level:

- on_task_start : Invoked before task execution
- on_task_complete : Invoked after successful completion

**Sources:** [src/praisonai-agents/praisonaiagents/agents/agents.py434-435](https://github.com/MervinPraison/PraisonAI/blob/ab80807b/src/praisonai-agents/praisonaiagents/agents/agents.py#L434-L435) [src/praisonai-agents/praisonaiagents/agents/agents.py1107-1156](https://github.com/MervinPraison/PraisonAI/blob/ab80807b/src/praisonai-agents/praisonaiagents/agents/agents.py#L1107-L1156)

### Verbose Output

The `verbose` parameter controls logging levels during process execution. Higher values provide more detailed execution traces:

**Sources:** [src/praisonai-agents/praisonaiagents/agents/agents.py441-453](https://github.com/MervinPraison/PraisonAI/blob/ab80807b/src/praisonai-agents/praisonaiagents/agents/agents.py#L441-L453)
