<!-- source: https://deepwiki.com/MervinPraison/PraisonAI/2.4-task-system -->

# Task and Process Management

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

This document covers the task definition, execution orchestration, and process management capabilities within the PraisonAI framework. Task and process management handles how individual tasks are created, configured, executed, and coordinated into workflows across multiple AI agents.

For information about individual agent capabilities and configuration, see [Agent Architecture](/MervinPraison/PraisonAI/2.1-agent-class). For details about multi-agent coordination strategies, see [Multi-Agent Orchestration](/MervinPraison/PraisonAI/2.3-llm-integration).

## Task Definition and Structure

Tasks in PraisonAI are defined using the `Task` class, which encapsulates all the information needed to execute a specific unit of work. Tasks serve as the fundamental building blocks for agent workflows and can be configured with various execution parameters, output formats, and dependencies.

### Core Task Properties

The `Task` class supports a comprehensive set of configuration options:

### Task Output Formats

Tasks support multiple output formats to accommodate different use cases:

```

```

Sources: [src/praisonai-agents/praisonaiagents/task/task.py15-152](https://github.com/MervinPraison/PraisonAI/blob/ab80807b/src/praisonai-agents/praisonaiagents/task/task.py#L15-L152) [src/praisonai-agents/praisonaiagents/agents/agents.py745-775](https://github.com/MervinPraison/PraisonAI/blob/ab80807b/src/praisonai-agents/praisonaiagents/agents/agents.py#L745-L775)

### Task Status Lifecycle

Tasks progress through a defined status lifecycle managed by the execution system:

```

```

Sources: [src/praisonai-agents/praisonaiagents/agents/agents.py18-26](https://github.com/MervinPraison/PraisonAI/blob/ab80807b/src/praisonai-agents/praisonaiagents/agents/agents.py#L18-L26) [src/praisonai-agents/praisonaiagents/agents/agents.py780-840](https://github.com/MervinPraison/PraisonAI/blob/ab80807b/src/praisonai-agents/praisonaiagents/agents/agents.py#L780-L840)

## Process Execution Types

The `Process` class handles different execution flows for coordinating multiple tasks. Three primary process types are supported, each with distinct coordination patterns and use cases.

### Sequential Process

Sequential execution runs tasks in a linear order where each task completes before the next begins:

```

```

### Workflow Process

Workflow execution supports conditional branching and complex task dependencies:

```

```

### Hierarchical Process

Hierarchical execution uses a manager agent to dynamically route tasks based on execution context:

```

```

Sources: [src/praisonai-agents/praisonaiagents/process/process.py17-35](https://github.com/MervinPraison/PraisonAI/blob/ab80807b/src/praisonai-agents/praisonaiagents/process/process.py#L17-L35) [src/praisonai-agents/praisonaiagents/process/process.py360-554](https://github.com/MervinPraison/PraisonAI/blob/ab80807b/src/praisonai-agents/praisonaiagents/process/process.py#L360-L554) [src/praisonai-agents/praisonaiagents/process/process.py841-860](https://github.com/MervinPraison/PraisonAI/blob/ab80807b/src/praisonai-agents/praisonaiagents/process/process.py#L841-L860)

## Task Context and Dependencies

Context management enables tasks to access results from previous tasks and external data sources. The system supports multiple context types and flexible dependency resolution.

### Context Processing Pipeline

```

```

Sources: [src/praisonai-agents/praisonaiagents/agents/agents.py62-122](https://github.com/MervinPraison/PraisonAI/blob/ab80807b/src/praisonai-agents/praisonaiagents/agents/agents.py#L62-L122) [src/praisonai-agents/praisonaiagents/process/process.py147-202](https://github.com/MervinPraison/PraisonAI/blob/ab80807b/src/praisonai-agents/praisonaiagents/process/process.py#L147-L202)

### Dependency Resolution

Task dependencies are resolved through the `previous_tasks` and `next_tasks` relationships:

Sources: [src/praisonai-agents/praisonaiagents/task/task.py109-111](https://github.com/MervinPraison/PraisonAI/blob/ab80807b/src/praisonai-agents/praisonaiagents/task/task.py#L109-L111) [src/praisonai-agents/praisonaiagents/process/process.py364-372](https://github.com/MervinPraison/PraisonAI/blob/ab80807b/src/praisonai-agents/praisonaiagents/process/process.py#L364-L372)

## Task Execution and Orchestration

The `PraisonAIAgents` class orchestrates task execution across multiple agents with support for retry logic, quality management, and memory integration.

### Execution Flow Architecture

```

```

Sources: [src/praisonai-agents/praisonaiagents/agents/agents.py604-779](https://github.com/MervinPraison/PraisonAI/blob/ab80807b/src/praisonai-agents/praisonaiagents/agents/agents.py#L604-L779) [src/praisonai-agents/praisonaiagents/agents/agents.py123-260](https://github.com/MervinPraison/PraisonAI/blob/ab80807b/src/praisonai-agents/praisonaiagents/agents/agents.py#L123-L260)

### Retry and Validation Mechanisms

The system implements sophisticated retry logic with validation feedback:

```

```

Sources: [src/praisonai-agents/praisonaiagents/agents/agents.py790-840](https://github.com/MervinPraison/PraisonAI/blob/ab80807b/src/praisonai-agents/praisonaiagents/agents/agents.py#L790-L840) [src/praisonai-agents/praisonaiagents/process/process.py18-20](https://github.com/MervinPraison/PraisonAI/blob/ab80807b/src/praisonai-agents/praisonaiagents/process/process.py#L18-L20) [src/praisonai-agents/praisonaiagents/task/task.py91](https://github.com/MervinPraison/PraisonAI/blob/ab80807b/src/praisonai-agents/praisonaiagents/task/task.py#L91-L91)

## Advanced Task Types

PraisonAI supports specialized task types for complex workflows including decision-making and iterative processing.

### Decision Tasks

Decision tasks enable conditional workflow routing based on agent evaluation:

```

```

### Loop Tasks

Loop tasks enable iterative processing over datasets or repeated operations:

```

```

Sources: [src/praisonai-agents/praisonaiagents/task/task.py112-151](https://github.com/MervinPraison/PraisonAI/blob/ab80807b/src/praisonai-agents/praisonaiagents/task/task.py#L112-L151) [src/praisonai-agents/praisonaiagents/process/process.py60-146](https://github.com/MervinPraison/PraisonAI/blob/ab80807b/src/praisonai-agents/praisonaiagents/process/process.py#L60-L146)

## Memory and Quality Management

Task execution integrates with memory and quality management systems to ensure high-quality outputs and learning from previous executions.

### Task Callback Pipeline

```

```

Sources: [src/praisonai-agents/praisonaiagents/task/task.py252-421](https://github.com/MervinPraison/PraisonAI/blob/ab80807b/src/praisonai-agents/praisonaiagents/task/task.py#L252-L421) [src/praisonai-agents/praisonaiagents/memory/memory.py440-473](https://github.com/MervinPraison/PraisonAI/blob/ab80807b/src/praisonai-agents/praisonaiagents/memory/memory.py#L440-L473)

## AutoAgents Task Generation

The `AutoAgents` class provides automated task and agent creation based on natural language instructions, demonstrating advanced task generation capabilities.

### Automated Task Generation Flow

```

```

Sources: [src/praisonai-agents/praisonaiagents/agents/autoagents.py245-423](https://github.com/MervinPraison/PraisonAI/blob/ab80807b/src/praisonai-agents/praisonaiagents/agents/autoagents.py#L245-L423) [src/praisonai-agents/praisonaiagents/agents/autoagents.py424-488](https://github.com/MervinPraison/PraisonAI/blob/ab80807b/src/praisonai-agents/praisonaiagents/agents/autoagents.py#L424-L488)
