@workflow/core 5.0.0-beta.5 → 5.0.0-beta.50

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (310) hide show
  1. package/dist/attribute-changes.d.ts +5 -0
  2. package/dist/attribute-changes.d.ts.map +1 -0
  3. package/dist/attribute-changes.js +25 -0
  4. package/dist/capabilities.d.ts +35 -2
  5. package/dist/capabilities.d.ts.map +1 -1
  6. package/dist/capabilities.js +74 -5
  7. package/dist/capture-stack.d.ts +1 -1
  8. package/dist/capture-stack.js +2 -2
  9. package/dist/class-serialization.d.ts +32 -0
  10. package/dist/class-serialization.d.ts.map +1 -1
  11. package/dist/class-serialization.js +37 -1
  12. package/dist/classify-error.d.ts +19 -3
  13. package/dist/classify-error.d.ts.map +1 -1
  14. package/dist/classify-error.js +98 -6
  15. package/dist/context-violation-error.d.ts +5 -5
  16. package/dist/context-violation-error.d.ts.map +1 -1
  17. package/dist/context-violation-error.js +8 -6
  18. package/dist/create-hook.d.ts +72 -7
  19. package/dist/create-hook.d.ts.map +1 -1
  20. package/dist/create-hook.js +1 -1
  21. package/dist/define-hook.js +2 -2
  22. package/dist/describe-error.d.ts +7 -7
  23. package/dist/describe-error.d.ts.map +1 -1
  24. package/dist/describe-error.js +97 -12
  25. package/dist/encryption.d.ts +38 -4
  26. package/dist/encryption.d.ts.map +1 -1
  27. package/dist/encryption.js +96 -14
  28. package/dist/events-consumer.d.ts +271 -0
  29. package/dist/events-consumer.d.ts.map +1 -1
  30. package/dist/events-consumer.js +646 -42
  31. package/dist/flushable-stream.d.ts +56 -1
  32. package/dist/flushable-stream.d.ts.map +1 -1
  33. package/dist/flushable-stream.js +123 -11
  34. package/dist/global.d.ts +36 -2
  35. package/dist/global.d.ts.map +1 -1
  36. package/dist/global.js +21 -6
  37. package/dist/index.d.ts +2 -1
  38. package/dist/index.d.ts.map +1 -1
  39. package/dist/index.js +3 -2
  40. package/dist/log-format.d.ts +2 -2
  41. package/dist/log-format.js +7 -7
  42. package/dist/logger.d.ts +1 -0
  43. package/dist/logger.d.ts.map +1 -1
  44. package/dist/logger.js +10 -6
  45. package/dist/private.d.ts +226 -9
  46. package/dist/private.d.ts.map +1 -1
  47. package/dist/private.js +626 -7
  48. package/dist/replay-payload-cache.d.ts +64 -0
  49. package/dist/replay-payload-cache.d.ts.map +1 -0
  50. package/dist/replay-payload-cache.js +158 -0
  51. package/dist/runtime/compute-instance.d.ts +13 -0
  52. package/dist/runtime/compute-instance.d.ts.map +1 -0
  53. package/dist/runtime/compute-instance.js +14 -0
  54. package/dist/runtime/constants.d.ts +315 -0
  55. package/dist/runtime/constants.d.ts.map +1 -1
  56. package/dist/runtime/constants.js +502 -16
  57. package/dist/runtime/count-step-started-events.d.ts +52 -0
  58. package/dist/runtime/count-step-started-events.d.ts.map +1 -0
  59. package/dist/runtime/count-step-started-events.js +72 -0
  60. package/dist/runtime/deployment-guard.d.ts +99 -0
  61. package/dist/runtime/deployment-guard.d.ts.map +1 -0
  62. package/dist/runtime/deployment-guard.js +154 -0
  63. package/dist/runtime/get-port-lazy.d.ts +15 -0
  64. package/dist/runtime/get-port-lazy.d.ts.map +1 -1
  65. package/dist/runtime/get-port-lazy.js +75 -6
  66. package/dist/runtime/get-world-lazy.d.ts +5 -14
  67. package/dist/runtime/get-world-lazy.d.ts.map +1 -1
  68. package/dist/runtime/get-world-lazy.js +19 -29
  69. package/dist/runtime/helpers.d.ts +341 -29
  70. package/dist/runtime/helpers.d.ts.map +1 -1
  71. package/dist/runtime/helpers.js +559 -57
  72. package/dist/runtime/quickjs-assets.generated.d.ts +14 -0
  73. package/dist/runtime/quickjs-assets.generated.d.ts.map +1 -0
  74. package/dist/runtime/quickjs-assets.generated.js +30 -0
  75. package/dist/runtime/quickjs-entrypoint.d.ts +136 -0
  76. package/dist/runtime/quickjs-entrypoint.d.ts.map +1 -0
  77. package/dist/runtime/quickjs-entrypoint.js +1686 -0
  78. package/dist/runtime/quickjs-runtime.d.ts +244 -0
  79. package/dist/runtime/quickjs-runtime.d.ts.map +1 -0
  80. package/dist/runtime/quickjs-runtime.js +2427 -0
  81. package/dist/runtime/quickjs-serde.d.ts +107 -0
  82. package/dist/runtime/quickjs-serde.d.ts.map +1 -0
  83. package/dist/runtime/quickjs-serde.js +2159 -0
  84. package/dist/runtime/replay-budget.d.ts +97 -0
  85. package/dist/runtime/replay-budget.d.ts.map +1 -0
  86. package/dist/runtime/replay-budget.js +139 -0
  87. package/dist/runtime/replay-recovery-reporter.d.ts +36 -0
  88. package/dist/runtime/replay-recovery-reporter.d.ts.map +1 -0
  89. package/dist/runtime/replay-recovery-reporter.js +64 -0
  90. package/dist/runtime/resume-hook.d.ts +91 -8
  91. package/dist/runtime/resume-hook.d.ts.map +1 -1
  92. package/dist/runtime/resume-hook.js +512 -89
  93. package/dist/runtime/resume-latency.d.ts +150 -0
  94. package/dist/runtime/resume-latency.d.ts.map +1 -0
  95. package/dist/runtime/resume-latency.js +155 -0
  96. package/dist/runtime/run-id-time.d.ts +19 -0
  97. package/dist/runtime/run-id-time.d.ts.map +1 -0
  98. package/dist/runtime/run-id-time.js +42 -0
  99. package/dist/runtime/run.d.ts +72 -7
  100. package/dist/runtime/run.d.ts.map +1 -1
  101. package/dist/runtime/run.js +280 -53
  102. package/dist/runtime/runs.d.ts +54 -3
  103. package/dist/runtime/runs.d.ts.map +1 -1
  104. package/dist/runtime/runs.js +126 -16
  105. package/dist/runtime/start.d.ts +101 -2
  106. package/dist/runtime/start.d.ts.map +1 -1
  107. package/dist/runtime/start.js +352 -61
  108. package/dist/runtime/step-executor.d.ts +205 -5
  109. package/dist/runtime/step-executor.d.ts.map +1 -1
  110. package/dist/runtime/step-executor.js +760 -127
  111. package/dist/runtime/step-latency.d.ts +220 -0
  112. package/dist/runtime/step-latency.d.ts.map +1 -0
  113. package/dist/runtime/step-latency.js +215 -0
  114. package/dist/runtime/step-ownership.d.ts +72 -0
  115. package/dist/runtime/step-ownership.d.ts.map +1 -0
  116. package/dist/runtime/step-ownership.js +114 -0
  117. package/dist/runtime/step-single-flight.d.ts +12 -0
  118. package/dist/runtime/step-single-flight.d.ts.map +1 -0
  119. package/dist/runtime/step-single-flight.js +75 -0
  120. package/dist/runtime/suspension-handler.d.ts +269 -7
  121. package/dist/runtime/suspension-handler.d.ts.map +1 -1
  122. package/dist/runtime/suspension-handler.js +1253 -125
  123. package/dist/runtime/unserializable-step.d.ts +34 -0
  124. package/dist/runtime/unserializable-step.d.ts.map +1 -0
  125. package/dist/runtime/unserializable-step.js +52 -0
  126. package/dist/runtime/vm-mode.d.ts +44 -0
  127. package/dist/runtime/vm-mode.d.ts.map +1 -0
  128. package/dist/runtime/vm-mode.js +62 -0
  129. package/dist/runtime/vm-serde-bundle.generated.d.ts +14 -0
  130. package/dist/runtime/vm-serde-bundle.generated.d.ts.map +1 -0
  131. package/dist/runtime/vm-serde-bundle.generated.js +16 -0
  132. package/dist/runtime/wait-continuation.d.ts +106 -0
  133. package/dist/runtime/wait-continuation.d.ts.map +1 -0
  134. package/dist/runtime/wait-continuation.js +136 -0
  135. package/dist/runtime/wait-until.d.ts +18 -0
  136. package/dist/runtime/wait-until.d.ts.map +1 -0
  137. package/dist/runtime/wait-until.js +42 -0
  138. package/dist/runtime/world-compatibility.d.ts +32 -0
  139. package/dist/runtime/world-compatibility.d.ts.map +1 -0
  140. package/dist/runtime/world-compatibility.js +44 -0
  141. package/dist/runtime/world-init.d.ts +17 -42
  142. package/dist/runtime/world-init.d.ts.map +1 -1
  143. package/dist/runtime/world-init.js +18 -43
  144. package/dist/runtime/world.d.ts +14 -2
  145. package/dist/runtime/world.d.ts.map +1 -1
  146. package/dist/runtime/world.js +75 -19
  147. package/dist/runtime.d.ts +10 -6
  148. package/dist/runtime.d.ts.map +1 -1
  149. package/dist/runtime.js +3741 -490
  150. package/dist/sealed-box.d.ts +167 -0
  151. package/dist/sealed-box.d.ts.map +1 -0
  152. package/dist/sealed-box.js +571 -0
  153. package/dist/serialization/client.d.ts +3 -3
  154. package/dist/serialization/client.d.ts.map +1 -1
  155. package/dist/serialization/client.js +8 -4
  156. package/dist/serialization/codec-devalue-vm.d.ts +16 -0
  157. package/dist/serialization/codec-devalue-vm.d.ts.map +1 -0
  158. package/dist/serialization/codec-devalue-vm.js +148 -0
  159. package/dist/serialization/codec-devalue.d.ts +1 -1
  160. package/dist/serialization/codec-devalue.d.ts.map +1 -1
  161. package/dist/serialization/codec-devalue.js +24 -6
  162. package/dist/serialization/codec.d.ts +37 -2
  163. package/dist/serialization/codec.d.ts.map +1 -1
  164. package/dist/serialization/codec.js +2 -2
  165. package/dist/serialization/compression.d.ts +105 -0
  166. package/dist/serialization/compression.d.ts.map +1 -0
  167. package/dist/serialization/compression.js +261 -0
  168. package/dist/serialization/encryption.d.ts +119 -17
  169. package/dist/serialization/encryption.d.ts.map +1 -1
  170. package/dist/serialization/encryption.js +152 -17
  171. package/dist/serialization/errors.d.ts +13 -0
  172. package/dist/serialization/errors.d.ts.map +1 -1
  173. package/dist/serialization/errors.js +20 -2
  174. package/dist/serialization/format.d.ts +6 -6
  175. package/dist/serialization/format.js +7 -7
  176. package/dist/serialization/hardened.d.ts +156 -0
  177. package/dist/serialization/hardened.d.ts.map +1 -0
  178. package/dist/serialization/hardened.js +538 -0
  179. package/dist/serialization/index.d.ts +10 -8
  180. package/dist/serialization/index.d.ts.map +1 -1
  181. package/dist/serialization/index.js +10 -8
  182. package/dist/serialization/reducers/class-vm.d.ts +20 -0
  183. package/dist/serialization/reducers/class-vm.d.ts.map +1 -0
  184. package/dist/serialization/reducers/class-vm.js +77 -0
  185. package/dist/serialization/reducers/class.d.ts.map +1 -1
  186. package/dist/serialization/reducers/class.js +11 -6
  187. package/dist/serialization/reducers/common-vm.d.ts +15 -0
  188. package/dist/serialization/reducers/common-vm.d.ts.map +1 -0
  189. package/dist/serialization/reducers/common-vm.js +616 -0
  190. package/dist/serialization/reducers/common.d.ts +1 -1
  191. package/dist/serialization/reducers/common.d.ts.map +1 -1
  192. package/dist/serialization/reducers/common.js +202 -62
  193. package/dist/serialization/reducers/step-function-vm.d.ts +44 -0
  194. package/dist/serialization/reducers/step-function-vm.d.ts.map +1 -0
  195. package/dist/serialization/reducers/step-function-vm.js +97 -0
  196. package/dist/serialization/reducers/step-function.d.ts.map +1 -1
  197. package/dist/serialization/reducers/step-function.js +25 -9
  198. package/dist/serialization/step.d.ts +4 -4
  199. package/dist/serialization/step.d.ts.map +1 -1
  200. package/dist/serialization/step.js +9 -5
  201. package/dist/serialization/types.d.ts +80 -1
  202. package/dist/serialization/types.d.ts.map +1 -1
  203. package/dist/serialization/types.js +15 -1
  204. package/dist/serialization/workflow-vm.d.ts +29 -0
  205. package/dist/serialization/workflow-vm.d.ts.map +1 -0
  206. package/dist/serialization/workflow-vm.js +74 -0
  207. package/dist/serialization-format.d.ts +64 -8
  208. package/dist/serialization-format.d.ts.map +1 -1
  209. package/dist/serialization-format.js +225 -73
  210. package/dist/serialization.d.ts +262 -34
  211. package/dist/serialization.d.ts.map +1 -1
  212. package/dist/serialization.js +1879 -274
  213. package/dist/set-attributes.d.ts +13 -0
  214. package/dist/set-attributes.d.ts.map +1 -0
  215. package/dist/set-attributes.js +60 -0
  216. package/dist/source-map.d.ts +25 -0
  217. package/dist/source-map.d.ts.map +1 -1
  218. package/dist/source-map.js +154 -10
  219. package/dist/step/context-storage.d.ts +61 -2
  220. package/dist/step/context-storage.d.ts.map +1 -1
  221. package/dist/step/context-storage.js +7 -5
  222. package/dist/step/writable-stream.d.ts +3 -3
  223. package/dist/step/writable-stream.d.ts.map +1 -1
  224. package/dist/step/writable-stream.js +72 -9
  225. package/dist/step.d.ts.map +1 -1
  226. package/dist/step.js +148 -27
  227. package/dist/symbols.d.ts +50 -0
  228. package/dist/symbols.d.ts.map +1 -1
  229. package/dist/symbols.js +51 -1
  230. package/dist/telemetry/semantic-conventions.d.ts +397 -2
  231. package/dist/telemetry/semantic-conventions.d.ts.map +1 -1
  232. package/dist/telemetry/semantic-conventions.js +297 -3
  233. package/dist/telemetry.d.ts +91 -0
  234. package/dist/telemetry.d.ts.map +1 -1
  235. package/dist/telemetry.js +244 -17
  236. package/dist/test-support/orchestrator-context.d.ts +25 -0
  237. package/dist/test-support/orchestrator-context.d.ts.map +1 -0
  238. package/dist/test-support/orchestrator-context.js +101 -0
  239. package/dist/types.d.ts +6 -0
  240. package/dist/types.d.ts.map +1 -1
  241. package/dist/types.js +23 -1
  242. package/dist/util.d.ts +0 -5
  243. package/dist/util.d.ts.map +1 -1
  244. package/dist/util.js +1 -15
  245. package/dist/version.d.ts +1 -1
  246. package/dist/version.d.ts.map +1 -1
  247. package/dist/version.js +2 -2
  248. package/dist/vm/index.d.ts.map +1 -1
  249. package/dist/vm/index.js +84 -14
  250. package/dist/vm/script-cache.d.ts +26 -0
  251. package/dist/vm/script-cache.d.ts.map +1 -0
  252. package/dist/vm/script-cache.js +131 -0
  253. package/dist/vm/uint8array-base64.js +1 -1
  254. package/dist/workflow/abort-controller.d.ts +2 -2
  255. package/dist/workflow/abort-controller.d.ts.map +1 -1
  256. package/dist/workflow/abort-controller.js +88 -21
  257. package/dist/workflow/attribute-dispatcher.d.ts +6 -0
  258. package/dist/workflow/attribute-dispatcher.d.ts.map +1 -0
  259. package/dist/workflow/attribute-dispatcher.js +45 -0
  260. package/dist/workflow/create-hook.d.ts.map +1 -1
  261. package/dist/workflow/create-hook.js +24 -3
  262. package/dist/workflow/get-workflow-metadata.js +2 -2
  263. package/dist/workflow/hook.d.ts.map +1 -1
  264. package/dist/workflow/hook.js +304 -47
  265. package/dist/workflow/index.d.ts +1 -0
  266. package/dist/workflow/index.d.ts.map +1 -1
  267. package/dist/workflow/index.js +2 -1
  268. package/dist/workflow/set-attributes.d.ts +68 -0
  269. package/dist/workflow/set-attributes.d.ts.map +1 -0
  270. package/dist/workflow/set-attributes.js +60 -0
  271. package/dist/workflow/sleep.d.ts.map +1 -1
  272. package/dist/workflow/sleep.js +58 -12
  273. package/dist/workflow/world-init-stub.d.ts +3 -3
  274. package/dist/workflow/world-init-stub.js +4 -4
  275. package/dist/workflow.d.ts +95 -3
  276. package/dist/workflow.d.ts.map +1 -1
  277. package/dist/workflow.js +895 -561
  278. package/docs/api-reference/create-hook.mdx +89 -10
  279. package/docs/api-reference/create-webhook.mdx +16 -15
  280. package/docs/api-reference/define-hook.mdx +35 -33
  281. package/docs/api-reference/fatal-error.mdx +30 -8
  282. package/docs/api-reference/fetch.mdx +14 -10
  283. package/docs/api-reference/get-step-metadata.mdx +2 -2
  284. package/docs/api-reference/get-workflow-metadata.mdx +3 -3
  285. package/docs/api-reference/get-writable.mdx +7 -7
  286. package/docs/api-reference/index.mdx +4 -1
  287. package/docs/api-reference/retryable-error.mdx +1 -1
  288. package/docs/api-reference/set-attributes.mdx +61 -0
  289. package/docs/api-reference/sleep.mdx +4 -4
  290. package/docs/foundations/cancellation.mdx +31 -32
  291. package/docs/foundations/errors-and-retries.mdx +42 -11
  292. package/docs/foundations/hooks.mdx +64 -35
  293. package/docs/foundations/idempotency.mdx +244 -12
  294. package/docs/foundations/index.mdx +1 -23
  295. package/docs/foundations/meta.json +2 -1
  296. package/docs/foundations/serialization.mdx +21 -22
  297. package/docs/foundations/starting-workflows.mdx +106 -30
  298. package/docs/foundations/streaming.mdx +107 -59
  299. package/docs/foundations/versioning.mdx +263 -0
  300. package/docs/foundations/workflows-and-steps.mdx +9 -9
  301. package/docs/how-it-works/cancellation.mdx +63 -63
  302. package/docs/how-it-works/code-transform.mdx +83 -67
  303. package/docs/how-it-works/encryption.mdx +30 -26
  304. package/docs/how-it-works/event-sourcing.mdx +98 -34
  305. package/docs/how-it-works/framework-integrations.mdx +96 -337
  306. package/docs/how-it-works/understanding-directives.mdx +22 -22
  307. package/package.json +24 -15
  308. package/dist/runtime/step-handler.d.ts +0 -2
  309. package/dist/runtime/step-handler.d.ts.map +0 -1
  310. package/dist/runtime/step-handler.js +0 -776
@@ -1,5 +1,5 @@
1
1
  ---
2
- title: Starting Workflows
2
+ title: Starting workflows
3
3
  description: Trigger workflow execution with the start() function and track progress with Run objects.
4
4
  type: guide
5
5
  summary: Trigger workflows and track their execution using the start() function.
@@ -9,11 +9,11 @@ related:
9
9
  - /docs/api-reference/workflow-api/start
10
10
  ---
11
11
 
12
- Once you've defined your workflow functions, you need to trigger them to begin execution. This is done using the `start()` function from `workflow/api`, which enqueues a new workflow run and returns a `Run` object that you can use to track its progress.
12
+ After you define a workflow function, use the `start()` function from `workflow/api` to trigger it. The function enqueues a new workflow run and returns a `Run` object for tracking its progress.
13
13
 
14
- ## The `start()` Function
14
+ ## The `start()` function
15
15
 
16
- The [`start()`](/docs/api-reference/workflow-api/start) function is used to programmatically trigger workflow executions from runtime contexts like API routes, Server Actions, or any server-side code.
16
+ The [`start()`](/docs/api-reference/workflow-api/start) function programmatically triggers workflow executions from runtime contexts such as API routes, Server Actions, or other server-side code. In v5, you can also call `start()` inside a workflow function to spawn a child run or continue work in a new run.
17
17
 
18
18
  ```typescript lineNumbers
19
19
  import { start } from "workflow/api";
@@ -32,16 +32,21 @@ export async function POST(request: Request) {
32
32
  }
33
33
  ```
34
34
 
35
- **Key Points:**
35
+ **Key points:**
36
36
 
37
- - `start()` returns immediately after enqueuing the workflow - it doesn't wait for completion
37
+ - `start()` returns immediately after enqueuing the workflow. It doesn't wait for completion
38
38
  - The first argument is your workflow function
39
39
  - The second argument is an array of arguments to pass to the workflow (optional if the workflow takes no arguments)
40
40
  - All arguments must be [serializable](/docs/foundations/serialization)
41
+ - On Worlds with a regional dimension, the optional `region` option pins the new run's storage, queuing, and streams to a specific region. See [Multi-region on the Vercel World](/worlds/vercel#multi-region)
41
42
 
42
- **Learn more**: [`start()` API Reference](/docs/api-reference/workflow-api/start)
43
+ **Learn more**: [`start()` API reference](/docs/api-reference/workflow-api/start)
43
44
 
44
- ## The `Run` Object
45
+ <Callout type="info">
46
+ For parent-child workflow patterns, see [Workflow Composition](/cookbook/common-patterns/workflow-composition). For long-lived workflows that intentionally hand off to newer deployments with `deploymentId: "latest"`, see [Versioning](/docs/foundations/versioning).
47
+ </Callout>
48
+
49
+ ## The `Run` object
45
50
 
46
51
  When you call `start()`, it returns a [`Run`](/docs/api-reference/workflow-api/start#returns) object that provides access to the workflow's status and results.
47
52
 
@@ -61,24 +66,53 @@ const status = await run.status; // "running" | "completed" | "failed"
61
66
  const result = await run.returnValue;
62
67
  ```
63
68
 
64
- **Key Properties:**
69
+ **Key properties:**
65
70
 
66
- - `runId` - Unique identifier for this workflow run
67
- - `status` - Current status of the workflow (async)
68
- - `returnValue` - The value returned by the workflow function (async, blocks until completion)
69
- - `readable` - ReadableStream for streaming updates from the workflow
71
+ - `runId`: Unique identifier for this workflow run
72
+ - `status`: Current status of the workflow (async)
73
+ - `returnValue`: The value returned by the workflow function (async, blocks until completion)
74
+ - `readable`: `ReadableStream` for streaming updates from the workflow
70
75
 
71
76
  <Callout type="info">
72
- Most `Run` properties are async getters that return promises. You need to `await` them to get their values. For a complete list of properties and methods, see the API reference below.
77
+ Most `Run` properties are async getters that return promises. `await` them to get their values. For a complete list of properties and methods, see the API reference below.
73
78
  </Callout>
74
79
 
75
- **Learn more**: [`Run` API Reference](/docs/api-reference/workflow-api/start#returns)
80
+ **Learn more**: [`Run` API reference](/docs/api-reference/workflow-api/start#returns)
81
+
82
+ ## Common patterns
83
+
84
+ ### Starting workflows from workflow functions
85
+
86
+ You can also call `start()` directly inside workflow functions to spawn child workflows. For choosing between this and awaiting a workflow function directly, see [Workflow Composition](/cookbook/common-patterns/workflow-composition).
87
+
88
+ ```typescript lineNumbers
89
+ import { start } from "workflow/api";
90
+ import { childWorkflow } from "./workflows/child";
91
+
92
+ export async function parentWorkflow(inputValue: number) {
93
+ "use workflow";
94
+
95
+ const childRun = await start(childWorkflow, [inputValue]); // [!code highlight]
76
96
 
77
- ## Common Patterns
97
+ // childRun is a full Run object. Use it like normal.
98
+ const childResult = await childRun.returnValue;
99
+ return { childRunId: childRun.runId, childResult };
100
+ }
101
+ ```
78
102
 
79
- ### Fire and Forget
103
+ When you call `start()` inside a workflow function, it automatically executes through an internal step to maintain deterministic replay. The returned `Run` object works as it does outside workflows. Properties such as `.runId`, `.status`, and `.returnValue`, and methods such as `.cancel()`, are all available. Each property access or method call executes as a separate step.
80
104
 
81
- The most common pattern is to start a workflow and immediately return, letting it execute in the background:
105
+ <Callout type="info">
106
+ Inside workflow functions, each `Run` property access (e.g., `run.status`, `run.returnValue`) triggers a workflow step. This means each access is recorded in the event log and replayed deterministically.
107
+ </Callout>
108
+
109
+ <Callout type="warn">
110
+ Awaiting `returnValue` polls the child run every second, and the polling step holds its worker slot open until the child finishes. Size worker-based Worlds to cover the peak number of these polls in flight. If the child workflow is long-running, spawn it without awaiting `returnValue` and have it resume a [hook](/docs/foundations/hooks) when it completes. See the [`startAndWait()` pattern](/cookbook/advanced/child-workflows).
111
+ </Callout>
112
+
113
+ ### Fire and forget
114
+
115
+ Start a workflow and immediately return to let it execute in the background:
82
116
 
83
117
  ```typescript lineNumbers
84
118
  import { start } from "workflow/api";
@@ -96,7 +130,7 @@ export async function POST(request: Request) {
96
130
  }
97
131
  ```
98
132
 
99
- ### Wait for Completion
133
+ ### Wait for completion
100
134
 
101
135
  If you need to wait for the workflow to complete before responding:
102
136
 
@@ -115,12 +149,12 @@ export async function POST(request: Request) {
115
149
  ```
116
150
 
117
151
  <Callout type="warn">
118
- Be cautious when waiting for `returnValue` - if your workflow takes a long time, your API route may timeout.
152
+ Waiting for `returnValue` can cause your API route to time out if the workflow takes a long time.
119
153
  </Callout>
120
154
 
121
- ### Stream Updates to Client
155
+ ### Stream updates to client
122
156
 
123
- Stream real-time updates from your workflow as it executes, without waiting for completion:
157
+ Stream updates from your workflow as it executes without waiting for completion:
124
158
 
125
159
  ```typescript lineNumbers
126
160
  import { start } from "workflow/api";
@@ -144,7 +178,7 @@ export async function POST(request: Request) {
144
178
  }
145
179
  ```
146
180
 
147
- Your workflow can obtain a writable stream using [`getWritable()`](/docs/api-reference/workflow/get-writable):
181
+ Your workflow can write to the stream using [`getWritable()`](/docs/api-reference/workflow/get-writable):
148
182
 
149
183
  ```typescript lineNumbers
150
184
  import { getWritable } from "workflow";
@@ -178,12 +212,12 @@ async function streamContentToClient(
178
212
  ```
179
213
 
180
214
  <Callout type="info">
181
- Streams are particularly useful for AI workflows where you want to show progress to users in real-time, or for long-running processes that produce intermediate results.
215
+ Use streams to show users real-time progress from AI workflows or intermediate results from long-running processes.
182
216
  </Callout>
183
217
 
184
- **Learn more**: [Streaming in Workflows](/docs/foundations/serialization#streaming)
218
+ **Learn more**: [Streaming in workflows](/docs/foundations/serialization#streaming)
185
219
 
186
- ### Check Status Later
220
+ ### Check status later
187
221
 
188
222
  You can retrieve a workflow run later using its `runId` with [`getRun()`](/docs/api-reference/workflow-api/get-run):
189
223
 
@@ -209,10 +243,52 @@ export async function GET(request: Request) {
209
243
  }
210
244
  ```
211
245
 
212
- ## Next Steps
246
+ ### Recursive and repeating workflows
247
+
248
+ A workflow can start a new instance of itself. This pattern prevents a single long-running workflow from accumulating too many events. Large event logs are slower to replay, more expensive to store, and harder to inspect in the UI. Breaking work into smaller runs that chain together keeps each run lean.
249
+
250
+ ```typescript lineNumbers
251
+ import { start } from "workflow/api";
252
+ declare function fetchBatch(cursor?: string): Promise<{ items: string[]; nextCursor?: string }>; // @setup
253
+ declare function processBatch(items: string[]): Promise<void>; // @setup
254
+
255
+ export async function processQueue(cursor?: string) {
256
+ "use workflow";
257
+
258
+ const { items, nextCursor } = await fetchBatch(cursor);
259
+ await processBatch(items);
260
+
261
+ if (nextCursor) {
262
+ // Continue processing in a new workflow run
263
+ await start(processQueue, [nextCursor]); // [!code highlight]
264
+ }
265
+ }
266
+ ```
267
+
268
+ This pattern also enables **repeating cron-like workflows**. A workflow can complete its work, sleep, and then schedule a new instance of itself. This creates an indefinite chain without allowing any single run to grow too large:
269
+
270
+ ```typescript lineNumbers
271
+ import { sleep } from "workflow";
272
+ import { start } from "workflow/api";
273
+ declare function refreshMetrics(): Promise<void>; // @setup
274
+
275
+ export async function syncDashboard() {
276
+ "use workflow";
277
+
278
+ await refreshMetrics();
279
+ await sleep("1h");
280
+
281
+ // Schedule the next run
282
+ await start(syncDashboard); // [!code highlight]
283
+ }
284
+ ```
285
+
286
+ #### Starting against the latest deployment
287
+
288
+ By default a chained run starts on the same deployment as its parent. For workflows that chain over long periods, pass [`deploymentId: "latest"`](/docs/api-reference/workflow-api/start#using-deploymentid-latest) so the next run picks up new code. [Versioning](/docs/foundations/versioning#self-upgrading-workflows) covers this pattern in full, including how the serialized state acts as the migration boundary between versions.
213
289
 
214
- Now that you understand how to start workflows and track their execution:
290
+ ## Next steps
215
291
 
216
292
  - Browse the [Cookbook](/cookbook) for copy-paste recipes covering composition, scheduling, timeouts, and more
217
- - Explore [Errors & Retrying](/docs/foundations/errors-and-retries) to handle failures gracefully
218
- - Check the [`start()` API Reference](/docs/api-reference/workflow-api/start) for complete details
293
+ - Explore [Errors and retrying](/docs/foundations/errors-and-retries) to handle failures
294
+ - Check the [`start()` API reference](/docs/api-reference/workflow-api/start) for complete details
@@ -1,8 +1,8 @@
1
1
  ---
2
2
  title: Streaming
3
- description: Stream data in real-time to clients for progress updates and incremental content delivery.
3
+ description: Stream data in real time to clients for progress updates and incremental content delivery.
4
4
  type: conceptual
5
- summary: Stream real-time data to clients without waiting for workflow completion.
5
+ summary: Stream data to clients in real time without waiting for workflow completion.
6
6
  prerequisites:
7
7
  - /docs/foundations/workflows-and-steps
8
8
  related:
@@ -10,9 +10,9 @@ related:
10
10
  - /docs/ai/resumable-streams
11
11
  ---
12
12
 
13
- Workflows can stream data in real-time to clients without waiting for the entire workflow to complete. This enables progress updates, AI-generated content, log messages, and other incremental data to be delivered as workflows execute.
13
+ Workflows can stream data to clients in real time without waiting for the entire workflow to complete. Clients can receive progress updates, AI-generated content, log messages, and other incremental data as workflows execute.
14
14
 
15
- ## Getting Started with `getWritable()`
15
+ ## Getting started with `getWritable()`
16
16
 
17
17
  Every workflow run has a default writable stream that steps can write to using [`getWritable()`](/docs/api-reference/workflow/get-writable). Data written to this stream becomes immediately available to clients consuming the workflow's output.
18
18
 
@@ -38,7 +38,7 @@ export async function simpleStreamingWorkflow() {
38
38
  }
39
39
  ```
40
40
 
41
- ### Consuming the Stream
41
+ ### Consuming the stream
42
42
 
43
43
  Use the `Run` object's `readable` property to consume the stream from your API route:
44
44
 
@@ -58,7 +58,31 @@ export async function POST() {
58
58
 
59
59
  When a client makes a request to this endpoint, they'll receive each message as it's written, without waiting for the workflow to complete.
60
60
 
61
- ### Resuming Streams from a Specific Point
61
+ ### Avoiding function timeouts after client disconnects
62
+
63
+ On Vercel, `run.readable` and `run.getReadable()` reconnect to Workflow's stream storage while the workflow is still running. By default, a client disconnect does not terminate the Vercel Function serving the stream. If a user closes the page or stops the request, the function can therefore keep reconnecting until it reaches its maximum duration and fails with `FUNCTION_INVOCATION_TIMEOUT`.
64
+
65
+ For streaming routes using the Node.js runtime, opt in to [request cancellation](https://vercel.com/docs/functions/functions-api-reference#enable-cancellation) in `vercel.json`:
66
+
67
+ ```json filename="vercel.json"
68
+ {
69
+ "functions": {
70
+ "app/api/stream/route.ts": {
71
+ "supportsCancellation": true
72
+ }
73
+ }
74
+ }
75
+ ```
76
+
77
+ Replace the function path with the path or glob for your streaming route. When the downstream client disconnects, Vercel terminates the matching function invocation instead of leaving its stream reader running. The workflow run and its durable stream continue independently, so the client can reconnect through another route invocation later.
78
+
79
+ <Callout type="warn">
80
+ Cancellation applies to every function matching the configured path or glob, even if the route does not listen to `request.signal`. Any other work in that invocation which is not wrapped in [`waitUntil`](https://vercel.com/docs/functions/functions-api-reference/vercel-functions-package#waituntil) or [`after`](https://nextjs.org/docs/app/api-reference/functions/after) can be lost. Only enable it for routes that are safe to terminate when their client disconnects.
81
+ </Callout>
82
+
83
+ This setting prevents abandoned stream readers from consuming the rest of a function invocation. It does not extend the function's maximum duration. An actively connected streaming response can still reach the configured limit, at which point the client should reconnect to the durable stream.
84
+
85
+ ### Resuming streams from a specific point
62
86
 
63
87
  Use `run.getReadable({ startIndex })` to resume a stream from a specific position. This is useful for reconnecting after timeouts or network interruptions:
64
88
 
@@ -85,7 +109,7 @@ export async function GET(
85
109
  }
86
110
  ```
87
111
 
88
- This allows clients to reconnect and continue receiving data from where they left off, rather than restarting from the beginning.
112
+ Clients can reconnect and continue receiving data from where they left off instead of restarting from the beginning.
89
113
 
90
114
  `startIndex` also supports **negative values** to read relative to the end of the stream. For example, `startIndex: -5` starts 5 chunks before the current end. This is useful when you want to show the most recent output without reading the entire stream history.
91
115
 
@@ -103,31 +127,32 @@ If the absolute value exceeds the total number of chunks, reading starts from th
103
127
  Because streams are live and continue receiving chunks, negative `startIndex` values resolve to different absolute positions on each call. Accurate pagination over a live stream requires cursor-based access, which is not yet supported. Keep this in mind when building clients that paginate over stream data.
104
128
  </Callout>
105
129
 
106
- ## Streams as Data Types
130
+ ## Streams as data types
107
131
 
108
- [`ReadableStream`](https://developer.mozilla.org/en-US/docs/Web/API/ReadableStream) and [`WritableStream`](https://developer.mozilla.org/en-US/docs/Web/API/WritableStream) are standard Web Streams API types that Workflow SDK makes serializable. These are not custom types - they follow the web standard - but Workflow SDK adds the ability to pass them between functions while maintaining their streaming capabilities.
132
+ [`ReadableStream`](https://developer.mozilla.org/en-US/docs/Web/API/ReadableStream) and [`WritableStream`](https://developer.mozilla.org/en-US/docs/Web/API/WritableStream) are standard Web Streams API types that Workflow SDK makes serializable. Workflow SDK lets you pass these standard types between functions while maintaining their streaming capabilities.
109
133
 
110
134
  Unlike regular values that are fully serialized to the [event log](/docs/how-it-works/event-sourcing), streams maintain their streaming capabilities when passed between functions.
111
135
 
112
136
  **Key properties:**
137
+
113
138
  - Stream references can be passed between workflow and step functions
114
139
  - Stream data flows directly without being stored in the event log
115
140
  - Streams preserve their state across workflow suspension points
116
141
 
117
142
  <Callout type="info">
118
- **How Streams Persist Across Workflow Suspensions**
143
+ **How streams persist across workflow suspensions**
119
144
 
120
- Streams in Workflow SDK are backed by persistent, resumable storage provided by the "world" implementation. This is what enables streams to maintain their state even when workflows suspend and resume:
145
+ Persistent, resumable storage from the World implementation lets Workflow SDK streams maintain their state when workflows suspend and resume:
121
146
 
122
147
  - **Vercel deployments**: Streams are backed by a performant Redis-based stream
123
148
  - **Local development**: Stream chunks are stored in the filesystem
124
149
  </Callout>
125
150
 
126
- ### Passing Streams as Arguments
151
+ ### Passing streams as arguments
127
152
 
128
- Since streams are serializable data types, you don't need to use the special [`getWritable()`](/docs/api-reference/workflow/get-writable). You can even wire your own streams through workflows, passing them as arguments from outside into steps.
153
+ Because streams are serializable data types, you don't need to use [`getWritable()`](/docs/api-reference/workflow/get-writable). You can pass your own streams as arguments from outside a workflow into steps.
129
154
 
130
- Here's an example of passing a request body stream through a workflow to a step that processes it:
155
+ The following example passes a request body stream through a workflow to a step that processes it:
131
156
 
132
157
  ```typescript title="app/api/upload/route.ts" lineNumbers
133
158
  import { start } from "workflow/api";
@@ -167,15 +192,15 @@ async function processInputStream(input: ReadableStream<Uint8Array>) {
167
192
  }
168
193
  ```
169
194
 
170
- ## Important Limitation
195
+ ## Important limitation
171
196
 
172
197
  <Callout type="info">
173
- **Streams Cannot Be Used Directly in Workflow Context**
198
+ **Streams cannot be used directly in workflow context**
174
199
 
175
200
  You cannot read from or write to streams directly within a workflow function. All stream operations must happen in step functions.
176
201
  </Callout>
177
202
 
178
- Workflow functions must be deterministic to support replay. Since streams bypass the [event log](/docs/how-it-works/event-sourcing) for performance, reading stream data in a workflow would break determinism - each replay could see different data. By requiring all stream operations to happen in steps, the framework ensures consistent behavior.
203
+ Workflow functions must be deterministic to support replay. Streams bypass the [event log](/docs/how-it-works/event-sourcing) for performance, so reading stream data in a workflow would break determinism because each replay could see different data. Requiring all stream operations to happen in steps ensures consistent behavior.
179
204
 
180
205
  For more on determinism and replay, see [Workflows and Steps](/docs/foundations/workflows-and-steps).
181
206
 
@@ -214,7 +239,7 @@ async function writeToStream(data: string) {
214
239
  }
215
240
  ```
216
241
 
217
- ## Namespaced Streams
242
+ ## Namespaced streams
218
243
 
219
244
  Use `getWritable({ namespace: 'name' })` to create multiple independent streams for different types of data. This is useful when you want to separate logs, metrics, data outputs, or other distinct channels.
220
245
 
@@ -264,7 +289,7 @@ export async function multiStreamWorkflow() {
264
289
  }
265
290
  ```
266
291
 
267
- ### Consuming Namespaced Streams
292
+ ### Consuming namespaced streams
268
293
 
269
294
  Use `run.getReadable({ namespace: 'name' })` to access specific streams:
270
295
 
@@ -289,9 +314,37 @@ export async function POST(request: Request) {
289
314
  }
290
315
  ```
291
316
 
292
- ## Common Patterns
317
+ ## Writing to another run's stream
318
+
319
+ `getRun(runId).getWritable()` appends to a stream owned by another run. This lets short-lived runs contribute to a long-lived holder run's stream using only its ID.
293
320
 
294
- ### Progress Updates for Long-Running Tasks
321
+ ```typescript title="workflows/turn.ts" lineNumbers
322
+ import { getRun } from "workflow/api";
323
+
324
+ type SessionEvent = { turn: number; text: string };
325
+
326
+ async function runTurn(holderRunId: string, turn: number) {
327
+ "use step";
328
+
329
+ const writable = getRun(holderRunId).getWritable<SessionEvent>(); // [!code highlight]
330
+ const writer = writable.getWriter();
331
+
332
+ await writer.write({ turn, text: "done" });
333
+ writer.releaseLock(); // [!code highlight]
334
+ }
335
+ ```
336
+
337
+ Pass `{ namespace: "name" }` to target a [namespaced stream](#namespaced-streams). The writable can also be forwarded through `start()` and into steps.
338
+
339
+ <Callout type="warn">
340
+ Contributors should call `releaseLock()`, which flushes pending writes. Calling `close()` closes the shared stream for every writer.
341
+ </Callout>
342
+
343
+ The API grants append access, not read access or additional authorization. The owning run controls the stream's lifecycle, and writes to an unknown run fail.
344
+
345
+ ## Common patterns
346
+
347
+ ### Progress updates for long-running tasks
295
348
 
296
349
  Send incremental progress updates to keep users informed during lengthy workflows:
297
350
 
@@ -345,29 +398,19 @@ export async function batchProcessingWorkflow(items: string[]) {
345
398
  }
346
399
  ```
347
400
 
348
- ### Streaming AI Responses with `DurableAgent`
401
+ ### Streaming AI responses with `WorkflowAgent`
349
402
 
350
- Stream AI-generated content using [`DurableAgent`](/docs/api-reference/workflow-ai/durable-agent) from `@workflow/ai`. Tools can also emit progress updates to the same stream using [data chunks](https://ai-sdk.dev/docs/ai-sdk-ui/streaming-data#streaming-custom-data) with the [`UIMessageChunk`](https://ai-sdk.dev/docs/ai-sdk-ui/stream-protocol) type from the AI SDK:
403
+ Stream AI-generated content using AI SDK's [`WorkflowAgent`](https://ai-sdk.dev/v7/docs/agents/workflow-agent#workflowagent) from `@ai-sdk/workflow`. The agent writes `ModelCallStreamPart` chunks to the workflow stream, and route handlers convert them to UI message chunks with `createModelCallToUIChunkTransform()` before returning the response:
351
404
 
352
405
  ```typescript title="workflows/ai-assistant.ts" lineNumbers
353
- import { DurableAgent } from "@workflow/ai/agent";
406
+ import { WorkflowAgent, type ModelCallStreamPart } from "@ai-sdk/workflow";
407
+ import { tool } from "ai";
354
408
  import { getWritable } from "workflow";
355
409
  import { z } from "zod";
356
- import type { UIMessageChunk } from "ai";
357
410
 
358
411
  async function searchFlights({ query }: { query: string }) {
359
412
  "use step";
360
413
 
361
- // Tools can emit progress updates to the stream
362
- const writable = getWritable<UIMessageChunk>(); // [!code highlight]
363
- const writer = writable.getWriter(); // [!code highlight]
364
- await writer.write({ // [!code highlight]
365
- type: "data-progress", // [!code highlight]
366
- data: { message: `Searching flights for ${query}...` }, // [!code highlight]
367
- transient: true, // [!code highlight]
368
- }); // [!code highlight]
369
- writer.releaseLock(); // [!code highlight]
370
-
371
414
  // ... search logic ...
372
415
  return { flights: [/* results */] };
373
416
  }
@@ -375,27 +418,28 @@ async function searchFlights({ query }: { query: string }) {
375
418
  export async function aiAssistantWorkflow(userMessage: string) {
376
419
  "use workflow";
377
420
 
378
- const agent = new DurableAgent({
421
+ const agent = new WorkflowAgent({
379
422
  model: "anthropic/claude-haiku-4.5",
380
- system: "You are a helpful flight assistant.",
423
+ instructions: "You are a helpful flight assistant.",
381
424
  tools: {
382
- searchFlights: {
425
+ searchFlights: tool({
383
426
  description: "Search for flights",
384
427
  inputSchema: z.object({ query: z.string() }),
385
428
  execute: searchFlights,
386
- },
429
+ }),
387
430
  },
388
431
  });
389
432
 
390
433
  // LLM response will be streamed to the run's writable
391
434
  await agent.stream({
392
435
  messages: [{ role: "user", content: userMessage }],
393
- writable: getWritable<UIMessageChunk>(), // [!code highlight]
436
+ writable: getWritable<ModelCallStreamPart>(), // [!code highlight]
394
437
  });
395
438
  }
396
439
  ```
397
440
 
398
441
  ```typescript title="app/api/ai-assistant/route.ts" lineNumbers
442
+ import { createModelCallToUIChunkTransform } from "@ai-sdk/workflow";
399
443
  import { createUIMessageStreamResponse } from "ai";
400
444
  import { start } from "workflow/api";
401
445
  import { aiAssistantWorkflow } from "./workflows/ai";
@@ -406,16 +450,16 @@ export async function POST(request: Request) {
406
450
  const run = await start(aiAssistantWorkflow, [message]);
407
451
 
408
452
  return createUIMessageStreamResponse({
409
- stream: run.readable,
453
+ stream: run.readable.pipeThrough(createModelCallToUIChunkTransform()), // [!code highlight]
410
454
  });
411
455
  }
412
456
  ```
413
457
 
414
458
  <Callout type="info">
415
- For a complete implementation, see the [flight booking example](https://github.com/vercel/workflow-examples/tree/main/flight-booking-app) which demonstrates streaming AI responses with tool progress updates.
459
+ For the full agent API and migration notes, see the [`WorkflowAgent` documentation](https://ai-sdk.dev/v7/docs/agents/workflow-agent#workflowagent).
416
460
  </Callout>
417
461
 
418
- ### Streaming Between Steps
462
+ ### Streaming between steps
419
463
 
420
464
  One step produces a stream and another step consumes it:
421
465
 
@@ -456,7 +500,7 @@ async function consumeData(readable: ReadableStream<number>) {
456
500
  }
457
501
  ```
458
502
 
459
- ### Processing Large Files Without Memory Overhead
503
+ ### Processing large files without memory overhead
460
504
 
461
505
  Process large files by streaming chunks through transformation steps:
462
506
 
@@ -497,7 +541,11 @@ async function uploadResult(stream: ReadableStream<Uint8Array>) {
497
541
  }
498
542
  ```
499
543
 
500
- ## Best Practices
544
+ ## Best practices
545
+
546
+ **Batching and first-chunk latency:**
547
+
548
+ Writes are flushed immediately by default. The leading chunk of an idle stream dispatches as soon as it is written, and chunks arriving while a flush is in flight coalesce into the next batch. If you write bursts of many tiny chunks and prefer fewer round trips over first-chunk latency, set a group-commit window with the World's `streamFlushIntervalMs` option or the `WORKFLOW_STREAM_FLUSH_INTERVAL_MS` environment variable. See [Worlds configuration](/docs/configuration/worlds#streamflushintervalms).
501
549
 
502
550
  **Release locks properly:**
503
551
 
@@ -515,7 +563,7 @@ Stream locks acquired in a step only apply within that step, not across other st
515
563
  </Callout>
516
564
 
517
565
  <Callout type="warn">
518
- If a lock is not released, the step function's HTTP request cannot terminate. Even though the step returns and the workflow continues, the underlying request will remain active until it times out—wasting compute resources unnecessarily.
566
+ If a lock is not released, the invocation that ran the step cannot terminate. Even though the step returns and the workflow continues, the underlying request remains active until it times out and wastes compute resources.
519
567
  </Callout>
520
568
 
521
569
  **Close streams when done:**
@@ -541,7 +589,7 @@ const writer = writable.getWriter();
541
589
  await writer.write({ /* typed data */ });
542
590
  ```
543
591
 
544
- ## Stream Failures
592
+ ## Stream failures
545
593
 
546
594
  When a step returns a stream, the step is considered successful once it returns, even if the stream later encounters an error. The workflow won't automatically retry the step. The consumer of the stream must handle errors gracefully. For more on retry behavior, see [Errors and Retries](/docs/foundations/errors-and-retries).
547
595
 
@@ -584,17 +632,17 @@ export async function streamErrorWorkflow() {
584
632
  ```
585
633
 
586
634
  <Callout type="info">
587
- Stream errors don't trigger automatic retries for the producer step. Design your stream consumers to handle errors appropriately. Since the stream is already in an errored state, retrying the consumer won't help - use `FatalError` to fail the workflow immediately.
635
+ Stream errors don't trigger automatic retries for the producer step. Design your stream consumers to handle errors. Because the stream is already in an errored state, retrying the consumer won't help. Use `FatalError` to fail the workflow immediately.
588
636
  </Callout>
589
637
 
590
- ## Related Documentation
591
-
592
- - [`getWritable()` API Reference](/docs/api-reference/workflow/get-writable) - Get the workflow's writable stream
593
- - [`sleep()` API Reference](/docs/api-reference/workflow/sleep) - Pause workflow execution for a duration
594
- - [`start()` API Reference](/docs/api-reference/workflow-api/start) - Start workflows and access the `Run` object
595
- - [`getRun()` API Reference](/docs/api-reference/workflow-api/get-run) - Retrieve runs and their streams later
596
- - [world.streams](/docs/api-reference/workflow-api/world/streams) - Low-level stream read/write/close via World SDK
597
- - [DurableAgent](/docs/api-reference/workflow-ai/durable-agent) - AI agents with built-in streaming support
598
- - [Errors and Retries](/docs/foundations/errors-and-retries) - Understanding error handling and retry behavior
599
- - [Serialization](/docs/foundations/serialization) - Understanding what data types can be passed in workflows
600
- - [Workflows and Steps](/docs/foundations/workflows-and-steps) - Core concepts of workflow execution
638
+ ## Related documentation
639
+
640
+ - [`getWritable()` API reference](/docs/api-reference/workflow/get-writable): Get the workflow's writable stream
641
+ - [`sleep()` API reference](/docs/api-reference/workflow/sleep): Pause workflow execution for a duration
642
+ - [`start()` API reference](/docs/api-reference/workflow-api/start): Start workflows and access the `Run` object
643
+ - [`getRun()` API reference](/docs/api-reference/workflow-api/get-run): Retrieve runs and their streams later
644
+ - [`world.streams`](/docs/api-reference/workflow-runtime/world/streams): Use low-level stream read, write, and close operations through the World SDK
645
+ - [`WorkflowAgent`](https://ai-sdk.dev/v7/docs/agents/workflow-agent#workflowagent): Build AI agents with durable, resumable streaming support
646
+ - [Errors and retries](/docs/foundations/errors-and-retries): Understand error handling and retry behavior
647
+ - [Serialization](/docs/foundations/serialization): Understand which data types you can pass in workflows
648
+ - [Workflows and steps](/docs/foundations/workflows-and-steps): Learn the core concepts of workflow execution