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
| Property | Type | Description |
|---|---|---|
input | Any | Input data for this execution |
config | dict | Runtime configuration |
execution_id | str | Unique execution identifier |
parent_id | str | Parent 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
- WorkflowEnvelope - Understand durability
- Backends - Configure backends