Basic Structure
Tasks in workflows follow a consistent structure and can be defined in three ways:
Inline Tasks
Root-level Tasks
External Tasks
workflow :
tasks :
- id : send_notification
type : basic
use : compozy/tools:notification@1.0.0
with :
message : "{{ tasks.process_data.output }}"
on_success :
next : cleanup
Key Elements
Tasks The actual work to be performed - see Task Types
Flow Control How tasks connect and interact with each other
Basic Workflow Patterns
Sequential Processing
Create linear workflows where tasks execute one after another:
workflow :
tasks :
- id : fetch_data
type : basic
use : compozy/tools:api-fetch@1.0.0
schema :
input :
type : object
properties :
url : string
with :
url : "{{ env.API_URL }}"
on_success :
next : process_data
- id : process_data
type : basic
use : compozy/tools:data-transform@1.0.0
with :
data : "{{ tasks.fetch_data.output }}"
on_success :
next : save_results
retry :
attempts : 3
backoff : exponential
interval : 1s
Conditional Logic
Add decision points to your workflow using decision tasks:
workflow :
tasks :
- id : check_data
type : decision
condition : "{{ tasks.validate_input.output.is_valid }}"
routes :
"true" : process_valid
"false" : handle_invalid
on_condition_match :
next : log_decision
- id : process_valid
type : basic
use : compozy/tools:data-processor@1.0.0
on_error :
next : handle_error
- id : handle_invalid
type : basic
use : compozy/tools:error-handler@1.0.0
Parallel Processing
Execute tasks concurrently using parallel tasks:
workflow :
tasks :
- id : process_batch
type : parallel
config :
max_concurrent : 3
fail_fast : false
execute :
- use : compozy/tools:processor-1@1.0.0
retry :
attempts : 3
- use : compozy/tools:processor-2@1.0.0
retry :
attempts : 2
on_error :
next : handle_batch_error
Composability
Break down workflows into reusable components:
# tasks/shared.yaml
tasks :
- id : document_processor
type : basic
use : compozy/tools:doc-processor@1.0.0
schema :
input :
type : object
properties :
format :
type : string
enum : [ pdf , docx ]
with :
format : pdf
# workflow.yaml
workflow :
tasks :
- id : process_document
import : ./tasks/shared.yaml
with :
document : "{{ trigger.document }}"
on_success :
next : notify_complete
Memory Integration
Workflows can reference memory systems defined in the base configuration:
workflow :
memory : chat_memory # Reference to memory defined in base config
tasks :
- id : chat_task
type : basic
use : compozy/tools:chat-processor@1.0.0
with :
context : "{{ memory.chat_memory.current_thread }}"
history : "{{ memory.chat_memory.last_messages }}"
relevant : "{{ memory.chat_memory.semantic_search }}"
Best Practices
Task Design
Keep tasks focused and single-purpose
Use appropriate task types
Define clear input/output schemas
Error Handling
Configure retry policies
Implement fallback mechanisms
Use error routing effectively
Performance
Use parallel tasks when possible
Configure appropriate concurrency
Implement efficient batching
Maintainability
Break down complex workflows
Use schema validation
Document task requirements
References