Basic Usage
Import a workflow and call it like a regular async function:workflow.ts
enrich_company fails and retries, it doesn’t affect the parent’s execution history.
Invocation Patterns
Configuration Options
The second argument to a child workflow invocation is a configuration object:Activity Options Override
Options set on a child workflow invocation apply to all steps within that child workflow branch. Steps can still override these with their ownoptions.activityOptions property.
- Output’s default activity options
- The child workflow’s
options.activityOptions - Activity options inherited from the parent workflow
- The
activityOptionspassed to this child workflow invocation - The called step’s own
options.activityOptions
Lifecycle
When you call a child workflow, you have three choices: wait for it, fire it off and forget about it, or start it without waiting but let it die if the parent dies. Here’s the breakdown:Attached (Awaited)
The parent waits for the child to finish before continuing. If the parent is terminated, the child is terminated too:When using
await, the detached flag has no effect since the parent waits for the child to complete.Detached (Fire-and-Forget)
The parent doesn’t wait, and the child keeps running even if the parent terminates. Use this for things like sending notifications or logging — work that should finish regardless of what happens to the parent:Not Awaited (Attached)
The parent doesn’t wait, but the child is terminated if the parent terminates. Use this when you want to kick off work in parallel but don’t need the result:When to Use Child Workflows
Use child workflows when:- You have a reusable pipeline called from multiple places (e.g.
enrich_companycalled from bothlead_pipelineandaccount_research) - You want independent retry boundaries — a failing child doesn’t blow up the parent’s execution history
- A sub-task should outlive the parent (detached mode for notifications, webhooks)
- You’re organizing a large system into smaller, independently testable units
- You just need to reuse a step — import the step directly
- The logic is tightly coupled to the parent and doesn’t make sense on its own
Examples
Parallel Child Workflows
Enrich multiple companies at once by running child workflows in parallel:workflow.ts
Fire-and-Forget Notification
Process an order and send a notification without blocking:workflow.ts