workflow 5.8.0 → 5.8.1

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.
@@ -28,7 +28,7 @@ Workflow SDK complements it by making bot **sessions** durable. Each conversatio
28
28
  One thread mapped to one workflow run also means the thread stays on the deployment that started it. For channels where each message should use newer code, see [Versioning](/docs/foundations/versioning) for explicit child-run and handoff patterns using `deploymentId: "latest"`.
29
29
  </Callout>
30
30
 
31
- The rest of this page covers the integration pattern. For a full Slack + Next.js + Redis walkthrough, see the [Durable chat sessions guide](https://chat-sdk.dev/docs/guides/durable-chat-sessions-nextjs) on chat-sdk.dev.
31
+ The rest of this page covers the integration pattern. If you don't have a Chat SDK bot yet, start with the [Slack bot with Next.js and Redis guide](https://vercel.com/kb/guide/how-to-build-a-slack-bot-with-next-js-and-redis), then use this page to make its sessions durable.
32
32
 
33
33
  ## How it fits together
34
34
 
@@ -10,7 +10,7 @@ related:
10
10
  - /docs/foundations/streaming
11
11
  ---
12
12
 
13
- We benchmark the Workflow SDK runtime on Vercel at each point where a workflow waits on it: starting a run, moving from one step to the next, fanning out, resuming from a hook, and delivering a stream. This page explains what each benchmark measures and how, and then shows the [latest results](#latest-results), which compare a new release with an earlier one.
13
+ We benchmark the Workflow SDK runtime on Vercel at each point where a workflow waits on it: starting a run, moving from one step to the next, fanning out, resuming from a hook, and delivering a stream, plus a five-turn agent loop that combines them. This page explains what each benchmark measures and how, and then shows the [latest results](#latest-results), which compare the latest release with earlier ones.
14
14
 
15
15
  ## What we measure
16
16
 
@@ -38,11 +38,17 @@ A workflow creates a [hook](/docs/foundations/hooks) and waits on it for 1 s, th
38
38
 
39
39
  One step replays a recorded AI agent's token stream, 2,593 chunks over 52.4 s, in real time to a [namespaced stream](/docs/foundations/streaming#namespaced-streams) with [`getWritable()`](/docs/api-reference/workflow/get-writable), and a second step in the same run reads it with `getRun(runId).getReadable()`. Chunk trip time runs from the writer writing a chunk until the reader receives it. The same benchmark records how long the whole response takes to reach the reader and how many runs had a chunk delayed by over 1 s. See [Streams](#streams) for the latest results.
40
40
 
41
+ ### Agent loop overhead
42
+
43
+ A five-turn agent built from plain steps, shaped like a durable AI agent. Each turn is one model step that streams 10 tokens over 100 ms to [`getWritable()`](/docs/api-reference/workflow/get-writable). On turns 1 to 4 the model then calls two tools, which run in parallel as 100 ms steps, and turn 5 answers. Each message is 1 KB of JSON, and the conversation passed to every step grows each turn. The overhead runs from `start()` until the first line of a step after the last turn, minus the 900 ms of model and tool work on the critical path. The loop runs with and without streaming its tokens. See [Agent loop](#agent-loop) for the latest results.
44
+
45
+ Every step uses the default retry settings. A model step marked [`maxRetries = 0`](/docs/foundations/errors-and-retries), as some agent libraries do, waits until its start is recorded before it runs, which added about 70 ms per turn on v5.8.0 in our measurements.
46
+
41
47
  ## Methodology
42
48
 
43
- - **Platform**: Each version runs the same benchmark app on Vercel production in `iad1`, against the managed [Vercel World](/worlds/vercel), on its own deployment. The versions are measured at the same time. Before measuring, each deployment runs two short workflows and one fan-out that are not counted.
49
+ - **Platform**: Each version runs the same benchmark app on Vercel production in `iad1`, against the managed [Vercel World](/worlds/vercel), on its own deployment. The versions are measured at the same time. Before each sweep of a benchmark, every deployment runs one warm-up that is not counted: a five-step workflow before the 1,020-step run, and one run of the benchmark otherwise. The agent loop runs on a separate app, deployed the same way once per version, which runs one loop with and one without streaming before measuring.
44
50
  - **Workload**: Every step takes 1 KB of JSON in and out and does 100 ms of simulated work, which the overhead measurements exclude.
45
- - **Runs**: Each version runs every benchmark several times, and each result pools the samples from all of its runs. The run counts are listed with the latest results.
51
+ - **Runs**: Each version runs every benchmark several times, and each result pools the samples from all of its runs. The run counts are listed with [all results](#all-results).
46
52
  - **Percentiles**: Each percentile pools every sample across a version's runs and uses the nearest-rank method. Half of the samples are at or below the p50 (the median), three quarters at or below the p75, and all but the slowest 1% at or below the p99. With 100 or fewer samples, a p99 is the slowest sample.
47
53
 
48
54
  ### Limits
@@ -56,132 +62,160 @@ One step replays a recorded AI agent's token stream, 2,593 chunks over 52.4 s, i
56
62
  <Callout type="info">
57
63
  {/* generated:performance latest */}
58
64
 
59
- **Latest results:** Workflow SDK v5.2.0 compared with v4.8.12, measured October 8, 2026. We run these benchmarks regularly and publish updated results here.
65
+ **Latest results:** Workflow SDK v5.8.0 compared with v5.2.0 and v4.8.18, measured November 27, 2026. We run these benchmarks regularly and publish updated results here.
60
66
 
61
67
  {/* end generated:performance latest */}
62
68
  </Callout>
63
69
 
64
70
  {/* generated:performance headline */}
65
71
 
66
- At p75, v5.2.0 is as fast as or faster than v4.8.12 on every benchmark. The largest change is in long runs: 1,000 steps into a run, v5.2.0 adds 70 ms between steps where v4.8.12 adds 1,748 ms.
72
+ At p75 (the median for stream delivery), v5.8.0 is as fast as or faster than v5.2.0 on every benchmark, and faster than v4.8.18 on every benchmark. The largest change from v5.2.0 is in step-to-step overhead: 818 ms on v4.8.18, 260 ms on v5.2.0 and 7 ms on v5.8.0.
67
73
 
68
74
  {/* end generated:performance headline */}
69
75
 
70
- {/* generated:performance caveats */}
71
-
72
- Both versions ran at the same time and shared the platform. The exception is the 1,020-step benchmark on v4: one of its five runs ran alongside v5.2.0's, and the other four ran on their own afterwards, the same day with the same configuration. Each version ran the sequential workflow 10 times, the agent stream 10 times, the fan-out 25 times, the resume benchmark 25 times, and the 1,020-step run 5 times.
73
-
74
- {/* end generated:performance caveats */}
75
-
76
76
  <Image
77
- srcLight="/performance/v5.2.0/01-overview-light.png"
78
- srcDark="/performance/v5.2.0/01-overview-dark.png"
79
- alt="Dot plot of how many times faster the newer version is than the older one at p75 on each benchmark, on a log scale. The full values are in the results table below."
77
+ srcLight="/performance/v5.8.0/01-overview-light.png"
78
+ srcDark="/performance/v5.8.0/01-overview-dark.png"
79
+ alt="Dot plot of how many times faster the latest version is than each earlier one on each benchmark, on a log scale. The full values are in the results table below."
80
80
  width={2016}
81
- height={1444}
81
+ height={2204}
82
82
  />
83
83
 
84
84
  ### Steps and long runs
85
85
 
86
86
  {/* generated:performance sequential */}
87
87
 
88
- At p75, a five-step workflow reaches its first step in 172 ms on v5.2.0 and 418 ms on v4.8.12, and v5.2.0 adds 109 ms between steps where v4.8.12 adds 618 ms.
88
+ At p75, a five-step workflow reaches its first step in 662 ms on v4.8.18, 189 ms on v5.2.0 and 197 ms on v5.8.0. Between steps, it adds 818 ms on v4.8.18, 260 ms on v5.2.0 and 7 ms on v5.8.0.
89
89
 
90
90
  {/* end generated:performance sequential */}
91
91
 
92
92
  {/* generated:performance long-run */}
93
93
 
94
- Through a 1,020-step run, step-to-step overhead on v4.8.12 grows from 622 ms in steps 1 to 20 to 1,748 ms in steps 1,001 to 1,020, at p75. On v5.2.0 it is 110 ms and 70 ms. The median run takes 21.0 min on v4.8.12 and 3.0 min on v5.2.0.
94
+ Through a 1,020-step run, from steps 1 to 20 to steps 1,001 to 1,020, step-to-step overhead at p75 grows from 828 ms to 1,933 ms on v4.8.18, falls from 144 ms to 73 ms on v5.2.0, and falls from 10 ms to 9 ms on v5.8.0. The median run takes 21.8 min on v4.8.18, 3.0 min on v5.2.0 and 1.8 min on v5.8.0.
95
95
 
96
96
  {/* end generated:performance long-run */}
97
97
 
98
98
  <Image
99
- srcLight="/performance/v5.2.0/02-sequential-light.png"
100
- srcDark="/performance/v5.2.0/02-sequential-dark.png"
101
- alt="Three charts comparing the two versions: time to first step and step-to-step overhead for a five-step workflow, step-to-step overhead through a 1,020-step run at p75, and the time to finish all 1,020 steps. The full values are in the results table below."
99
+ srcLight="/performance/v5.8.0/02-sequential-light.png"
100
+ srcDark="/performance/v5.8.0/02-sequential-dark.png"
101
+ alt="Three charts comparing the three versions: time to first step and step-to-step overhead for a five-step workflow, step-to-step overhead through a 1,020-step run at p75 on a log scale, and the time to finish all 1,020 steps. The full values are in the results table below."
102
102
  width={2016}
103
- height={2328}
103
+ height={2746}
104
104
  />
105
105
 
106
106
  ### Fan-out
107
107
 
108
108
  {/* generated:performance fanout */}
109
109
 
110
- At p75, v5.2.0 starts the first of 64 branches in 360 ms against 478 ms on v4.8.12, then starts the slowest branch at about the same time (996 ms against 972 ms) and joins in 448 ms against 464 ms.
110
+ At p75, the first of 64 branches starts in 706 ms on v4.8.18, 1,914 ms on v5.2.0 and 226 ms on v5.8.0. The slowest branch starts in 1,781 ms on v4.8.18, 3,282 ms on v5.2.0 and 1,400 ms on v5.8.0, and the join takes 702 ms on v4.8.18, 717 ms on v5.2.0 and 264 ms on v5.8.0. The first branch started after more than 1 s in 1 of 25 runs on v4.8.18, 8 on v5.2.0 and 5 on v5.8.0. On v5.2.0 those runs are more than a quarter of the 25, so they set its p75.
111
111
 
112
112
  {/* end generated:performance fanout */}
113
113
 
114
114
  <Image
115
- srcLight="/performance/v5.2.0/03-fanout-light.png"
116
- srcDark="/performance/v5.2.0/03-fanout-dark.png"
117
- alt="Dumbbell chart of a 64-branch fan-out at p75, comparing the two versions for the first branch to start, the slowest branch to start, and the join. The full values are in the results table below."
115
+ srcLight="/performance/v5.8.0/03-fanout-light.png"
116
+ srcDark="/performance/v5.8.0/03-fanout-dark.png"
117
+ alt="Chart of a 64-branch fan-out at p75, comparing the three versions for the first branch to start, the slowest branch to start, and the join. The full values are in the results table below."
118
118
  width={2016}
119
- height={804}
119
+ height={1056}
120
120
  />
121
121
 
122
122
  ### Resuming a workflow
123
123
 
124
124
  {/* generated:performance resume */}
125
125
 
126
- At p75, a workflow waiting on a hook resumes in 425 ms on v5.2.0 against 699 ms on v4.8.12.
126
+ At p75, a workflow waiting on a hook resumes in 953 ms on v4.8.18, 562 ms on v5.2.0 and 220 ms on v5.8.0.
127
127
 
128
128
  {/* end generated:performance resume */}
129
129
 
130
130
  <Image
131
- srcLight="/performance/v5.2.0/04-resume-light.png"
132
- srcDark="/performance/v5.2.0/04-resume-dark.png"
133
- alt="Dumbbell chart of time to resume after 1 s idle at p50 and p75, comparing the two versions. The full values are in the results table below."
131
+ srcLight="/performance/v5.8.0/04-resume-light.png"
132
+ srcDark="/performance/v5.8.0/04-resume-dark.png"
133
+ alt="Chart of time to resume after 1 s idle at p50 and p75, comparing the three versions. The full values are in the results table below."
134
134
  width={2016}
135
- height={700}
135
+ height={832}
136
136
  />
137
137
 
138
138
  ### Streams
139
139
 
140
140
  {/* generated:performance streams */}
141
141
 
142
- The agent produced its 2,593-chunk response over 52.4 s. On v4.8.12 the writer step manages about 12 chunks per second, so the response takes 226.1 s to reach the reader. v5.2.0 writes streams over a WebSocket by default, keeps up at about 49 chunks per second, and delivers the response in 53.5 s.
142
+ The agent produced its 2,593-chunk response over 52.4 s. On v4.8.18 the writer step manages about 12 chunks per second, so the response takes 215.1 s to reach the reader. v5.2.0 and v5.8.0 write streams over a WebSocket by default, keep up at about 49 chunks per second, and deliver the response in 54.1 s on v5.2.0 and 53.5 s on v5.8.0.
143
143
 
144
- At p75, a chunk reaches the reader in 102 ms on v5.2.0 against 172 ms on v4.8.12. v5.2.0 had a chunk delayed by over 1 s in 0 of 10 runs, against 6 of 10 on v4.8.12.
144
+ At p75, a chunk reaches the reader in 160 ms on v4.8.18, 94 ms on v5.2.0 and 93 ms on v5.8.0. A chunk was delayed by over 1 s in 6 of 10 runs on v4.8.18, 0 of 10 runs on v5.2.0 and 0 of 10 runs on v5.8.0.
145
145
 
146
146
  {/* end generated:performance streams */}
147
147
 
148
148
  On the Vercel World, [`WORKFLOW_STREAMS_TRANSPORT`](/docs/configuration/worlds#workflow_streams_transport) sets the transport for stream writes.
149
149
 
150
150
  <Image
151
- srcLight="/performance/v5.2.0/05-streams-light.png"
152
- srcDark="/performance/v5.2.0/05-streams-dark.png"
153
- alt="Three charts of a replayed agent stream comparing the two versions: the time to deliver the whole response against the recording's length, chunk trip time at p50 and p75, and the number of runs with a chunk delayed by over 1 s. The full values are in the results table below."
151
+ srcLight="/performance/v5.8.0/05-streams-light.png"
152
+ srcDark="/performance/v5.8.0/05-streams-dark.png"
153
+ alt="Three charts of a replayed agent stream comparing the three versions: the time to deliver the whole response against the recording's length, chunk trip time at p50 and p75, and the number of runs with a chunk delayed by over 1 s. The full values are in the results table below."
154
+ width={2016}
155
+ height={2154}
156
+ />
157
+
158
+ ### Agent loop
159
+
160
+ {/* generated:performance agent-loop */}
161
+
162
+ The loop runs on a benchmark app of its own, deployed once per version, and each version ran it 15 times with streaming and 15 times without.
163
+
164
+ At p75, the five-turn loop that streams its tokens adds 9,814 ms on v4.8.18, 3,394 ms on v5.2.0 and 892 ms on v5.8.0. Without streaming, it adds 7,078 ms on v4.8.18, 2,252 ms on v5.2.0 and 366 ms on v5.8.0, of which 198 ms on v5.8.0 is the time to reach the first step (at p75).
165
+
166
+ On v5.8.0, the streaming loop waits after each model step until its last tokens are stored: the tools start 130 ms after the model step at p75, against 7 ms without streaming.
167
+
168
+ {/* end generated:performance agent-loop */}
169
+
170
+ <Image
171
+ srcLight="/performance/v5.8.0/06-agent-loop-light.png"
172
+ srcDark="/performance/v5.8.0/06-agent-loop-dark.png"
173
+ alt="Chart of the five-turn agent loop's overhead at p75, with and without streaming, comparing the three versions. The full values are in the results table below."
154
174
  width={2016}
155
- height={1628}
175
+ height={872}
156
176
  />
157
177
 
178
+
158
179
  ### All results
159
180
 
160
181
  Every measured value from the latest results. Percentiles follow the [methodology](#methodology) above.
161
182
 
183
+ {/* generated:performance caveats */}
184
+
185
+ All three versions ran at the same time and shared the platform. The fan-out and resume benchmarks ran as three back-to-back sweeps of 10, 10 and 5 runs, and the 1,020-step run as five sweeps of one run, each with all three versions at once. v4.8.18 takes longer to finish the agent stream and the 1,020-step run, so most of its runs of those two finished after the v5 versions had. Each version ran the sequential workflow 10 times, the agent stream 10 times, the fan-out 25 times, the resume benchmark 25 times, the 1,020-step run 5 times, and the agent loop 15 times with streaming and 15 times without.
186
+
187
+ {/* end generated:performance caveats */}
188
+
162
189
  {/* generated:performance table */}
163
190
 
164
- | Metric | v4.8.12 | v5.2.0 | Change | Samples per version |
165
- | --- | --: | --: | --: | --: |
166
- | **Sequential workflow, 5 steps, 10 runs** | | | | |
167
- | Time to first step, p75 | 418 ms | 172 ms | 2.4× faster | 10 runs |
168
- | Time to first step, slowest run | 451 ms | 253 ms | 1.8× faster | 10 runs |
169
- | Step-to-step overhead, p75 | 618 ms | 109 ms | 5.7× faster | 40 gaps |
170
- | Step-to-step overhead, p99 | 777 ms | 327 ms | 2.4× faster | 40 gaps |
171
- | **Long run, 1,020 steps, 5 runs** | | | | |
172
- | Step overhead, steps 1 to 20, p75 | 622 ms | 110 ms | 5.7× faster | 95 gaps |
173
- | Step overhead, steps 101 to 120, p75 | 719 ms | 74 ms | 9.7× faster | 95 gaps |
174
- | Step overhead, steps 1,001 to 1,020, p75 | 1,748 ms | 70 ms | 25.0× faster | 95 gaps |
175
- | Whole run, median wall time | 21.0 min | 3.0 min | 7.0× faster | 5 runs |
176
- | **Fan-out, 64 parallel branches, 25 runs** | | | | |
177
- | First branch starts, p75 | 478 ms | 360 ms | 1.3× faster | 25 runs |
178
- | Slowest branch to start, p75 | 972 ms | 996 ms | No change | 25 runs |
179
- | Join, p75 | 464 ms | 448 ms | No change | 25 runs |
180
- | **Resume after 1 s idle, 25 runs of 5 resumes** | | | | |
181
- | Time to resume, p50 | 619 ms | 383 ms | 1.6× faster | 125 resumes |
182
- | Time to resume, p75 | 699 ms | 425 ms | 1.6× faster | 125 resumes |
183
- | **Agent stream, 52.4 s recording, 10 runs** | | | | |
184
- | Delivery, median wall time | 226.1 s | 53.5 s | 4.2× faster | 10 runs |
185
- | Chunk trip time, p75 | 172 ms | 102 ms | 1.7× faster | 25,930 chunks |
191
+ | Metric | v4.8.18 | v5.2.0 | v5.8.0 | v5.8.0 vs v5.2.0 | v5.8.0 vs v4.8.18 | Samples per version |
192
+ | --- | --: | --: | --: | --: | --: | --: |
193
+ | **Sequential workflow, 5 steps, 10 runs** | | | | | | |
194
+ | Time to first step, p75 | 662 ms | 189 ms | 197 ms | No change | 3.4× faster | 10 runs |
195
+ | Step-to-step overhead, p75 | 818 ms | 260 ms | 7 ms | 37.1× faster | 116.9× faster | 40 gaps |
196
+ | Step-to-step overhead, p99 | 987 ms | 684 ms | 381 ms | 1.8× faster | 2.6× faster | 40 gaps |
197
+ | **Long run, 1,020 steps, 5 runs** | | | | | | |
198
+ | Step overhead, steps 1 to 20, p75 | 828 ms | 144 ms | 10 ms | 14.4× faster | 82.8× faster | 95 gaps |
199
+ | Step overhead, steps 101 to 120, p75 | 884 ms | 98 ms | 7 ms | 14.0× faster | 126.3× faster | 95 gaps |
200
+ | Step overhead, steps 1,001 to 1,020, p75 | 1,933 ms | 73 ms | 9 ms | 8.1× faster | 214.8× faster | 95 gaps |
201
+ | Whole run, median wall time | 21.8 min | 3.0 min | 1.8 min | 1.6× faster | 11.8× faster | 5 runs |
202
+ | **Fan-out, 64 parallel branches, 25 runs** | | | | | | |
203
+ | First branch starts, p75 | 706 ms | 1,914 ms | 226 ms | 8.5× faster | 3.1× faster | 25 runs |
204
+ | Slowest branch to start, p75 | 1,781 ms | 3,282 ms | 1,400 ms | 2.3× faster | 1.3× faster | 25 runs |
205
+ | Join, p75 | 702 ms | 717 ms | 264 ms | 2.7× faster | 2.7× faster | 25 runs |
206
+ | **Resume after 1 s idle, 25 runs of 5 resumes** | | | | | | |
207
+ | Time to resume, p50 | 875 ms | 493 ms | 177 ms | 2.8× faster | 4.9× faster | 125 resumes |
208
+ | Time to resume, p75 | 953 ms | 562 ms | 220 ms | 2.6× faster | 4.3× faster | 125 resumes |
209
+ | **Agent stream, 52.4 s recording, 10 runs** | | | | | | |
210
+ | Delivery, median wall time | 215.1 s | 54.1 s | 53.5 s | No change | 4.0× faster | 10 runs |
211
+ | Chunk trip time, p75 | 160 ms | 94 ms | 93 ms | No change | 1.7× faster | 25,930 chunks |
212
+ | **Agent loop, 5 turns, streaming tokens, 15 runs** | | | | | | |
213
+ | Overhead, p50 | 9,523 ms | 2,913 ms | 695 ms | 4.2× faster | 13.7× faster | 15 runs |
214
+ | Overhead, p75 | 9,814 ms | 3,394 ms | 892 ms | 3.8× faster | 11.0× faster | 15 runs |
215
+ | Model step to tools, p75 | 719 ms | 507 ms | 130 ms | 3.9× faster | 5.5× faster | 60 turns |
216
+ | **Agent loop, 5 turns, without streaming, 15 runs** | | | | | | |
217
+ | Overhead, p50 | 6,812 ms | 2,015 ms | 288 ms | 7.0× faster | 23.7× faster | 15 runs |
218
+ | Overhead, p75 | 7,078 ms | 2,252 ms | 366 ms | 6.2× faster | 19.3× faster | 15 runs |
219
+ | Model step to tools, p75 | 764 ms | 339 ms | 7 ms | 48.4× faster | 109.1× faster | 60 turns |
186
220
 
187
221
  {/* end generated:performance table */}
@@ -282,6 +282,7 @@ The fence is optional. The runtime sends `inBand` only on spec 9 runs, so a Worl
282
282
  - **Fence first.** Decide the fence before anything else the write does. A stale writer must touch no entity row. If the write updates entity state as well as appending, make the check, the update and the append one atomic operation (in Postgres, one transaction that locks the run's counter row first).
283
283
  - **Missing count.** Answer an in-band write without `expectedSeqInBand` with a 400 (`WorkflowWorldError` with `status: 400`).
284
284
  - **Out-of-band creates** (`inBand: false` or absent) allocate unconditionally, move `seq`, and never move `seqInBand`. The fence never refuses them.
285
+ - **Out-of-band `wait_completed`.** On a run stamped at spec version 9 or later, refuse an out-of-band `wait_completed` with a 409 (`WorkflowWorldError` with `status: 409`, `code: 'wait-completion-in-band-only'`) and allocate nothing. The orchestrator runs ahead past a wait that is not about to come due, which is only sound if it is the one that completes it.
285
286
 
286
287
  `world-local`, `world-postgres` and `world-vercel` declare the fence. `world-vercel`'s backend fences in-band writes on every run with an event sequencer (spec version 7 and later). On an older run it answers an in-band write with a 400 (`WorkflowWorldError`, `code: 'in-band-fence-unsupported'`) rather than writing it unfenced, so a writer decides whether to fence from the run's spec version. Its list responses carry the snapshot only where the backend reports one, so a writer there can find none.
287
288
 
@@ -761,6 +762,6 @@ Your World will then appear on the [Worlds ecosystem](/worlds) page with its com
761
762
 
762
763
  ## Supporting spec 9 runs
763
764
 
764
- Everything above is the contract for spec 8 runs, which every World needs. A World may also support spec 9 runs, which it then uses for new runs by default (`WORKFLOW_SPEC_VERSION=8` opts its users out). To do so it implements the [in-band writer fence](#optional-the-in-band-writer-fence), serializes each spec 9 run's orchestrator deliveries, follows the spec 9 queue and deduplication rules, declares `capabilities.inBandFence: true`, and passes it on as `mintedSpecVersion(process.env, { inBandFence: true })`. `mintedSpecVersion()` called with no options never returns 9, so a World that does none of this keeps creating spec 8 runs.
765
+ Everything above is the contract for spec 8 runs, which every World needs. A World may also support spec 9 runs, which it then uses for new runs by default (`WORKFLOW_SPEC_VERSION=8` opts its users out). The Vercel, Local and Postgres Worlds support them, so the rest of the documentation describes spec 9 behavior, and a note marks each place where a spec 8 run behaves differently. To do so it implements the [in-band writer fence](#optional-the-in-band-writer-fence), serializes each spec 9 run's orchestrator deliveries, follows the spec 9 queue and deduplication rules, declares `capabilities.inBandFence: true`, and passes it on as `mintedSpecVersion(process.env, { inBandFence: true })`. `mintedSpecVersion()` called with no options never returns 9, so a World that does none of this keeps creating spec 8 runs.
765
766
 
766
767
  A World that also reserves rate limit slots for [`experimental_rateLimit()`](/docs/api-reference/workflow/rate-limit) declares `capabilities.rateLimits: true` and passes `mintedSpecVersion(process.env, { inBandFence: true, rateLimits: true })`, which makes spec 10 its default instead. A spec 10 run is a spec 9 run that may hold rate events, so everything in this section applies to it. `WorldCapabilities.rateLimits` in `@workflow/world` documents the rate events such a World decides.
@@ -147,9 +147,13 @@ Whether pending and running runs found in the data directory are re-enqueued whe
147
147
 
148
148
  Change it when: several processes or workers run workflows on one data directory. Turn recovery off, or give each one its own `tag` (see [Programmatic configuration](#programmatic-configuration)).
149
149
 
150
- The Local World's queue is in memory, so a restart loses the messages runs had queued. Recovery re-enqueues each run, and that delivery re-arms the run's wait timers (a `sleep()` or a timeout): a spec 8 run suspends on its open waits again, and the recovery marker on the message makes a single-orchestrator (spec 9) delivery send the run's step messages and wait timers again. As a backstop, recovery also sends each recovered run a wake for every open wait due within about 24.8 days (the queue's longest timer), due when the wait is.
150
+ The Local World's queue is in memory, so a restart loses the messages runs had queued. Recovery re-enqueues each run, and the recovery marker on the message makes that delivery send the run's step messages and wait timers (a `sleep()` or a timeout) again. As a backstop, recovery also sends each recovered run a wake for every open wait due within about 24.8 days (the queue's longest timer), due when the wait is.
151
151
 
152
- Recovery also hands back to the queue any step that was running inline when the previous process exited. The step runs again right away instead of after the inline-ownership lease (about 14 minutes), and the interrupted attempt counts toward its retries. A step with `maxRetries: 0` that was interrupted mid-body therefore fails on restart with an "exceeded max retries" error instead of running again once the lease expires, as it already does after a crash on the Vercel World.
152
+ A step that was running inline when the previous process exited runs again on the recovered delivery, and the interrupted attempt counts toward its retries. A step with `maxRetries: 0` that was interrupted mid-body therefore fails instead of running again.
153
+
154
+ <Spec8Note>
155
+ the recovered delivery re-arms the run's wait timers by suspending on its open waits again. Recovery also hands back to the queue any step that was running inline when the previous process exited, so the step runs again right away instead of after the inline-ownership lease (about 14 minutes). A step with `maxRetries: 0` that was interrupted mid-body fails on restart with an "exceeded max retries" error.
156
+ </Spec8Note>
153
157
 
154
158
  If you turn recovery off and re-enqueue runs yourself, call `releaseOrphanedSteps(runId)` before re-enqueueing each run. It is a method of `LocalWorld`, the type `createWorld()` from `@workflow/world-local` returns. The `World` type that `getWorld()` returns does not declare it, so a caller holding a `World` needs the `LocalWorld` type to call it.
155
159
 
@@ -312,7 +312,7 @@ The defaults work for a single process on a local database, so most apps set onl
312
312
  | [`WORKFLOW_POSTGRES_SKIP_WORKERS`](#workflow_postgres_skip_workers) | off | Send work without executing it |
313
313
  | [`WORKFLOW_POSTGRES_HEADERS_TIMEOUT_MS`](#workflow_postgres_headers_timeout_ms) | `0` ms (no deadline) | Hung delivery detection |
314
314
  | [`WORKFLOW_POSTGRES_BODY_TIMEOUT_MS`](#workflow_postgres_body_timeout_ms) | `0` ms (no deadline) | Stalled response detection |
315
- | [`WORKFLOW_POSTGRES_JOB_LOCK_STALE_SECONDS`](#workflow_postgres_job_lock_stale_seconds) | unset: 300 s for spec 9 run-lease jobs only | Redelivery after a process dies |
315
+ | [`WORKFLOW_POSTGRES_JOB_LOCK_STALE_SECONDS`](#workflow_postgres_job_lock_stale_seconds) | unset: 300 s for run-lease jobs only | Redelivery after a process dies |
316
316
  | [`WORKFLOW_POSTGRES_HOOK_RETENTION_LIMIT_DAYS`](#workflow_postgres_hook_retention_limit_days) | `30` days | Maximum hook retention |
317
317
  | [`WORKFLOW_QUEUE_NAMESPACE`](#workflow_queue_namespace) | unset | Queue topic namespace |
318
318
  | [`WORKFLOW_STREAM_FLUSH_INTERVAL_MS`](#workflow_stream_flush_interval_ms) | `0` ms | Stream write batching |
@@ -446,7 +446,11 @@ Change it when: more than one process shares the database, once every one of the
446
446
 
447
447
  A running delivery renews its lock every quarter of the window, and at least every 10 seconds. When a process dies mid-delivery, another process redelivers its jobs within about one and a half windows (about 45 seconds at `30`), instead of after Graphile Worker's fixed 4 hour stale-lock reset or the next restart.
448
448
 
449
- Unset, every delivery still renews its lock, and its worker registers as renewing in `workflow.workflow_job_lock_holders` (migration 0030, which `bootstrap` applies). Then only the jobs holding a spec 9 run's delivery lease (its orchestrator deliveries, and invoke mode's executor lane; migration 0031) are released, after 300 seconds unrenewed, and only those whose holder registered. A spec 9 run whose worker was killed therefore continues within about 8 minutes (one and a half windows) instead of 4 hours. A job held by a process on an earlier version, which does not register, is never released this way, so the default is safe during a rolling upgrade. `0` turns renewal and release off.
449
+ Unset, every delivery still renews its lock, and its worker registers as renewing in `workflow.workflow_job_lock_holders` (migration 0030, which `bootstrap` applies). Then only the jobs holding a run's delivery lease (its orchestrator deliveries, and invoke mode's executor lane; migration 0031) are released, after 300 seconds unrenewed, and only those whose holder registered. A run whose worker was killed therefore continues within about 8 minutes (one and a half windows) instead of 4 hours. A job held by a process on an earlier version, which does not register, is never released this way, so the default is safe during a rolling upgrade. `0` turns renewal and release off.
450
+
451
+ <Spec8Note>
452
+ a run's jobs hold no delivery lease, so unset releases none of them: a job a killed worker held waits for Graphile Worker's 4 hour reset or the next restart. Set this option to have them released.
453
+ </Spec8Note>
450
454
 
451
455
  Keep the value well above the longest a process can go without running its timers (synchronous work that blocks the event loop) or getting a pool connection. A delivery whose renewals stall past the window is redelivered while it still runs.
452
456
 
@@ -595,7 +599,7 @@ The Postgres World uses PostgreSQL as a durable backend:
595
599
 
596
600
  - **Storage**: Workflow runs, events, steps, and hooks are stored in PostgreSQL tables.
597
601
  - **Job queue**: [graphile-worker](https://github.com/graphile/worker) handles reliable job processing with retries.
598
- - **Crash recovery**: The next `start()` re-enqueues active runs, except a run parked on a hook or a wait that is not yet due with no wake left to deliver and no delivery in progress. A run's recovery job is keyed by the run, so repeated boots do not stack duplicates. A running delivery also renews its job lock. If its process dies, any other process redelivers a spec 9 run's orchestrator job once its lock has gone unrenewed for 300 seconds, and with [`WORKFLOW_POSTGRES_JOB_LOCK_STALE_SECONDS`](#workflow_postgres_job_lock_stale_seconds) set, any job of this World once its lock has gone unrenewed for that many seconds.
602
+ - **Crash recovery**: The next `start()` re-enqueues active runs, except a run parked on a hook or a wait that is not yet due with no wake left to deliver and no delivery in progress. A run's recovery job is keyed by the run, so repeated boots do not stack duplicates. A running delivery also renews its job lock. If its process dies, any other process redelivers a run's orchestrator job once its lock has gone unrenewed for 300 seconds, and with [`WORKFLOW_POSTGRES_JOB_LOCK_STALE_SECONDS`](#workflow_postgres_job_lock_stale_seconds) set, any job of this World once its lock has gone unrenewed for that many seconds.
599
603
  - **Streaming**: PostgreSQL NOTIFY/LISTEN enables real-time event distribution. If the database drops the `LISTEN` connection, the World reconnects every second and re-reads persisted chunks for open stream readers, so readers don't miss chunks written during the outage.
600
604
 
601
605
  This architecture ensures workflows survive application restarts with all state reliably persisted. For implementation details, see the [source code](https://github.com/vercel/workflow/tree/main/packages/world-postgres).
@@ -626,11 +626,11 @@ For more details, see the [Vercel Workflow documentation](https://vercel.com/doc
626
626
 
627
627
  With [`WORKFLOW_STREAMS_TRANSPORT`](#workflow_streams_transport) at its default, the client only offers the upgrade. The server accepts or declines each one, and a writer whose upgrade is declined or fails writes over HTTP for the rest of its lifetime. This setting does not decide which tenants may upgrade and does not infer server support from package versions. The protocol route (`/websockets/v1`) is versioned independently from REST v2/v4 and persisted workflow `specVersion` values.
628
628
 
629
- A writer's first write group always goes over HTTP, and so does its second. The socket starts opening in the background once the second group's request is sent, and later groups keep going over HTTP until it opens, so no write waits for the upgrade. A writer that closes after one or two groups never uses the socket. If the socket has not opened within 10 seconds, or the upgrade fails or is declined, the writer stays on HTTP.
629
+ A writer that starts without a socket sends its first and second write groups over HTTP. The socket starts opening in the background once the second group's request is sent, and later groups keep going over HTTP until it opens, so no write waits for the upgrade. If the socket has not opened within 10 seconds, or the upgrade fails or is declined, the writer stays on HTTP.
630
630
 
631
631
  Writes and close requests execute serially, so a write never overtakes an earlier one on the other transport. After the socket accepts a write, a missing acknowledgement has an unknown outcome: the writer fails rather than replaying the write over HTTP and risking a duplicate append. A throttled (429) write or close did not apply, so the writer retries it after the server's `Retry-After`, as the HTTP writer does, on the socket if it stays open (or its replacement, after a drain) and otherwise over HTTP. Past 30 seconds of cumulative wait, the write moves to HTTP, whose own 429 retry applies. A close that fails with a 5xx is retried over HTTP, since close is idempotent.
632
632
 
633
- Once a released writer's writes drain, its socket closes without closing the shared stream, and later writes through that same handle go over HTTP. Writers acquired with `getWritable()` inside a step release their socket when the step completes. External `getRun(runId).getWritable()` handles release it on the first `releaseLock()` after pending writes drain, so hold the writer lock for the whole burst to keep writing over the socket.
633
+ Once a released writer's writes drain, it hands its socket, without closing the shared stream, to the next writer of the same run and stream in the same function instance, and later writes through the released handle go over HTTP. The next writer sends its writes, starting with its first group, over that socket, so consecutive steps that write to one stream pay for one handshake. A writer whose first operation is a close sends it over HTTP. A socket that is still opening when its writer is released is handed on once it opens. Only one writer uses a socket at a time. An idle socket keeps its function invocation open and closes after 2 seconds, or as soon as the server drains or closes it. The server attributes a connection's requests to the writer that opened it, so on a reused socket server-side records show the earlier writer's id. Writers acquired with `getWritable()` inside a step release their socket when the step completes. External `getRun(runId).getWritable()` handles release it on the first `releaseLock()` after pending writes drain, so hold the writer lock for the whole burst to keep writing over the socket.
634
634
 
635
635
  Before routine authentication expiry or server max duration, the server sends a v1 `drain` control. The client stops sending, lets an already-admitted request receive its reply, and reconnects after the server closes with code 1001. If the new socket is not open within 250 ms, the writer continues over HTTP. Authentication drains re-resolve a fresh bearer. A request that was sent but receives no reply before close still has an unknown outcome and is never replayed.
636
636
 
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "workflow",
3
- "version": "5.8.0",
3
+ "version": "5.8.1",
4
4
  "description": "Workflow SDK - Build durable, resilient, and observable workflows",
5
5
  "main": "dist/typescript-plugin.cjs",
6
6
  "type": "module",
@@ -60,19 +60,19 @@
60
60
  }
61
61
  },
62
62
  "dependencies": {
63
- "@workflow/astro": "5.0.15",
64
- "@workflow/cli": "5.3.3",
65
- "@workflow/core": "5.8.0",
66
- "@workflow/errors": "5.2.0",
63
+ "@workflow/astro": "5.0.16",
64
+ "@workflow/cli": "5.3.4",
65
+ "@workflow/core": "5.8.1",
66
+ "@workflow/errors": "5.2.1",
67
67
  "@workflow/typescript-plugin": "5.0.1",
68
68
  "@workflow/utils": "5.1.1",
69
69
  "ms": "2.1.3",
70
- "@workflow/next": "5.1.6",
71
- "@workflow/nest": "5.1.13",
72
- "@workflow/nitro": "5.0.15",
73
- "@workflow/nuxt": "5.0.15",
74
- "@workflow/sveltekit": "5.0.15",
75
- "@workflow/rollup": "5.0.15"
70
+ "@workflow/next": "5.1.7",
71
+ "@workflow/nest": "5.1.14",
72
+ "@workflow/nitro": "5.0.16",
73
+ "@workflow/nuxt": "5.0.16",
74
+ "@workflow/sveltekit": "5.0.16",
75
+ "@workflow/rollup": "5.0.16"
76
76
  },
77
77
  "devDependencies": {
78
78
  "@types/ms": "2.1.0",