context.run() executes a piece of custom business logic as a workflow step.
It returns a Promise, so you can decide how steps execute:
- Sequentially by awaiting them one by one.
- In parallel by awaiting multiple steps together.
Arguments
string
A unique identifier for the step.
function
The business logic to run inside this step.
object
Flow control and retry configuration for this step only. Fields left unset fall back to the
configuration the run was triggered with.See step-level flow control and
retries for details.
Response
Each step can return a JSON-serializable value—anything from simple primitives to complex objects. The value is JSON-serialized and automatically restored across requests.Usage
Because results are JSON-serialized, class instances are restored as plain objects.
This means instance methods will not be available unless you explicitly rehydrate the object.To fix this, you can recreate the instance using Object.assign() or a custom factory: