The run: Field
Use run: instead of prompt: to execute TypeScript:
run: block has access to:
input— the validated workflow input- Any upstream step outputs by their step id (e.g.,
analyze,research) executionId,attempt,iteration— execution metadata
Return Value
Therun: block must return an object matching the step’s output schema:
Async Code
run: blocks can use await:
The handler: Field
For complex logic, point to an exported function in a TypeScript file:
run: block:
When to Use Each
| Approach | Use When |
|---|---|
prompt: | The step calls a model. Most common. |
run: | Short computation, data transformation, simple API calls. |
handler: | Complex logic, Effect services, shared code, testing. |
Mixing Prompt and Code
A single step uses eitherprompt: or run:/handler:, not both. If you need to transform data before prompting, use two steps:
Accessing Effect Services
Handler functions have full access to the Effect ecosystem:Error Handling
Errors inrun: blocks follow the same retry and failure semantics as prompt steps: