Tasks
Understanding Tasks in PraisonAI
Understanding Tasks
Tasks are units of work that agents execute. Each task has a clear goal, input requirements, and expected outputs.
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
Understanding Tasks
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
Getting Started
Install PraisonAI
Install the core package:
Create Agent
Create app.py
:
Best Practices
Design tasks to be atomic and focused. Each task should have a single, clear responsibility.
Task Design Principles
Resource Management
Async Task Execution
Async Task Features
- Enable async execution with
async_execution=True
- Perfect for I/O-heavy operations
- Supports parallel task execution
Pro Tip: Use async execution for tasks that involve I/O operations (like API calls or file operations) to improve overall performance. Keep CPU-intensive tasks synchronous.