Usage
Tasks in Compozy are defined and configured using the following structure and patterns.
Structure
Tasks in Compozy follow a consistent structure that supports both simple operations and complex flow control. For detailed information about task types and their specific structures, see the Task Types documentation.
Task Types
Basic
Simple, single-operation tasks for API calls, transformations, and processing steps.
Parallel
Execute multiple operations simultaneously with configurable concurrency limits.
Decision
Route execution based on conditions with support for complex business logic.
Collection
Process arrays of items sequentially or in parallel with advanced execution patterns.
Wait
Pause execution until specific conditions are met or timeout occurs.
Map
Transform data between tasks with type-safe field mapping.
Composite
Group multiple operations into reusable units.
Event Handlers
Tasks support various event handlers to control flow and handle state transitions:
Error Handling & Recovery
Tasks support sophisticated error handling and recovery mechanisms:
Schema Definition
Schemas in Compozy use JSON Schema format to validate task inputs. Note that outputs are handled by the executed components (agents, MCPs, or tools):
Environment Variables
Configure task-specific settings and secrets:
Task Imports
Reuse and customize tasks from external files:
State Management
Tasks maintain state information that can be accessed in event handlers:
Memory Integration
Tasks can interact with workflow-level memory systems for state persistence and context management. First, define memory at the workflow level, then reference it in tasks:
Memory operations in tasks support:
- Reading from and writing to memory stores
- Semantic search across stored content
- Thread and conversation management
- Context windowing and retrieval
- Vector similarity search
- Memory persistence and cleanup
Best Practices
Task Design
- Choose appropriate task types for your needs
- Keep tasks focused and single-purpose
- Use parallel tasks judiciously
Configuration
- Set reasonable defaults for concurrent operations
- Use environment variables for sensitive data
- Document task requirements
Event Handling
- Implement appropriate handlers for critical events
- Use on_complete for cleanup operations
- Log important state transitions
Error Management
- Configure retries for transient failures
- Use conditional error routing
- Implement graceful degradation
State Management
- Monitor task state changes
- Implement appropriate logging
- Use state information for debugging
Recovery Strategies
- Configure appropriate retry policies
- Implement fallback mechanisms
- Handle partial failures in parallel tasks