Skip to main content

@workflow Decorator

The @workflow decorator defines multi-step execution flows. Workflows orchestrate decisions, tools, and other workflows.

Basic Usage

from waxell_sdk import agent, workflow

@agent(name="data-processor")
class DataProcessor:

@workflow
def process_data(self, ctx):
# Step 1: Validate input
validated = ctx.call(self.validate)

# Step 2: Transform data
transformed = ctx.call(self.transform, data=validated)

# Step 3: Store results
return ctx.call(self.store, data=transformed)

Execution Context

The ctx parameter provides access to the execution context:

@workflow
def my_workflow(self, ctx):
# Access input data
input_data = ctx.input

# Call other methods
result = ctx.call(self.other_method)

# Access configuration
config = ctx.config

return result

Durability

Workflows support checkpoint and resume for long-running operations:

@workflow(durable=True)
def long_running_workflow(self, ctx):
# Each ctx.call is a checkpoint
step1 = ctx.call(self.expensive_operation)

# If interrupted here, resumes from last checkpoint
step2 = ctx.call(self.another_operation)

return step2

Next Steps