Tasks
Understanding Tasks in PraisonAI
Tasks are the fundamental units of work in PraisonAI, defining what needs to be done, how it should be done, and who should do it.
Understanding Tasks
Task Definition
Description & Requirements
Agent Assignment
Matching & Delegation
Execution
Processing & Tools
Output
Results & Validation
Core Components
Task Definition
Clear description of work to be done and expected outputs
Agent Assignment
Matching tasks with capable agents
Tool Access
Resources available for task completion
Output Handling
Managing and formatting task results
Task Configuration
Task Types
Basic Task
Simple, single-operation tasks with clear inputs and outputs
Decision Task
Tasks involving choices and conditional paths
Loop Task
Repetitive operations over collections
Task Relationships
Properly managing task dependencies is crucial for complex workflows. Always ensure proper context sharing and error handling.
Context Sharing
Task Dependencies
Relationship | Description | Example |
---|---|---|
Sequential | Tasks run one after another | Research → Analysis → Report |
Parallel | Independent tasks run simultaneously | Data Collection + Processing |
Conditional | Tasks depend on previous results | Success → Next Task, Failure → Retry |
Advanced Features
Output Handling
- Multiple output formats
- Structured data validation
- File system integration
Task Control
- Execution flow control
- Error recovery
- Progress tracking
Best Practices
Design tasks to be atomic and focused. Each task should have a single, clear responsibility.
- Clear task descriptions
- Well-defined success criteria
- Appropriate tool selection
- Error handling consideration
- Resource management
Next Steps
Create Tasks
Learn how to create and configure tasks
Task API
Explore the complete Task API documentation
Async Task Execution
Tasks can be executed asynchronously by setting async_execution=True
. This is particularly useful for tasks that involve I/O operations or when you want to run multiple tasks in parallel.
Async Task Configuration
Async Callbacks
Tasks support both synchronous and asynchronous callbacks:
Mixing Sync and Async Tasks
You can mix synchronous and asynchronous tasks in the same workflow: