workflow 5.0.0-beta.42 → 5.0.0-beta.44

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 (183) hide show
  1. package/README.md +6 -4
  2. package/dist/internal/builtins.d.ts +4 -4
  3. package/dist/internal/builtins.js +6 -6
  4. package/docs/ai/chat-session-modeling.mdx +23 -24
  5. package/docs/ai/defining-tools.mdx +5 -6
  6. package/docs/ai/human-in-the-loop.mdx +11 -11
  7. package/docs/ai/index.mdx +20 -20
  8. package/docs/ai/message-queueing.mdx +6 -6
  9. package/docs/ai/meta.json +1 -0
  10. package/docs/ai/resumable-streams.mdx +32 -28
  11. package/docs/ai/sleep-and-delays.mdx +9 -9
  12. package/docs/ai/streaming-updates-from-tools.mdx +4 -4
  13. package/docs/api-reference/vitest/index.mdx +8 -8
  14. package/docs/api-reference/workflow/create-hook.mdx +15 -15
  15. package/docs/api-reference/workflow/create-webhook.mdx +15 -15
  16. package/docs/api-reference/workflow/define-hook.mdx +10 -10
  17. package/docs/api-reference/workflow/fatal-error.mdx +2 -2
  18. package/docs/api-reference/workflow/fetch.mdx +7 -7
  19. package/docs/api-reference/workflow/get-step-metadata.mdx +2 -2
  20. package/docs/api-reference/workflow/get-workflow-metadata.mdx +3 -3
  21. package/docs/api-reference/workflow/get-writable.mdx +7 -7
  22. package/docs/api-reference/workflow/index.mdx +1 -1
  23. package/docs/api-reference/workflow/retryable-error.mdx +1 -1
  24. package/docs/api-reference/workflow/set-attributes.mdx +2 -2
  25. package/docs/api-reference/workflow/sleep.mdx +3 -3
  26. package/docs/api-reference/workflow-ai/durable-agent.mdx +42 -42
  27. package/docs/api-reference/workflow-ai/index.mdx +3 -3
  28. package/docs/api-reference/workflow-ai/workflow-chat-transport.mdx +28 -28
  29. package/docs/api-reference/workflow-api/get-hook-by-token.mdx +11 -11
  30. package/docs/api-reference/workflow-api/get-run.mdx +10 -10
  31. package/docs/api-reference/workflow-api/index.mdx +2 -4
  32. package/docs/api-reference/workflow-api/resume-hook.mdx +14 -14
  33. package/docs/api-reference/workflow-api/resume-webhook.mdx +4 -4
  34. package/docs/api-reference/workflow-api/start.mdx +16 -15
  35. package/docs/api-reference/workflow-astro/workflow.mdx +3 -3
  36. package/docs/api-reference/workflow-errors/entity-conflict-error.mdx +4 -4
  37. package/docs/api-reference/workflow-errors/hook-conflict-error.mdx +4 -4
  38. package/docs/api-reference/workflow-errors/hook-not-found-error.mdx +8 -8
  39. package/docs/api-reference/workflow-errors/index.mdx +6 -6
  40. package/docs/api-reference/workflow-errors/precondition-failed-error.mdx +9 -9
  41. package/docs/api-reference/workflow-errors/run-expired-error.mdx +2 -2
  42. package/docs/api-reference/workflow-errors/run-not-supported-error.mdx +4 -4
  43. package/docs/api-reference/workflow-errors/step-not-registered-error.mdx +5 -5
  44. package/docs/api-reference/workflow-errors/throttle-error.mdx +2 -2
  45. package/docs/api-reference/workflow-errors/too-early-error.mdx +2 -2
  46. package/docs/api-reference/workflow-errors/workflow-error.mdx +4 -4
  47. package/docs/api-reference/workflow-errors/workflow-not-registered-error.mdx +5 -6
  48. package/docs/api-reference/workflow-errors/workflow-run-cancelled-error.mdx +6 -6
  49. package/docs/api-reference/workflow-errors/workflow-run-failed-error.mdx +5 -5
  50. package/docs/api-reference/workflow-errors/workflow-run-not-completed-error.mdx +4 -4
  51. package/docs/api-reference/workflow-errors/workflow-run-not-found-error.mdx +4 -4
  52. package/docs/api-reference/workflow-errors/workflow-runtime-error.mdx +2 -2
  53. package/docs/api-reference/workflow-errors/workflow-world-error.mdx +8 -8
  54. package/docs/api-reference/workflow-globals.mdx +12 -11
  55. package/docs/api-reference/workflow-nest/configure-workflow-controller.mdx +2 -2
  56. package/docs/api-reference/workflow-nest/nest-local-builder.mdx +4 -4
  57. package/docs/api-reference/workflow-nest/workflow-controller.mdx +1 -1
  58. package/docs/api-reference/workflow-nest/workflow-module.mdx +4 -4
  59. package/docs/api-reference/workflow-next/with-workflow.mdx +16 -16
  60. package/docs/api-reference/workflow-nitro/index.mdx +6 -6
  61. package/docs/api-reference/workflow-nuxt/index.mdx +4 -4
  62. package/docs/api-reference/workflow-observability/hydrate-data.mdx +5 -5
  63. package/docs/api-reference/workflow-observability/hydrate-resource-io.mdx +4 -4
  64. package/docs/api-reference/workflow-observability/index.mdx +6 -8
  65. package/docs/api-reference/workflow-observability/observability-revivers.mdx +2 -2
  66. package/docs/api-reference/workflow-observability/parse-class-name.mdx +3 -3
  67. package/docs/api-reference/workflow-observability/parse-step-name.mdx +4 -4
  68. package/docs/api-reference/workflow-observability/parse-workflow-name.mdx +4 -4
  69. package/docs/api-reference/workflow-runtime/create-world.mdx +8 -8
  70. package/docs/api-reference/workflow-runtime/get-world-handlers.mdx +6 -6
  71. package/docs/api-reference/workflow-runtime/get-world.mdx +4 -4
  72. package/docs/api-reference/workflow-runtime/health-check.mdx +1 -1
  73. package/docs/api-reference/workflow-runtime/index.mdx +2 -4
  74. package/docs/api-reference/workflow-runtime/set-world.mdx +15 -13
  75. package/docs/api-reference/workflow-runtime/workflow-entrypoint.mdx +6 -5
  76. package/docs/api-reference/workflow-runtime/world/analytics.mdx +9 -9
  77. package/docs/api-reference/workflow-runtime/world/index.mdx +5 -3
  78. package/docs/api-reference/workflow-runtime/world/queue.mdx +11 -11
  79. package/docs/api-reference/workflow-runtime/world/storage.mdx +62 -28
  80. package/docs/api-reference/workflow-runtime/world/streams.mdx +7 -7
  81. package/docs/api-reference/workflow-serde/index.mdx +1 -1
  82. package/docs/api-reference/workflow-serde/workflow-deserialize.mdx +2 -2
  83. package/docs/api-reference/workflow-serde/workflow-serialize.mdx +7 -7
  84. package/docs/api-reference/workflow-sveltekit/workflow-plugin.mdx +3 -3
  85. package/docs/api-reference/workflow-vite/workflow.mdx +5 -5
  86. package/docs/changelog/attributes-mvp.mdx +39 -39
  87. package/docs/changelog/batched-event-writes.mdx +79 -0
  88. package/docs/changelog/eager-processing.mdx +63 -63
  89. package/docs/changelog/index.mdx +3 -3
  90. package/docs/changelog/lazy-event-creation.md +27 -27
  91. package/docs/changelog/meta.json +2 -1
  92. package/docs/changelog/resilient-resume.mdx +5 -5
  93. package/docs/changelog/resilient-start.mdx +14 -14
  94. package/docs/changelog/step-message-ownership.mdx +47 -47
  95. package/docs/changelog/turbo-mode.md +20 -20
  96. package/docs/comparisons/index.mdx +13 -13
  97. package/docs/comparisons/workflow-sdk-vs-aws-agentcore.mdx +15 -15
  98. package/docs/comparisons/workflow-sdk-vs-aws-step-functions.mdx +12 -12
  99. package/docs/comparisons/workflow-sdk-vs-cloudflare-workflows.mdx +11 -11
  100. package/docs/comparisons/workflow-sdk-vs-inngest.mdx +19 -19
  101. package/docs/comparisons/workflow-sdk-vs-temporal.mdx +23 -23
  102. package/docs/comparisons/workflow-sdk-vs-trigger-dev.mdx +18 -17
  103. package/docs/configuration/build-and-diagnostics.mdx +5 -5
  104. package/docs/configuration/cli-and-web-ui.mdx +4 -4
  105. package/docs/configuration/runtime-tuning.mdx +102 -21
  106. package/docs/configuration/worlds.mdx +34 -12
  107. package/docs/cookbook/advanced/child-workflows.mdx +25 -25
  108. package/docs/cookbook/advanced/publishing-libraries.mdx +40 -40
  109. package/docs/cookbook/advanced/serializable-steps.mdx +21 -21
  110. package/docs/cookbook/advanced/upgrading-workflows.mdx +31 -31
  111. package/docs/cookbook/agent-patterns/agent-cancellation.mdx +20 -20
  112. package/docs/cookbook/agent-patterns/human-in-the-loop.mdx +22 -22
  113. package/docs/cookbook/common-patterns/batching.mdx +14 -14
  114. package/docs/cookbook/common-patterns/idempotency.mdx +9 -9
  115. package/docs/cookbook/common-patterns/rate-limiting.mdx +3 -3
  116. package/docs/cookbook/common-patterns/saga.mdx +19 -19
  117. package/docs/cookbook/common-patterns/scheduling.mdx +23 -23
  118. package/docs/cookbook/common-patterns/sequential-and-parallel.mdx +26 -26
  119. package/docs/cookbook/common-patterns/timeouts.mdx +23 -23
  120. package/docs/cookbook/common-patterns/webhooks.mdx +6 -6
  121. package/docs/cookbook/common-patterns/workflow-composition.mdx +19 -19
  122. package/docs/cookbook/index.mdx +22 -22
  123. package/docs/cookbook/integrations/ai-sdk.mdx +43 -41
  124. package/docs/cookbook/integrations/chat-sdk.mdx +34 -34
  125. package/docs/cookbook/integrations/sandbox.mdx +46 -46
  126. package/docs/deploying.mdx +15 -15
  127. package/docs/errors/abort-signal-timeout-in-workflow.mdx +12 -12
  128. package/docs/errors/corrupted-event-log.mdx +13 -14
  129. package/docs/errors/deployment-mismatch.mdx +14 -14
  130. package/docs/errors/fetch-in-workflow.mdx +8 -8
  131. package/docs/errors/hook-conflict.mdx +11 -11
  132. package/docs/errors/index.mdx +1 -1
  133. package/docs/errors/node-js-module-in-workflow.mdx +5 -5
  134. package/docs/errors/replay-divergence.mdx +3 -3
  135. package/docs/errors/runtime-decryption-failed.mdx +12 -12
  136. package/docs/errors/serialization-failed.mdx +40 -12
  137. package/docs/errors/start-invalid-workflow-function.mdx +5 -5
  138. package/docs/errors/step-executed-multiple-times.mdx +2 -2
  139. package/docs/errors/step-not-registered.mdx +5 -5
  140. package/docs/errors/timeout-in-workflow.mdx +8 -8
  141. package/docs/errors/webhook-invalid-respond-with-value.mdx +18 -18
  142. package/docs/errors/webhook-response-not-sent.mdx +16 -16
  143. package/docs/errors/workflow-not-registered.mdx +5 -5
  144. package/docs/foundations/cancellation.mdx +31 -31
  145. package/docs/foundations/errors-and-retries.mdx +42 -11
  146. package/docs/foundations/hooks.mdx +37 -37
  147. package/docs/foundations/idempotency.mdx +9 -9
  148. package/docs/foundations/serialization.mdx +21 -22
  149. package/docs/foundations/starting-workflows.mdx +36 -37
  150. package/docs/foundations/streaming.mdx +68 -39
  151. package/docs/foundations/versioning.mdx +3 -3
  152. package/docs/foundations/workflows-and-steps.mdx +9 -9
  153. package/docs/getting-started/astro.mdx +16 -16
  154. package/docs/getting-started/express.mdx +8 -8
  155. package/docs/getting-started/fastify.mdx +8 -8
  156. package/docs/getting-started/hono.mdx +8 -8
  157. package/docs/getting-started/nestjs.mdx +18 -17
  158. package/docs/getting-started/next.mdx +11 -11
  159. package/docs/getting-started/nitro.mdx +16 -16
  160. package/docs/getting-started/nuxt.mdx +8 -8
  161. package/docs/getting-started/python.mdx +4 -4
  162. package/docs/getting-started/react-router/v7.mdx +1 -1
  163. package/docs/getting-started/react-router/v8.mdx +1 -1
  164. package/docs/getting-started/sveltekit.mdx +14 -14
  165. package/docs/getting-started/tanstack-start.mdx +12 -12
  166. package/docs/getting-started/vite.mdx +8 -8
  167. package/docs/how-it-works/cancellation.mdx +62 -62
  168. package/docs/how-it-works/code-transform.mdx +66 -54
  169. package/docs/how-it-works/encryption.mdx +25 -21
  170. package/docs/how-it-works/event-sourcing.mdx +84 -28
  171. package/docs/how-it-works/framework-integrations.mdx +12 -12
  172. package/docs/how-it-works/understanding-directives.mdx +21 -21
  173. package/docs/internal/index.mdx +6 -6
  174. package/docs/internal/nitro-native-build.mdx +2 -2
  175. package/docs/internal/nitro-web-ui.mdx +4 -4
  176. package/docs/internal/serializable-abort-controller.mdx +7 -7
  177. package/docs/observability/attributes.mdx +3 -3
  178. package/docs/observability/index.mdx +14 -10
  179. package/docs/observability/tracing.mdx +10 -10
  180. package/docs/testing/index.mdx +35 -35
  181. package/docs/testing/server-based.mdx +10 -10
  182. package/docs/whats-new.mdx +185 -0
  183. package/package.json +12 -12
@@ -30,7 +30,7 @@ async function testWorkflow() {
30
30
  }
31
31
  ```
32
32
 
33
- ### Detecting Workflow Runtime
33
+ ### Detecting workflow runtime
34
34
 
35
35
  You can use `getWorkflowMetadata` to detect whether your code is running inside a workflow context. This is useful when building shared utilities that need to behave differently inside and outside of workflows.
36
36
 
@@ -64,7 +64,7 @@ function log(message: string) {
64
64
  }
65
65
  ```
66
66
 
67
- ### Detecting Encryption
67
+ ### Detecting encryption
68
68
 
69
69
  The `features` object indicates which capabilities are active for the current run. Library authors can use `features.encryption` to control whether sensitive data is included in step return values, which are serialized to the event log:
70
70
 
@@ -90,7 +90,7 @@ async function fetchUserProfile(userId: string) {
90
90
  }
91
91
  ```
92
92
 
93
- ## API Signature
93
+ ## API signature
94
94
 
95
95
  ### Parameters
96
96
 
@@ -47,7 +47,7 @@ async function writeToStream(writable: WritableStream) {
47
47
  }
48
48
  ```
49
49
 
50
- ## API Signature
50
+ ## API signature
51
51
 
52
52
  ### Parameters
53
53
 
@@ -69,7 +69,7 @@ export default getWritable;`}
69
69
 
70
70
  Returns a `WritableStream<W>` where `W` is the type of data you plan to write to the stream.
71
71
 
72
- ## Good to Know
72
+ ## Good to know
73
73
 
74
74
  - **Workflow functions can only obtain the stream** - Call `getWritable()` in a workflow to get the stream reference, but you cannot call methods like `getWriter()`, `write()`, or `close()` directly in the workflow context.
75
75
  - **Step functions can interact with streams** - Steps can receive the stream as an argument or call `getWritable()` directly, and they can freely interact with it (write, close, etc.).
@@ -81,9 +81,9 @@ Returns a `WritableStream<W>` where `W` is the type of data you plan to write to
81
81
 
82
82
  ## Examples
83
83
 
84
- ### Basic Text Streaming
84
+ ### Basic text streaming
85
85
 
86
- Here's a simple example streaming text data:
86
+ This example streams text data:
87
87
 
88
88
  ```typescript lineNumbers
89
89
  import { sleep, getWritable } from "workflow";
@@ -118,7 +118,7 @@ async function stepCloseOutputStream(writable: WritableStream) {
118
118
  }
119
119
  ```
120
120
 
121
- ### Calling `getWritable()` Inside Steps
121
+ ### Calling `getWritable()` inside steps
122
122
 
123
123
  You can also call `getWritable()` directly inside step functions without passing it as a parameter:
124
124
 
@@ -157,7 +157,7 @@ async function stepCloseOutputStreamInside() {
157
157
  }
158
158
  ```
159
159
 
160
- ### Using Namespaced Streams in Steps
160
+ ### Using namespaced streams in steps
161
161
 
162
162
  You can also use namespaced streams when calling `getWritable()` from steps:
163
163
 
@@ -201,7 +201,7 @@ async function closeStreams() {
201
201
  }
202
202
  ```
203
203
 
204
- ### Advanced Chat Streaming
204
+ ### Advanced chat streaming
205
205
 
206
206
  Here's a more complex example showing how you might stream AI chat responses:
207
207
 
@@ -52,7 +52,7 @@ Workflow SDK contains the following functions you can use inside your workflow f
52
52
  </Card>
53
53
  </Cards>
54
54
 
55
- ## Error Classes
55
+ ## Error classes
56
56
 
57
57
  Workflow SDK includes error classes that can be thrown in a workflow or step to change the error exit strategy of a workflow.
58
58
 
@@ -31,7 +31,7 @@ async function retryStep() {
31
31
  The difference between `Error` and `RetryableError` may not be entirely obvious, since when both are thrown, they both retry. The difference is that `RetryableError` has an additional configurable `retryAfter` parameter.
32
32
  </Callout>
33
33
 
34
- ## API Signature
34
+ ## API signature
35
35
 
36
36
  ### Parameters
37
37
 
@@ -25,7 +25,7 @@ export async function orderWorkflow(orderId: string) {
25
25
  }
26
26
  ```
27
27
 
28
- ## API Signature
28
+ ## API signature
29
29
 
30
30
  ### Parameters
31
31
 
@@ -58,4 +58,4 @@ Validation errors throw [`FatalError`](/docs/api-reference/workflow/fatal-error)
58
58
 
59
59
  Calls from both workflow and step bodies append a native `attr_set` event, which the World materializes onto `run.attributes`. Workflow-originated events record a workflow writer; step-originated events record the originating step ID and attempt.
60
60
 
61
- Native attributes require spec version 4 or later. Step-body storage errors throw from `setAttributes`; catch them inside the step if the write should be best-effort. Workflow-body writes are committed when the workflow suspends: transient storage errors are retried with the suspension, while a write the World rejects as invalid such as exceeding the per-run attribute cap across multiple calls fails the run with the validation error.
61
+ Native attributes require spec version 4 or later. Step-body storage errors throw from `setAttributes`; catch them inside the step if the write should be best-effort. Workflow-body writes are committed when the workflow suspends: transient storage errors are retried with the suspension, while a write the World rejects as invalid (such as exceeding the per-run attribute cap across multiple calls) fails the run with the validation error.
@@ -26,7 +26,7 @@ async function testWorkflow() {
26
26
  }
27
27
  ```
28
28
 
29
- ## API Signature
29
+ ## API signature
30
30
 
31
31
  ### Parameters
32
32
 
@@ -39,7 +39,7 @@ showSections={['parameters']}
39
39
 
40
40
  ## Examples
41
41
 
42
- ### Sleeping With a Duration
42
+ ### Sleeping with a duration
43
43
 
44
44
  You can specify a duration for `sleep` to suspend the workflow for a fixed amount of time.
45
45
 
@@ -52,7 +52,7 @@ async function testWorkflow() {
52
52
  }
53
53
  ```
54
54
 
55
- ### Sleeping Until an End Date
55
+ ### Sleeping until an end date
56
56
 
57
57
  You can specify a future `Date` object for `sleep` to suspend the workflow until a specific date.
58
58
 
@@ -10,14 +10,14 @@ related:
10
10
  ---
11
11
 
12
12
  <Callout type="warn">
13
- `DurableAgent` is deprecated. Use AI SDK's [`WorkflowAgent`](https://ai-sdk.dev/v7/docs/agents/workflow-agent#workflowagent) for new durable agents see the [migration guide](https://ai-sdk.dev/v7/docs/agents/workflow-agent#migrating-from-durableagent).
13
+ `DurableAgent` is deprecated. Use AI SDK's [`WorkflowAgent`](https://ai-sdk.dev/v7/docs/agents/workflow-agent#workflowagent) for new durable agents. See the [migration guide](https://ai-sdk.dev/v7/docs/agents/workflow-agent#migrating-from-durableagent).
14
14
  </Callout>
15
15
 
16
16
  This reference is kept for existing applications that still import `DurableAgent` from `@workflow/ai/agent`. Do not use `DurableAgent` for new code.
17
17
 
18
18
  For current examples and implementation guidance, see AI SDK's [`WorkflowAgent`](https://ai-sdk.dev/v7/docs/agents/workflow-agent#workflowagent) docs. For legacy code, the API surface below documents the existing `DurableAgent` exports.
19
19
 
20
- ## API Signature
20
+ ## API signature
21
21
 
22
22
  ### Class
23
23
 
@@ -125,7 +125,7 @@ import type { StreamTextOnAbortCallback } from "@workflow/ai/agent";
125
125
  export default StreamTextOnAbortCallback;`}
126
126
  />
127
127
 
128
- ### Advanced Types
128
+ ### Advanced types
129
129
 
130
130
  #### ToolCallRepairFunction
131
131
 
@@ -157,30 +157,30 @@ import type { OutputSpecification } from "@workflow/ai/agent";
157
157
  export default OutputSpecification;`}
158
158
  />
159
159
 
160
- ## Key Features
160
+ ## Key features
161
161
 
162
- - **Durable Execution**: Agents can be interrupted and resumed without losing state
163
- - **Flexible Tool Implementation**: Tools can be implemented as workflow steps for automatic retries, or as regular workflow-level logic
164
- - **Stream Processing**: Handles streaming responses and tool calls in a structured way
165
- - **Workflow Native**: Fully integrated with Workflow SDK for production-grade reliability
166
- - **AI SDK Parity**: Supports the same options as AI SDK's `streamText` including generation settings, callbacks, and structured output
162
+ - **Durable execution**: Agents can be interrupted and resumed without losing state.
163
+ - **Flexible tool implementation**: Tools can be implemented as workflow steps for automatic retries or as regular workflow-level logic.
164
+ - **Stream processing**: Handles streaming responses and tool calls in a structured way.
165
+ - **Workflow native**: Fully integrated with Workflow SDK for production reliability.
166
+ - **AI SDK parity**: Supports the same options as AI SDK's `streamText`, including generation settings, callbacks, and structured output.
167
167
 
168
- ## Good to Know
168
+ ## Good to know
169
169
 
170
- - Tools can be implemented as workflow steps (using `"use step"` for automatic retries), or as regular workflow-level logic
171
- - Tools can use core library features like `sleep()` and Hooks within their `execute` functions
172
- - The agent processes tool calls iteratively until completion or `maxSteps` is reached
173
- - **Default `maxSteps` is unlimited** - set a value to limit the number of LLM calls
174
- - The `stream()` method returns `{ messages, steps, toolCalls, toolResults, experimental_output, uiMessages }` containing the full conversation history, step details, tool call details, optional structured output, and optionally accumulated UI messages
175
- - Use `collectUIMessages: true` to accumulate `UIMessage[]` during streaming, useful for persisting conversation state without re-reading the stream
176
- - The `prepareStep` callback runs before each step and can modify model, messages, generation settings, tool choice, and context
177
- - Generation settings (temperature, maxOutputTokens, etc.) can be set on the constructor and overridden per-stream call
178
- - Use `activeTools` to limit which tools are available for a specific stream call
179
- - The `onFinish` callback is called when all steps complete; `onAbort` is called if aborted
170
+ - Tools can be implemented as workflow steps (using `"use step"` for automatic retries) or as regular workflow-level logic.
171
+ - Tools can use core library features like `sleep()` and hooks within their `execute` functions.
172
+ - The agent processes tool calls iteratively until completion or until `maxSteps` is reached.
173
+ - **Default `maxSteps` is unlimited**: Set a value to limit the number of large language model (LLM) calls.
174
+ - The `stream()` method returns `{ messages, steps, toolCalls, toolResults, experimental_output, uiMessages }` containing the full conversation history, step details, tool call details, optional structured output, and optionally accumulated user interface (UI) messages.
175
+ - Use `collectUIMessages: true` to accumulate `UIMessage[]` during streaming, which is useful for persisting conversation state without re-reading the stream.
176
+ - The `prepareStep` callback runs before each step and can modify the model, messages, generation settings, tool choice, and context.
177
+ - Generation settings (`temperature`, `maxOutputTokens`, and others) can be set on the constructor and overridden per-stream call.
178
+ - Use `activeTools` to limit which tools are available for a specific stream call.
179
+ - The `onFinish` callback is called when all steps complete; `onAbort` is called if aborted.
180
180
 
181
181
  ## Examples
182
182
 
183
- ### Basic Agent with Tools
183
+ ### Basic agent with tools
184
184
 
185
185
  ```typescript
186
186
  import { DurableAgent } from "@workflow/ai/agent";
@@ -222,7 +222,7 @@ async function weatherAgentWorkflow(userQuery: string) {
222
222
  }
223
223
  ```
224
224
 
225
- ### Multiple Tools
225
+ ### Multiple tools
226
226
 
227
227
  ```typescript
228
228
  import { DurableAgent } from "@workflow/ai/agent";
@@ -271,7 +271,7 @@ async function multiToolAgentWorkflow(userQuery: string) {
271
271
  }
272
272
  ```
273
273
 
274
- ### Multi-turn Conversation
274
+ ### Multi-turn conversation
275
275
 
276
276
  ```typescript
277
277
  import { DurableAgent } from "@workflow/ai/agent";
@@ -325,7 +325,7 @@ async function multiTurnAgentWorkflow() {
325
325
  }
326
326
  ```
327
327
 
328
- ### Tools with Workflow Library Features
328
+ ### Tools with Workflow library features
329
329
 
330
330
  ```typescript
331
331
  import { DurableAgent } from "@workflow/ai/agent";
@@ -347,7 +347,7 @@ async function requestApproval({ message }: { message: string }) {
347
347
  // Note: No "use step" for this tool call either,
348
348
  // since hooks are awaited at the workflow level
349
349
 
350
- // Utilize a Hook for Human-in-the-loop approval
350
+ // Use a Hook for Human-in-the-loop approval
351
351
  const hook = approvalHook.create({
352
352
  metadata: { message }
353
353
  });
@@ -392,7 +392,7 @@ async function agentWithLibraryFeaturesWorkflow(userRequest: string) {
392
392
  }
393
393
  ```
394
394
 
395
- ### Dynamic Context with prepareStep
395
+ ### Dynamic context with prepareStep
396
396
 
397
397
  Use `prepareStep` to modify settings before each step in the agent loop:
398
398
 
@@ -436,7 +436,7 @@ async function agentWithPrepareStep(userMessage: string) {
436
436
  }
437
437
  ```
438
438
 
439
- ### Message Injection with prepareStep
439
+ ### Message injection with prepareStep
440
440
 
441
441
  Inject messages from external sources (like hooks) before each LLM call:
442
442
 
@@ -486,7 +486,7 @@ async function agentWithMessageQueue(initialMessage: string) {
486
486
  }
487
487
  ```
488
488
 
489
- ### Generation Settings
489
+ ### Generation settings
490
490
 
491
491
  Configure model generation parameters at the constructor or stream level:
492
492
 
@@ -524,7 +524,7 @@ async function agentWithGenerationSettings() {
524
524
  }
525
525
  ```
526
526
 
527
- ### Limiting Steps with maxSteps
527
+ ### Limiting steps with maxSteps
528
528
 
529
529
  By default, the agent loops until completion. Use `maxSteps` to limit the number of LLM calls:
530
530
 
@@ -575,7 +575,7 @@ async function multiStepAgent() {
575
575
  }
576
576
  ```
577
577
 
578
- ### Callbacks for Monitoring
578
+ ### Callbacks for monitoring
579
579
 
580
580
  Use callbacks to monitor streaming progress, handle errors, and react to completion:
581
581
 
@@ -616,7 +616,7 @@ async function agentWithCallbacks() {
616
616
  }
617
617
  ```
618
618
 
619
- ### Structured Output
619
+ ### Structured output
620
620
 
621
621
  Parse structured data from the LLM response using `Output.object`:
622
622
 
@@ -651,7 +651,7 @@ async function agentWithStructuredOutput() {
651
651
  }
652
652
  ```
653
653
 
654
- ### Tool Choice Control
654
+ ### Tool choice control
655
655
 
656
656
  Control when and which tools the model can use:
657
657
 
@@ -714,7 +714,7 @@ async function agentWithToolChoice() {
714
714
  }
715
715
  ```
716
716
 
717
- ### Passing Context to Tools
717
+ ### Passing context to tools
718
718
 
719
719
  Use `experimental_context` to pass shared context to tool executions:
720
720
 
@@ -758,7 +758,7 @@ async function agentWithContext(userId: string) {
758
758
  }
759
759
  ```
760
760
 
761
- ### Collecting UI Messages
761
+ ### Collecting UI messages
762
762
 
763
763
  Use `collectUIMessages` to accumulate `UIMessage[]` during streaming. This is useful when you need to persist the conversation without re-reading the run's output stream:
764
764
 
@@ -800,7 +800,7 @@ async function saveConversation(messages: UIMessage[]) {
800
800
  The `uiMessages` property is only available when `collectUIMessages` is set to `true`. When disabled, `uiMessages` is `undefined`.
801
801
  </Callout>
802
802
 
803
- ### Machine-Readable Tool Results
803
+ ### Machine-readable tool results
804
804
 
805
805
  `stream()` returns tool call information you can inspect programmatically. Compare `toolCalls` with `toolResults` to find unresolved tool calls that need client-side handling:
806
806
 
@@ -857,7 +857,7 @@ async function agentWithToolInspection(userMessage: string) {
857
857
  `toolCalls` and `toolResults` reflect the *last step* of the agent loop. Tools without an `execute` function will appear in `toolCalls` but not in `toolResults`, which is how you detect calls that need client-side handling.
858
858
  </Callout>
859
859
 
860
- ### Aborting Long-Running Streams
860
+ ### Aborting long-running streams
861
861
 
862
862
  Use `timeout` to abort a stream automatically after a fixed duration:
863
863
 
@@ -885,10 +885,10 @@ async function agentWithTimeout(userMessage: string) {
885
885
  }
886
886
  ```
887
887
 
888
- ## See Also
888
+ ## See also
889
889
 
890
- - [Building Durable AI Agents](/docs/ai) - Complete guide to creating durable agents
891
- - [Queueing User Messages](/docs/ai/message-queueing) - Using prepareStep for message injection
892
- - [WorkflowChatTransport](/docs/api-reference/workflow-ai/workflow-chat-transport) - Transport layer for AI SDK streams
893
- - [Workflows and Steps](/docs/foundations/workflows-and-steps) - Understanding workflow fundamentals
894
- - [AI SDK Loop Control](https://ai-sdk.dev/docs/agents/loop-control) - AI SDK's agent loop control patterns
890
+ - [Building Durable AI Agents](/docs/ai): Complete guide to creating durable agents
891
+ - [Queueing User Messages](/docs/ai/message-queueing): Using `prepareStep` for message injection
892
+ - [WorkflowChatTransport](/docs/api-reference/workflow-ai/workflow-chat-transport): Transport layer for AI SDK streams
893
+ - [Workflows and Steps](/docs/foundations/workflows-and-steps): Understanding workflow fundamentals
894
+ - [AI SDK Loop Control](https://ai-sdk.dev/docs/agents/loop-control): AI SDK's agent loop control patterns
@@ -7,15 +7,15 @@ related:
7
7
  - /docs/ai
8
8
  ---
9
9
 
10
- Helpers for integrating AI SDK for building AI-powered workflows.
10
+ The `@workflow/ai` package provides helpers for integrating AI SDK into AI-powered workflows.
11
11
 
12
12
  ## Classes
13
13
 
14
14
  <Cards>
15
15
  <Card title="DurableAgent" href="/docs/api-reference/workflow-ai/durable-agent">
16
- Deprecated use AI SDK's [`WorkflowAgent`](https://ai-sdk.dev/v7/docs/agents/workflow-agent#workflowagent). Reference kept for existing `@workflow/ai/agent` imports.
16
+ Deprecated: use AI SDK's [`WorkflowAgent`](https://ai-sdk.dev/v7/docs/agents/workflow-agent#workflowagent). Reference kept for existing `@workflow/ai/agent` imports.
17
17
  </Card>
18
18
  <Card title="WorkflowChatTransport" href="/docs/api-reference/workflow-ai/workflow-chat-transport">
19
- Deprecated use AI SDK's [`WorkflowChatTransport`](https://ai-sdk.dev/v7/docs/agents/workflow-agent#resumable-streaming-with-workflowchattransport) from `@ai-sdk/workflow`. Reference kept for existing `@workflow/ai` imports.
19
+ Deprecated: use AI SDK's [`WorkflowChatTransport`](https://ai-sdk.dev/v7/docs/agents/workflow-agent#resumable-streaming-with-workflowchattransport) from `@ai-sdk/workflow`. Reference kept for existing `@workflow/ai` imports.
20
20
  </Card>
21
21
  </Cards>
@@ -10,10 +10,10 @@ related:
10
10
  ---
11
11
 
12
12
  <Callout type="warn">
13
- `WorkflowChatTransport` from `@workflow/ai` is deprecated. AI SDK ships a 1:1 port use [`WorkflowChatTransport` from `@ai-sdk/workflow`](https://ai-sdk.dev/v7/docs/agents/workflow-agent#resumable-streaming-with-workflowchattransport) instead. This reference is kept for existing applications that still import it from `@workflow/ai`.
13
+ `WorkflowChatTransport` from `@workflow/ai` is deprecated. AI SDK ships a 1:1 port, so use [`WorkflowChatTransport` from `@ai-sdk/workflow`](https://ai-sdk.dev/v7/docs/agents/workflow-agent#resumable-streaming-with-workflowchattransport) instead. This reference is kept for existing applications that still import it from `@workflow/ai`.
14
14
  </Callout>
15
15
 
16
- A chat transport implementation for the AI SDK that provides reliable message streaming with automatic reconnection to interrupted streams. This transport is a drop-in replacement for the default AI SDK transport, enabling seamless recovery from network issues, page refreshes, or Vercel Function timeouts.
16
+ `WorkflowChatTransport` is an AI SDK chat transport that automatically reconnects to interrupted streams. It replaces the default AI SDK transport and recovers from network issues, page refreshes, or Vercel Functions timeouts.
17
17
 
18
18
  <Callout>
19
19
  `WorkflowChatTransport` implements the [`ChatTransport`](https://ai-sdk.dev/docs/ai-sdk-ui/transport) interface from the AI SDK and is designed to work with workflow-based chat applications. It requires endpoints that return the `x-workflow-run-id` header to enable stream resumption.
@@ -38,7 +38,7 @@ export default function Chat() {
38
38
  }
39
39
  ```
40
40
 
41
- ## API Signature
41
+ ## API signature
42
42
 
43
43
  ### Class
44
44
 
@@ -56,27 +56,27 @@ import type { WorkflowChatTransportOptions } from "@workflow/ai";
56
56
  export default WorkflowChatTransportOptions;`}
57
57
  />
58
58
 
59
- ## Key Features
59
+ ## Key features
60
60
 
61
- - **Automatic Reconnection**: Automatically recovers from interrupted streams with configurable retry limits
62
- - **Workflow Integration**: Seamlessly works with workflow-based endpoints that provide the `x-workflow-run-id` header
63
- - **Customizable Requests**: Allows intercepting and modifying requests via `prepareSendMessagesRequest` and `prepareReconnectToStreamRequest`
64
- - **Stream Callbacks**: Provides hooks for tracking chat lifecycle via `onChatSendMessage` and `onChatEnd`
65
- - **Custom Fetch**: Supports custom fetch implementations for advanced use cases
61
+ - **Automatic reconnection**: Recovers from interrupted streams with configurable retry limits.
62
+ - **Workflow integration**: Works with workflow-based endpoints that provide the `x-workflow-run-id` header.
63
+ - **Customizable requests**: Allows intercepting and modifying requests through `prepareSendMessagesRequest` and `prepareReconnectToStreamRequest`.
64
+ - **Stream callbacks**: Provides hooks for tracking the chat lifecycle through `onChatSendMessage` and `onChatEnd`.
65
+ - **Custom fetch**: Supports custom fetch implementations for advanced use cases.
66
66
 
67
- ## Good to Know
67
+ ## Good to know
68
68
 
69
- - The transport expects chat endpoints to return the `x-workflow-run-id` header in the response to enable stream resumption
70
- - By default, the transport posts to `/api/chat` and reconnects via `/api/chat/{runId}/stream`
71
- - The `onChatSendMessage` callback receives the full response object, allowing you to extract and store the workflow run ID for session resumption
72
- - Stream interruptions are automatically detected when a "finish" chunk is not received in the initial response
73
- - The `maxConsecutiveErrors` option controls how many reconnection attempts are made before giving up (default: 3)
74
- - `initialStartIndex` (constructor option) sets the default chunk position for the **first** reconnection attempt (e.g. after a page refresh). Subsequent retries within the same reconnection loop always resume from the last received chunk. Negative values (e.g. `-20`) read from the end of the stream, which is useful for showing only recent output without replaying the full conversation. `startIndex` (per-call option on `reconnectToStream`) overrides `initialStartIndex` for a single reconnection
75
- - When using a negative `initialStartIndex`, the reconnection endpoint must return the `x-workflow-stream-tail-index` response header (via `readable.getTailIndex()`). The transport reads this header to compute absolute chunk positions for retries. Without it, startIndex is assumed to be 0, replaying the entire stream
69
+ - The transport expects chat endpoints to return the `x-workflow-run-id` header in the response to enable stream resumption.
70
+ - By default, the transport posts to `/api/chat` and reconnects through `/api/chat/{runId}/stream`.
71
+ - The `onChatSendMessage` callback receives the full response object, allowing you to extract and store the workflow run ID for session resumption.
72
+ - Stream interruptions are automatically detected when a `finish` chunk is not received in the initial response.
73
+ - The `maxConsecutiveErrors` option controls how many reconnection attempts are made before giving up (default: 3).
74
+ - `initialStartIndex` (constructor option) sets the default chunk position for the **first** reconnection attempt (for example, after a page refresh). Subsequent retries within the same reconnection loop always resume from the last received chunk. Negative values (for example, `-20`) read from the end of the stream, which is useful for showing only recent output without replaying the full conversation. `startIndex` (per-call option on `reconnectToStream`) overrides `initialStartIndex` for a single reconnection.
75
+ - When using a negative `initialStartIndex`, the reconnection endpoint must return the `x-workflow-stream-tail-index` response header (through `readable.getTailIndex()`). The transport reads this header to compute absolute chunk positions for retries. Without it, `startIndex` is assumed to be `0`, replaying the entire stream.
76
76
 
77
77
  ## Examples
78
78
 
79
- ### Basic Chat Setup
79
+ ### Basic chat setup
80
80
 
81
81
  ```typescript
82
82
  "use client";
@@ -119,7 +119,7 @@ export default function BasicChat() {
119
119
  }
120
120
  ```
121
121
 
122
- ### With Session Persistence and Resumption
122
+ ### With session persistence and resumption
123
123
 
124
124
  ```typescript
125
125
  "use client";
@@ -187,7 +187,7 @@ export default function ChatWithResumption() {
187
187
  }
188
188
  ```
189
189
 
190
- ### With Custom Request Configuration
190
+ ### With custom request configuration
191
191
 
192
192
  ```typescript
193
193
  "use client";
@@ -256,11 +256,11 @@ export default function ChatWithCustomConfig() {
256
256
 
257
257
  ## Mid-part resumes
258
258
 
259
- A workflow stream is a flat sequence of chunks, but the AI SDK's UI protocol groups chunks into logical parts: a `text-start` opens a text part that subsequent `text-delta`s extend and a `text-end` closes, and the same shape applies to `reasoning-*` and `tool-input-*`. The AI SDK client enforces that grammar a `reasoning-delta` whose `reasoning-start` was never seen throws and breaks the chat.
259
+ A workflow stream is a flat sequence of chunks, but the AI SDK's user interface (UI) protocol groups chunks into logical parts: a `text-start` opens a text part that subsequent `text-delta`s extend and a `text-end` closes, and the same shape applies to `reasoning-*` and `tool-input-*`. The AI SDK client enforces that grammar: a `reasoning-delta` whose `reasoning-start` was never seen throws and breaks the chat.
260
260
 
261
- A non-zero `startIndex` (in particular a negative `initialStartIndex`) resolves to a chunk offset with no awareness of those part boundaries, so it can land in the middle of an open part. When that happens, `WorkflowChatTransport` will **drop chunks that reference a part it didn't see a start for** and log a one-time warning. The chat keeps working, but any partial part overlapping the resume cursor is discarded. Tool calls are an exception: `tool-input-available` / `tool-input-error` chunks are self-contained (they carry the full input), so a tool call is recovered as soon as one of those chunks appears in the resumed window only its streamed input deltas are lost.
261
+ A non-zero `startIndex` (in particular a negative `initialStartIndex`) resolves to a chunk offset with no awareness of those part boundaries, so it can land in the middle of an open part. When that happens, `WorkflowChatTransport` will **drop chunks that reference a part it didn't see a start for** and log a one-time warning. The chat keeps working, but any partial part overlapping the resume cursor is discarded. Tool calls are an exception: `tool-input-available` / `tool-input-error` chunks are self-contained (they carry the full input), so a tool call is recovered as soon as one of those chunks appears in the resumed window. Only its streamed input deltas are lost.
262
262
 
263
- To preserve those partial parts, rewind to a step boundary on the server before returning the readable. `start-step` / `finish-step` chunks are the natural seams no UI part is ever open across them. Sketch:
263
+ To preserve those partial parts, rewind to a step boundary on the server before returning the readable. `start-step` / `finish-step` chunks are the natural seams: no UI part is ever open across them. Sketch:
264
264
 
265
265
  {/*@skip-typecheck: incomplete code sample*/}
266
266
 
@@ -293,9 +293,9 @@ return createUIMessageStreamResponse({
293
293
  });
294
294
  ```
295
295
 
296
- ## See Also
296
+ ## See also
297
297
 
298
- - [`WorkflowAgent`](https://ai-sdk.dev/v7/docs/agents/workflow-agent#workflowagent) - Building durable, resumable AI agents (replaces `DurableAgent`)
299
- - [AI SDK `useChat` Documentation](https://ai-sdk.dev/docs/reference/ai-sdk-ui/use-chat) - Using `useChat` with custom transports
300
- - [Workflows and Steps](/docs/foundations/workflows-and-steps) - Understanding workflow fundamentals
301
- - ["flight-booking-app" Example](https://github.com/vercel/workflow-examples/tree/main/flight-booking-app) - An example application which uses `WorkflowChatTransport`
298
+ - [`WorkflowAgent`](https://ai-sdk.dev/v7/docs/agents/workflow-agent#workflowagent): Build durable, resumable AI agents (replaces `DurableAgent`)
299
+ - [AI SDK `useChat` documentation](https://ai-sdk.dev/docs/reference/ai-sdk-ui/use-chat): Use `useChat` with custom transports
300
+ - [Workflows and Steps](/docs/foundations/workflows-and-steps): Understand workflow fundamentals
301
+ - [`flight-booking-app` example](https://github.com/vercel/workflow-examples/tree/main/flight-booking-app): View an example application that uses `WorkflowChatTransport`
@@ -18,7 +18,7 @@ When `experimental_minRetention` is set, this function continues to return the H
18
18
  </Callout>
19
19
 
20
20
  <Callout type="info">
21
- Looking up a deterministic hook token is useful in hook-based idempotency flows, but it is only an advisory check. If no hook exists yet, another request can still start the same workflow before your `start()` call registers its hook. Use the lookup to avoid obvious duplicate starts, and handle the race inside the workflow by checking `await hook.getConflict()` before duplicate-sensitive work on a conflict it resolves with the run that owns the token, so the duplicate can route the caller to the active owner. If duplicates must be rejected before a workflow body runs, keep a durable request record until native atomic start-and-hook registration exists. See [Run idempotency](/docs/foundations/idempotency#run-idempotency).
21
+ Looking up a deterministic hook token is useful in hook-based idempotency flows, but it is only an advisory check. If no hook exists yet, another request can still start the same workflow before your `start()` call registers its hook. Use the lookup to avoid obvious duplicate starts, and handle the race inside the workflow by checking `await hook.getConflict()` before duplicate-sensitive work. On a conflict it resolves with the run that owns the token, so the duplicate can route the caller to the active owner. If duplicates must be rejected before a workflow body runs, keep a durable request record until native atomic start-and-hook registration exists. See [Run idempotency](/docs/foundations/idempotency#run-idempotency).
22
22
  </Callout>
23
23
 
24
24
  ```typescript lineNumbers
@@ -31,7 +31,7 @@ export async function POST(request: Request) {
31
31
  }
32
32
  ```
33
33
 
34
- ## API Signature
34
+ ## API signature
35
35
 
36
36
  ### Parameters
37
37
 
@@ -55,7 +55,7 @@ showSections={["returns"]}
55
55
 
56
56
  ## Examples
57
57
 
58
- ### Basic Hook Lookup
58
+ ### Basic hook lookup
59
59
 
60
60
  Retrieve hook information before resuming:
61
61
 
@@ -85,7 +85,7 @@ export async function POST(request: Request) {
85
85
  }
86
86
  ```
87
87
 
88
- ### Validating Hook Before Resume
88
+ ### Validating hook before resume
89
89
 
90
90
  Use `getHookByToken` to validate hook ownership or metadata before resuming:
91
91
 
@@ -115,7 +115,7 @@ export async function POST(request: Request) {
115
115
  }
116
116
  ```
117
117
 
118
- ### Checking Hook Environment
118
+ ### Checking hook environment
119
119
 
120
120
  Verify the hook belongs to the expected environment:
121
121
 
@@ -144,7 +144,7 @@ export async function POST(request: Request) {
144
144
  }
145
145
  ```
146
146
 
147
- ### Logging Hook Information
147
+ ### Logging hook information
148
148
 
149
149
  Log hook details for debugging or auditing:
150
150
 
@@ -181,9 +181,9 @@ export async function POST(request: Request) {
181
181
  }
182
182
  ```
183
183
 
184
- ## Related Functions
184
+ ## Related functions
185
185
 
186
- - [`resumeHook()`](/docs/api-reference/workflow-api/resume-hook) - Resume a hook with a payload.
187
- - [`createHook()`](/docs/api-reference/workflow/create-hook) - Create a hook in a workflow.
188
- - [`defineHook()`](/docs/api-reference/workflow/define-hook) - Type-safe hook helper.
189
- - [Idempotency](/docs/foundations/idempotency) - Deduplicate step side effects and workflow starts.
186
+ - [`resumeHook()`](/docs/api-reference/workflow-api/resume-hook): Resume a hook with a payload.
187
+ - [`createHook()`](/docs/api-reference/workflow/create-hook): Create a hook in a workflow.
188
+ - [`defineHook()`](/docs/api-reference/workflow/define-hook): Type-safe hook helper.
189
+ - [Idempotency](/docs/foundations/idempotency): Deduplicate step side effects and workflow starts.
@@ -9,7 +9,7 @@ related:
9
9
  - /docs/foundations/idempotency
10
10
  ---
11
11
 
12
- Retrieves the workflow run metadata and status information for a given run ID. This function provides immediate access to workflow run details without waiting for completion, making it ideal for status checking and monitoring.
12
+ Retrieves workflow run metadata and status information for a given run ID. This function provides immediate access to workflow run details without waiting for completion.
13
13
 
14
14
  Use this function when you need to check workflow status, get timing information, or access workflow metadata without blocking on workflow completion.
15
15
 
@@ -23,7 +23,7 @@ import { getRun } from "workflow/api";
23
23
  const run = getRun("my-run-id");
24
24
  ```
25
25
 
26
- ## API Signature
26
+ ## API signature
27
27
 
28
28
  ### Parameters
29
29
 
@@ -47,7 +47,7 @@ showSections={["returns"]}
47
47
 
48
48
  #### WorkflowReadableStream
49
49
 
50
- `run.getReadable()` returns a `WorkflowReadableStream` a standard `ReadableStream` extended with a `getTailIndex()` helper:
50
+ `run.getReadable()` returns a `WorkflowReadableStream`, a standard `ReadableStream` extended with a `getTailIndex()` helper:
51
51
 
52
52
  <TSDoc
53
53
  definition={`
@@ -83,7 +83,7 @@ export default StopSleepResult;`}
83
83
 
84
84
  ## Examples
85
85
 
86
- ### Check if a Run Exists
86
+ ### Check if a run exists
87
87
 
88
88
  Use the `exists` getter to check whether a workflow run exists without throwing when the run is not found:
89
89
 
@@ -112,7 +112,7 @@ export async function GET(req: Request) {
112
112
  }
113
113
  ```
114
114
 
115
- ### Basic Status Check
115
+ ### Basic status check
116
116
 
117
117
  Check the current status of a workflow run:
118
118
 
@@ -141,7 +141,7 @@ export async function GET(req: Request) {
141
141
  }
142
142
  ```
143
143
 
144
- ### Wake Up a Sleeping Workflow
144
+ ### Wake up a sleeping workflow
145
145
 
146
146
  Interrupt pending `sleep()` calls to resume a workflow early. This is useful for testing workflows or building custom UIs that let users skip wait periods:
147
147
 
@@ -170,7 +170,7 @@ const { stoppedCount } = await run.wakeUp({
170
170
  });
171
171
  ```
172
172
 
173
- ### Cancel a Run
173
+ ### Cancel a run
174
174
 
175
175
  Cancel a workflow run. You can pass an optional free-text `cancelReason` (up to 512 characters) that is recorded on the run's cancellation event and shown in the run detail view:
176
176
 
@@ -187,8 +187,8 @@ export async function POST(req: Request) {
187
187
  }
188
188
  ```
189
189
 
190
- The options object is optional `await run.cancel()` cancels the run without recording a reason.
190
+ The options object is optional: `await run.cancel()` cancels the run without recording a reason.
191
191
 
192
- ## Related Functions
192
+ ## Related functions
193
193
 
194
- - [`start()`](/docs/api-reference/workflow-api/start) - Start a new workflow and get its run ID.
194
+ - [`start()`](/docs/api-reference/workflow-api/start): Start a new workflow and get its run ID.