workflow 5.3.0 → 5.5.0
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.
- package/dist/observability.d.ts +1 -1
- package/dist/observability.d.ts.map +1 -1
- package/dist/observability.js +2 -2
- package/docs/ai/chat-session-modeling.mdx +1 -1
- package/docs/ai/resumable-streams.mdx +1 -1
- package/docs/api-reference/workflow/create-hook.mdx +3 -3
- package/docs/api-reference/workflow/create-webhook.mdx +1 -1
- package/docs/api-reference/workflow/fetch.mdx +1 -5
- package/docs/api-reference/workflow/get-step-metadata.mdx +19 -0
- package/docs/api-reference/workflow-ai/durable-agent.mdx +2 -1
- package/docs/api-reference/workflow-ai/workflow-chat-transport.mdx +4 -4
- package/docs/api-reference/workflow-api/get-hook-by-token.mdx +2 -2
- package/docs/api-reference/workflow-api/resume-hook.mdx +2 -2
- package/docs/api-reference/workflow-api/start.mdx +12 -8
- package/docs/api-reference/workflow-errors/hook-conflict-error.mdx +2 -2
- package/docs/api-reference/workflow-errors/index.mdx +1 -1
- package/docs/api-reference/workflow-errors/workflow-run-cancelled-error.mdx +1 -1
- package/docs/api-reference/workflow-errors/workflow-run-failed-error.mdx +1 -1
- package/docs/api-reference/workflow-errors/workflow-start-error.mdx +5 -5
- package/docs/api-reference/workflow-next/with-workflow.mdx +57 -0
- package/docs/api-reference/workflow-observability/create-state-resolver.mdx +56 -0
- package/docs/api-reference/workflow-observability/index.mdx +5 -0
- package/docs/api-reference/workflow-observability/meta.json +1 -0
- package/docs/api-reference/workflow-runtime/world/storage.mdx +2 -3
- package/docs/changelog/attributes-mvp.mdx +1 -1
- package/docs/changelog/batched-event-writes.mdx +0 -2
- package/docs/changelog/eager-processing.mdx +3 -1
- package/docs/changelog/lazy-event-creation.md +1 -1
- package/docs/changelog/spec-9.mdx +268 -120
- package/docs/changelog/step-message-ownership.mdx +2 -7
- package/docs/configuration/build-and-diagnostics.mdx +2 -0
- package/docs/configuration/cli-and-web-ui.mdx +13 -2
- package/docs/configuration/framework-options.mdx +7 -0
- package/docs/configuration/runtime-tuning.mdx +26 -74
- package/docs/configuration/worlds.mdx +55 -23
- package/docs/cookbook/advanced/child-workflows.mdx +126 -186
- package/docs/cookbook/agent-patterns/human-in-the-loop.mdx +1 -1
- package/docs/cookbook/common-patterns/idempotency.mdx +2 -2
- package/docs/cookbook/common-patterns/sequential-and-parallel.mdx +1 -1
- package/docs/cookbook/common-patterns/workflow-composition.mdx +5 -5
- package/docs/cookbook/integrations/ai-sdk.mdx +2 -2
- package/docs/errors/corrupted-event-log.mdx +1 -1
- package/docs/errors/fetch-in-workflow.mdx +15 -35
- package/docs/errors/hook-force-claimed.mdx +1 -1
- package/docs/errors/runtime-decryption-failed.mdx +1 -1
- package/docs/foundations/errors-and-retries.mdx +3 -1
- package/docs/foundations/hooks.mdx +1 -1
- package/docs/foundations/idempotency.mdx +11 -11
- package/docs/foundations/serialization.mdx +80 -0
- package/docs/foundations/starting-workflows.mdx +3 -7
- package/docs/getting-started/next.mdx +2 -0
- package/docs/how-it-works/event-sourcing.mdx +2 -2
- package/docs/observability/index.mdx +2 -0
- package/docs/whats-new.mdx +4 -4
- package/docs/worlds/building-a-world.mdx +22 -7
- package/docs/worlds/local.mdx +11 -7
- package/docs/worlds/postgres.mdx +17 -24
- package/docs/worlds/upgrading-to-v5.mdx +3 -3
- package/docs/worlds/vercel.mdx +13 -12
- package/package.json +14 -14
|
@@ -182,8 +182,7 @@ a normal return, not an error, and a missing run throws
|
|
|
182
182
|
also return a non-terminal snapshot before `timeoutMs` is up. Callers pace
|
|
183
183
|
their own retries (`await run.returnValue` keeps consecutive non-terminal
|
|
184
184
|
observations at least one `WORKFLOW_RETURN_VALUE_POLL_INTERVAL_MS` apart), and
|
|
185
|
-
worlds that omit the method are polled on that interval instead.
|
|
186
|
-
`WORKFLOW_RETURN_VALUE_LONG_POLL=0` to force interval polling everywhere.
|
|
185
|
+
worlds that omit the method are polled on that interval instead.
|
|
187
186
|
</Callout>
|
|
188
187
|
|
|
189
188
|
### runs.list()
|
|
@@ -352,7 +351,7 @@ Look up a hook by its token. Useful in webhook resume flows where you receive a
|
|
|
352
351
|
<Callout type="info">
|
|
353
352
|
For runtime application code, prefer [`getHookByToken()`](/docs/api-reference/workflow-api/get-hook-by-token). Use `world.hooks.getByToken()` when you are working directly with the World storage interface for custom tooling, admin views, or low-level integrations.
|
|
354
353
|
|
|
355
|
-
Hook-token lookup is the low-level form of the recommended idempotency flow: if a hook is already registered for your business key, reuse the hook's `runId` or resume that hook instead of starting another run. If no hook exists yet, start the workflow with [`start({
|
|
354
|
+
Hook-token lookup is the low-level form of the recommended idempotency flow: if a hook is already registered for your business key, reuse the hook's `runId` or resume that hook instead of starting another run. If no hook exists yet, start the workflow with [`start({ experimental_hook: { token } })`](/docs/api-reference/workflow-api/start#prevent-duplicate-starts), which creates the Hook atomically with the run and refuses a duplicate with `HookConflictError` naming the owner. On a World without atomic start Hooks, have the workflow create the deterministic hook near the beginning and check `await hook.getConflict()` to detect whether another run claimed the token first. See [Run idempotency](/docs/foundations/idempotency#run-idempotency).
|
|
356
355
|
</Callout>
|
|
357
356
|
|
|
358
357
|
```typescript lineNumbers
|
|
@@ -301,7 +301,7 @@ Integration tests in `world-postgres`:
|
|
|
301
301
|
- Upsert, merge across calls, unset via `null` (the SQL `jsonb_set` / `-` chain is exercised through these)
|
|
302
302
|
- Atomic cap enforcement inside the `UPDATE`'s `WHERE` clause; concurrent writers cannot collectively push past the per-run cap
|
|
303
303
|
|
|
304
|
-
End-to-end in `workbench/nextjs-turbopack` (exercises the full SWC plugin + workflow VM + step worker + `world-vercel` wire path against the production
|
|
304
|
+
End-to-end in `workbench/nextjs-turbopack` (exercises the full SWC plugin + workflow VM + step worker + `world-vercel` wire path against the production `world-vercel` backend `/v2/runs/:runId/attributes` endpoint):
|
|
305
305
|
|
|
306
306
|
- Awaited workflow-body calls dispatch through the `__builtin_set_attributes` step bridge and merge correctly (the test inspects the run's event log to confirm a `step_created` / `step_completed` pair was emitted)
|
|
307
307
|
- Fire-and-forget (`void experimental_setAttributes`) attributes land before the run terminates
|
|
@@ -72,8 +72,6 @@ Per-event `409`s are tolerated the same way the single path tolerates `EntityCon
|
|
|
72
72
|
|
|
73
73
|
`createBatch` is optional, so today only the Vercel World folds at all: every other World keeps the single-event path and never sends a pair.
|
|
74
74
|
|
|
75
|
-
**Escape hatch**: Set `WORKFLOW_BATCH_TRANSITIONS=0` (or `false`) to disable batching and restore the exact prior one-write-per-event path. See [`WORKFLOW_BATCH_TRANSITIONS`](/docs/configuration/worlds#workflow_batch_transitions).
|
|
76
|
-
|
|
77
75
|
## Follow-up
|
|
78
76
|
|
|
79
77
|
The deferred sequential transition (holding `step_completed(N)` across the replay turn and committing `[step_completed(N), step_created(N+1), step_started(N+1)]` as one batch at the next lazy start) builds on this contract and ships separately.
|
|
@@ -78,7 +78,7 @@ Each background step message is handled by a separate function invocation of the
|
|
|
78
78
|
- **Steps still pending**: The handler returns without queuing a continuation. The last handler to complete its step will see all steps done and replay inline.
|
|
79
79
|
- **Pending ops (stream writes)**: The handler queues a continuation and returns, so `waitUntil` can flush the pending stream data.
|
|
80
80
|
|
|
81
|
-
The inline steps of one invocation do not wait for each other. When one of them completes while its siblings are still running, the handler replays the workflow right away, so the branch it belongs to can start its next step inline. The siblings stay owned by this handler. If the workflow returns or throws first, the run ends right away; the handler still lets the siblings' bodies finish before it returns, so their step events can follow `run_completed` or `run_failed` in the log, and a sibling whose attempt fails retryably is not retried.
|
|
81
|
+
The inline steps of one invocation do not wait for each other. When one of them completes while its siblings are still running, the handler replays the workflow right away, so the branch it belongs to can start its next step inline. The siblings stay owned by this handler. If the workflow returns or throws first, the run ends right away; the handler still lets the siblings' bodies finish before it returns, so their step events can follow `run_completed` or `run_failed` in the log, and a sibling whose attempt fails retryably is not retried.
|
|
82
82
|
|
|
83
83
|
### Convergence after parallel steps
|
|
84
84
|
|
|
@@ -157,6 +157,8 @@ To prevent deadlock when polling is executed inline by the step executor, `Run#p
|
|
|
157
157
|
|
|
158
158
|
**Follow-up**: Replace the worker-pool sizing requirement with a polling design that does not occupy a worker slot. Options under consideration: moving child-completion polling out of the step body into the suspension layer, or emitting a `run_completed` notification on the parent's stream/queue so the parent only resumes when the child actually finishes.
|
|
159
159
|
|
|
160
|
+
**Update**: A parent awaiting `returnValue` of a child it started now suspends on a system hook the child resumes when it finishes, so it holds no worker slot while it waits. Only `returnValue` awaits that fall back to polling (inside a step, or with `WORKFLOW_CHILD_RUN_COMPLETION_HOOK=0`) still count toward this sizing. See [Child Workflows](/cookbook/advanced/child-workflows#how-the-parent-waits).
|
|
161
|
+
|
|
160
162
|
### Mixed suspensions
|
|
161
163
|
|
|
162
164
|
A suspension may contain steps, hooks, and waits simultaneously. The handler creates events for all, then dispatches everything we are not running inline as a single parallel batch of queue messages:
|
|
@@ -89,7 +89,7 @@ A follow-up builds two more latency wins on top of lazy inline start. Both are c
|
|
|
89
89
|
|
|
90
90
|
Previously the owned-inline path ran **exactly one** step inline per suspension and queued the rest. For a `Promise.all([stepA(), stepB(), stepC()])` fan-out that meant one branch ran inline while the others paid a queue round-trip each before making any progress.
|
|
91
91
|
|
|
92
|
-
The suspension handler now defers `step_created` for up to **`WORKFLOW_MAX_INLINE_STEPS` (default 3)** steps and returns them as `lazyInlineSteps`. The runtime runs that batch inline **in parallel**, each via its own lazy `step_started`, and queues only the steps beyond the cap.
|
|
92
|
+
The suspension handler now defers `step_created` for up to **`WORKFLOW_MAX_INLINE_STEPS` (default 3)** steps and returns them as `lazyInlineSteps`. The runtime runs that batch inline **in parallel**, each via its own lazy `step_started`, and queues only the steps beyond the cap. The runtime replays as soon as one step of the batch settles, so steps still running hold their slots and a later suspension gets fewer.
|
|
93
93
|
|
|
94
94
|
- **Selection:** the first N uncreated steps, matching the previous single-step inline candidate. Steps beyond N keep their eager `step_created` and are queued exactly as before.
|
|
95
95
|
- **Result aggregation:** `retry` steps (whose `step_started` succeeded, so the step exists) are re-queued per-step as background steps with their own delay. `throttled` steps are different: a throttle rejects the lazy `step_started` on the create-claim, so the step was *never created* and has no recoverable input. Re-queuing it as an input-less background step would make the world reject the bare `step_started` with "Step not found" and redeliver until it fails. Any throttle instead **defers redelivery of the orchestrator** (by the longest throttle backoff in the batch), which re-runs the throttled step inline *with its input* on replay. The runtime only loops back to replay in-process once every inline step has reached a terminal state.
|