惯性聚合 高效追踪和阅读你感兴趣的博客、新闻、科技资讯
阅读原文 在惯性聚合中打开

推荐订阅源

U
Unit 42
S
Security Affairs
Engineering at Meta
Engineering at Meta
MongoDB | Blog
MongoDB | Blog
Microsoft Security Blog
Microsoft Security Blog
让小产品的独立变现更简单 - ezindie.com
让小产品的独立变现更简单 - ezindie.com
美团技术团队
月光博客
月光博客
Cyber Security Advisories - MS-ISAC
Cyber Security Advisories - MS-ISAC
有赞技术团队
有赞技术团队
博客园 - 叶小钗
Hugging Face - Blog
Hugging Face - Blog
Microsoft Azure Blog
Microsoft Azure Blog
V
V2EX
Vercel News
Vercel News
阮一峰的网络日志
阮一峰的网络日志
腾讯CDC
C
Cisco Blogs
T
Tor Project blog
The Hacker News
The Hacker News
雷峰网
雷峰网
MyScale Blog
MyScale Blog
博客园 - 司徒正美
AWS News Blog
AWS News Blog
GbyAI
GbyAI
Y
Y Combinator Blog
D
DataBreaches.Net
Simon Willison's Weblog
Simon Willison's Weblog
S
Securelist
The GitHub Blog
The GitHub Blog
S
SegmentFault 最新的问题
T
Tenable Blog
L
LangChain Blog
M
MIT News - Artificial intelligence
N
Netflix TechBlog - Medium
The Cloudflare Blog
A
About on SuperTechFans
IT之家
IT之家
F
Fortinet All Blogs
Security Latest
Security Latest
Threat Intelligence Blog | Flashpoint
Threat Intelligence Blog | Flashpoint
NISL@THU
NISL@THU
爱范儿
爱范儿
钛媒体:引领未来商业与生活新知
钛媒体:引领未来商业与生活新知
cs.AI updates on arXiv.org
cs.AI updates on arXiv.org
freeCodeCamp Programming Tutorials: Python, JavaScript, Git & More
W
WeLiveSecurity
A
Arctic Wolf
I
Intezer
Application and Cybersecurity Blog
Application and Cybersecurity Blog

Workflow SDK Documentation

Patterns for Defining Tools Human-in-the-Loop Building Durable AI Agents Queueing User Messages Resumable Streams Sleep, Suspense, and Scheduling Streaming Updates from Tools API Reference Workflow Globals Changelog Resilient run start Cookbook Building a World Deploying Astro Express Fastify Hono Getting Started NestJS Next.js Nitro Nuxt Python SvelteKit Vite corrupted-event-log fetch-in-workflow hook-conflict Errors node-js-module-in-workflow serialization-failed start-invalid-workflow-function step-not-registered timeout-in-workflow webhook-invalid-respond-with-value webhook-response-not-sent workflow-not-registered Errors & Retrying Hooks & Webhooks Idempotency Foundations Serialization Starting Workflows Streaming Versioning Workflows and Steps How the Directives Work Encryption Event Sourcing Framework Integrations Understanding Directives Migration Guides Migrating from AWS Step Functions Migrating from Inngest Migrating from Temporal Observability Testing Server-Based Testing createHook createWebhook defineHook FatalError fetch getStepMetadata getWorkflowMetadata getWritable workflow RetryableError sleep @workflow/vitest DurableAgent @workflow/ai WorkflowChatTransport getHookByToken getRun getWorld workflow/api resumeHook resumeWebhook Chat Session Modeling runtime-decryption-failed Upgrading Workflows abort-signal-timeout-in-workflow Cancellation How Cancellation Works Internal Serializable AbortController and AbortSignal Eager Processing of Steps & Incremental Event Replay TanStack Start Agent Cancellation Sequential & Parallel Execution Local World | Workflow SDK Postgres World | Workflow SDK Vercel World | Workflow SDK Migrating from trigger.dev Secure Credential Handling Local World | Workflow SDK Postgres World | Workflow SDK Vercel World | Workflow SDK
Workflow Composition
2026-04-29 · via Workflow SDK Documentation

Call workflows from other workflows by direct await (flatten into the parent) or background spawn via start() (separate run).

Workflows can call other workflows. Choose between two composition modes depending on whether the parent needs the child's result inline (direct await) or wants to fire the child off as an independent run (background spawn). For massive fan-out with hook-based waiting and partial-failure handling, see Child Workflows.

  • Direct await — the parent needs the child's result before continuing, and you want a single unified event log
  • Background spawn — the parent doesn't need to wait, and you want the child to be observable as a separate run with its own runId

Direct await (flattening)

Call a child workflow with await and the child's steps execute inline within the parent — they appear in the parent's event log as if you'd called them directly.

declare function sendEmail(userId: string): Promise<void>; // @setup
declare function sendPushNotification(userId: string): Promise<void>; // @setup
declare function createAccount(userId: string): Promise<void>; // @setup
declare function setupPreferences(userId: string): Promise<void>; // @setup

// Child workflow
export async function sendNotifications(userId: string) {
  "use workflow";

  await sendEmail(userId);
  await sendPushNotification(userId);
  return { notified: true };
}

// Parent workflow calls the child directly
export async function onboardUser(userId: string) {
  "use workflow";

  await createAccount(userId);
  await sendNotifications(userId); 
  await setupPreferences(userId);

  return { userId, status: "onboarded" };
}

The parent waits for the child to finish before continuing. Both functions share a single workflow run, a single retry boundary, and a single event log.

Background spawn via start()

To run a child workflow independently without blocking the parent, call start() from a step. This launches the child as a separate workflow run with its own runId.

import { start } from "workflow/api";

declare function generateReport(reportId: string): Promise<void>; // @setup
declare function fulfillOrder(orderId: string): Promise<{ id: string }>; // @setup
declare function sendConfirmation(orderId: string): Promise<void>; // @setup

async function triggerReportGeneration(reportId: string) {
  "use step"; 

  const run = await start(generateReport, [reportId]); 
  return run.runId;
}

export async function processOrder(orderId: string) {
  "use workflow";

  const order = await fulfillOrder(orderId);

  const reportRunId = await triggerReportGeneration(orderId); 

  await sendConfirmation(orderId);

  return { orderId, reportRunId };
}

The parent continues immediately after start() returns. The child runs independently and can be monitored separately using the returned runId (e.g., via getRun()).

Each background spawn creates a separate run. If duplicate requests must route to one active child workflow, have the child create a deterministic hook token from the business key and use that hook as the idempotency point. If concurrent starts race, the losing child can detect the conflict early with await hook.getConflict(), which resolves with the active owner so the child can point callers at it. See Run idempotency.

If you want the child workflow to run on the latest deployment rather than the current one, pass deploymentId: "latest" in the start() options. See Versioning for the full model. This is currently a Vercel-specific feature, and other Worlds may map the concept to their own deployment runtimes. Be aware that the child workflow's function name, file path, argument types, and return type must remain compatible across deployments — renaming the function or changing its location will change the workflow ID, and modifying expected inputs or outputs can cause serialization failures.

  1. Direct await flattens. When a workflow function awaits another workflow function, the child's "use workflow" directive is treated as inline — the child's steps emit into the parent's event log and share the parent's run ID.
  2. start() mints a new run. The child gets its own runId, its own event log, and its own retry boundary. The parent only sees the runId returned by start().
  3. start() must be called from a step. Calling start() directly from a workflow function is not allowed — wrap it in a "use step" function. This keeps the spawn deterministic across replays.
Direct awaitBackground spawn (start())
Parent waits for childYesNo
Has its own runIdNo (shares parent's)Yes
Has its own event logNoYes
Has its own retry boundaryNoYes
Best forSequential composition, helper workflowsIndependent work, fire-and-forget, fan-out
  • Spawn many children at once — call start() in a loop inside a step. For more advanced fan-out (chunking, hook-based waiting, partial-failure handling), graduate to the Child Workflows recipe.
  • Wait for a background child to finish — combine start() with a completion hook the child resumes when done. The Child Workflows page covers the recommended startAndWait() pattern.
  • Pass results back from background children — the wrapped child resumes the parent's hook in finally with { status, value | error }; the parent awaits the hook instead of polling getRun().status.
  • "use workflow" — marks the orchestrator function
  • "use step" — marks functions with full Node.js access
  • start() — spawn a child workflow as a separate run
  • getRun() — retrieve a workflow run's status and return value
  • Idempotency — deduplicate step side effects and workflow starts