Skip to main content

ExecutionContext

The ExecutionContext manages pure execution state during workflow runs. It provides access to input, configuration, and method invocation.

Accessing Context

Context is passed to all decorated methods:

@workflow
def my_workflow(self, ctx):
# ctx is the ExecutionContext
input_data = ctx.input
config = ctx.config

result = ctx.call(self.next_step)
return result

Context Properties

PropertyTypeDescription
inputAnyInput data for this execution
configdictRuntime configuration
execution_idstrUnique execution identifier
parent_idstrParent execution ID (if nested)

Method Invocation

Use ctx.call() to invoke other methods:

@workflow
def process(self, ctx):
# Call a decision
classification = ctx.call(self.classify)

# Call with parameters
result = ctx.call(self.transform, data=ctx.input)

# Chain calls
final = ctx.call(self.finalize, result=result)

return final

LLM Access

Access the LLM through the context:

@decision
def analyze(self, ctx):
response = ctx.llm.generate(
prompt=f"Analyze: {ctx.input}",
max_tokens=500
)
return response

Next Steps