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
Clear Task Descriptions
Clear Task Descriptions
Write precise, unambiguous task descriptions that clearly state the task’s purpose and requirements.
Success Criteria
Success Criteria
Define measurable success criteria to ensure task completion can be properly evaluated.
Task Dependencies
Task Dependencies
Specify any dependencies or prerequisites for the task.
Resource Management
Tool Selection
Tool Selection
Choose appropriate tools that match your task’s requirements.
Error Handling
Error Handling
Implement comprehensive error management strategies.
Resource Limits
Resource Limits
Set appropriate resource constraints for optimal performance.
Performance Monitoring
Performance Monitoring
Configure monitoring and logging for task execution.
Async Task Execution
Async Task Features
- Enable async execution with
async_execution=True
- Perfect for I/O-heavy operations
- Supports parallel task execution
- Enable async execution with
async_execution=True
- Perfect for I/O-heavy operations
- Supports parallel task execution
- Support for async callbacks
- Process results asynchronously
- Handle task completion events
- Mix sync and async tasks
- Flexible execution patterns
- Optimal resource utilization
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.