Skip to main content

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

1

Task Design

  • Choose appropriate task types for your needs
  • Keep tasks focused and single-purpose
  • Use parallel tasks judiciously
2

Configuration

  • Set reasonable defaults for concurrent operations
  • Use environment variables for sensitive data
  • Document task requirements
3

Event Handling

  • Implement appropriate handlers for critical events
  • Use on_complete for cleanup operations
  • Log important state transitions
4

Error Management

  • Configure retries for transient failures
  • Use conditional error routing
  • Implement graceful degradation
5

State Management

  • Monitor task state changes
  • Implement appropriate logging
  • Use state information for debugging
6

Recovery Strategies

  • Configure appropriate retry policies
  • Implement fallback mechanisms
  • Handle partial failures in parallel tasks

Next Steps

Types

Learn about different task types and their use cases

Usage

Understand how to use tasks in your workflows

API reference

Review the task configuration API reference

Registry

Learn about publishing tasks to the registry