Commit Graph

296 Commits

Author SHA1 Message Date
Nathan Colosimo 49a50e83d9 Document configuration environment variables (v5) (#2468) 2026-07-07 17:56:41 -07:00
Ben Sabic 5b7fa7cf15 chore(docs): update eve link (#2738)
eve homepage is now live, change the link from the docs to the homepage now, reflecting how the other OSS sites behave

Signed-off-by: Ben Sabic <bensabic@users.noreply.github.com>
Co-authored-by: Ben Sabic <bensabic@users.noreply.github.com>
2026-07-01 10:42:18 -07:00
Nathan Colosimo 3077b8a803 fix(nitro): use workspaceDir for monorepos (#2713)
* fix(nitro): use workspaceDir for monorepos

* test: stabilize Next canary HMR e2e
2026-06-30 13:42:53 -07:00
Nathan Colosimo 65f1dbc889 Fail fast on incompatible workflow worlds (#2659) 2026-06-30 10:43:39 -07:00
Nathan Colosimo 692a6ac5dc Upgrade workspace to TypeScript 6 (#2700)
* Upgrade workspace to TypeScript 6

* Restore Nest baseUrl for SWC builds

* Use empty changeset for TS6 upgrade

* Remove TS6 changeset
2026-06-30 05:37:38 +00:00
Peter Wielander eff215ceec [ai] Drop orphan UI chunks after negative-index reconnect (#2082) 2026-06-26 14:22:29 -07:00
Pranay Prakash 92cb05505f docs: deprecate DurableAgent and WorkflowChatTransport, point to AI SDK WorkflowAgent (#2616)
- Add deprecation banners (with migration-guide link) to the DurableAgent and
  WorkflowChatTransport API references in v4 and v5; keep the full API surface intact
- Bring v4 headline guides to parity with v5's WorkflowAgent migration (ai/index,
  foundations/streaming, the cookbook recipe + index)
- Convert standard agent examples (defining-tools, message-queueing) to WorkflowAgent
  and reframe the streamText-vs comparison page
- Banner + repoint the deep recipes that stream custom UIMessageChunk data parts
  (chat-session-modeling, human-in-the-loop, agent-cancellation, serializable-steps) —
  that pattern doesn't map to WorkflowAgent's ModelCallStreamPart model, so their
  legacy DurableAgent examples are kept behind a clear deprecation banner
- Point all WorkflowChatTransport examples at the @ai-sdk/workflow 1:1 port
- Rename the cookbook agent-patterns recipe to WorkflowAgent

Co-authored-by: Claude Opus 4.8 <noreply@anthropic.com>
2026-06-25 21:59:45 -07:00
Nathan Colosimo 361ce23b0f fix(world-postgres): rename setup command (#2644) 2026-06-25 23:32:50 +00:00
christopherkindl 04ee1ce31d docs: use actual eve logo and tidy OSS nav dropdown (#2586)
Swap the text-based eve placeholder for the real eve wordmark (hard-copied
SVG from @vercel/geistcn-assets, themed via currentColor) and drop Streamdown
so AI Elements is last.

Co-authored-by: Claude Opus 4.8 (1M context) <noreply@anthropic.com>
Co-authored-by: Pranay Prakash <pranay.gp@gmail.com>
2026-06-23 11:31:34 -07:00
Peter Wielander d108ba32a7 [core] Turbo: skip the unused run_started event-log preload (#2569) 2026-06-22 15:53:00 -07:00
Pranay Prakash 6fad87b2a4 docs: derive section landing-page cards from the page tree + lint drift (#2567)
Section index card grids (e.g. foundations) were hand-written and drifted
from the sidebar (meta.json) and the actual pages. Make them derive from
the fumadocs page tree (single source of truth) and add CI lint so the
card grid and navigation can't fall out of sync again.

- resolveSectionChildren + <AutoCards/>, bound in both v4 and v5 docs
  routes (correct /docs vs /v5/docs URL spaces)
- getLLMText expands <AutoCards/> so llms.txt/.md/copy-page keep child links
- manualCards frontmatter opt-out for curated pages (source.config.ts)
- checkSectionCards (card<->nav completeness) + checkMetaEntriesResolve
  (dangling meta entries) in scripts/lint.ts
- convert foundations + errors (drift fixes) and v5 observability to AutoCards
- mark deploying + ai as manualCards (intentionally curated)
- remove dangling meta entries: v4 cancellation (x2), root introduction
  (x2), v4/internal serializable-abort-controller

Co-authored-by: Claude Opus 4.8 <noreply@anthropic.com>
2026-06-22 14:37:35 -07:00
Peter Wielander 9f1a3110f2 [docs] Document minimum SDK version for using hook.getConflict (#2423) 2026-06-22 13:15:30 -07:00
Peter Wielander 3e82a12712 [core] Turbo mode: fast-path the first invocation (#2526)
On the first delivery of a run's first invocation, background run_started,
skip the initial event-log load, and force optimistic inline start so the run
reaches its first steps with no preceding network round-trips. Safe because the
first delivery has no concurrent handler to race the step create-claim; turbo
exits the moment a suspension creates a hook or wait, and is a no-op for every
other invocation. On by default; disable with WORKFLOW_TURBO=0.
2026-06-22 11:42:46 -07:00
JJ Kasper 57cccaf373 Remove lazy discovery from workflow/next (#2545) 2026-06-22 13:14:35 -05:00
Ben Sabic 5377e880c7 feat(docs): add eve and AI SDK to product switcher (#2543)
Wire the existing AI SDK logo into the OSS product switcher (above Flags
SDK) and add a new eve entry (text wordmark + Beta badge, linking to
eve.dev/docs) above it at the top of the list.

Co-authored-by: Ben Sabic <bensabic@users.noreply.github.com>
2026-06-20 09:40:26 -07:00
Peter Wielander b713d8417b [builders] Fix unicode-escape crash in workflow graph extraction (#2324)
Signed-off-by: EfeDurmaz16 <efebarandurmaz05@gmail.com>
Co-authored-by: EfeDurmaz16 <efebarandurmaz05@gmail.com>
2026-06-19 20:04:27 -07:00
Pranay Prakash 37312edd0a Default source maps to dev-on / prod-off (#2529)
* Default source maps to dev-on / prod-off

Inline source maps are embedded in the step bundle and the intermediate
workflow VM bundle, which bloats production function bundles (a problem for
the Vercel 250MB limit) even though maps only help when reading a stack trace.

Make the default environment-aware in @workflow/builders: inline in
development (next dev / nitro dev / Vite-based dev servers, detected via
config.watch or NODE_ENV=development) and off in production. The `sourcemap`
config option and `WORKFLOW_SOURCEMAP` env var still override in either
environment. A production build with no override also drops the
source-map-support shim from the Vercel step function.

Keep runtime stack remapping graceful and fast when maps are absent
(@workflow/core): short-circuit when no frame references the workflow file
and memoize the parsed map (or its absence) per bundle, so production failures
don't rescan the bundle.

Co-Authored-By: Claude Opus 4.8 <noreply@anthropic.com>

* test(e2e): make source-map expectations match dev-on/prod-off default

The e2e error-stack tests gate source-map assertions on hasWorkflowSourceMaps()
and hasStepSourceMaps(). Now that source maps default to off in production
builds, update those helpers:

- hasWorkflowSourceMaps(): false for all production builds (local prod,
  postgres, Vercel — keyed off DEV_TEST_CONFIG), and exclude nest in dev (the
  Nest integration builds with watch:false / no NODE_ENV=development, so its
  bundles have no maps).
- hasStepSourceMaps(): nest now resolves to a production build (maps off) in
  both dev and prod.

Add unit cases for the dev-vs-prod and nest behavior.

Co-Authored-By: Claude Opus 4.8 <noreply@anthropic.com>

---------

Co-authored-by: Claude Opus 4.8 <noreply@anthropic.com>
2026-06-18 16:28:26 -07:00
Peter Wielander 84ccd40ea3 perf(core): parallel inline steps + optimistic lazy step start (#2516) 2026-06-18 16:03:21 -07:00
Pranay Prakash cb181392b9 feat(cli): print run deep links with --url, fix dashboard route (#2467)
Add a `--url` flag to `inspect`/`web` that prints a run's observability
dashboard deep link to stdout and exits — no browser, no local server —
so scripts and agents can share a link instead of opening a UI.

Fix the Vercel dashboard URL to the current
`…/workflows/runs/<id>?environment=<env>` route (drop the legacy
`/observability` segment) and respect `--env`. Apply the same route fix
to the e2e helpers, CI aggregation scripts, and the nextjs-turbopack
workbench. Document deep-linking in the workflow skill and observability
docs.

Co-authored-by: Claude Opus 4.8 <noreply@anthropic.com>
2026-06-16 17:37:03 -07:00
Pranay Prakash 5f0b845211 RFC: compress serialized payload refs — zstd (gzip fallback), specVersion 5 (#2394)
* feat(core,world): gzip-compress serialized payloads behind specVersion 5

Add a composable 'gzip' format prefix layer to the serialization
pipeline (compress before encrypt: encr(gzip(devl))), cutting stored
payload bytes by ~70-87% on real-world-style workloads. Compression is
gated on run specVersion 5 (new SPEC_VERSION_SUPPORTS_COMPRESSION) and
on target-deployment capabilities for cross-deployment writes; payloads
under 1KB or that don't compress meaningfully are stored unchanged.
Reads dispatch on the format prefix so both compressed and uncompressed
data are always readable. WORKFLOW_DISABLE_COMPRESSION=1 disables
writes.

Co-Authored-By: Claude Fable 5 <noreply@anthropic.com>

* test(core): add CPU/perf compression benchmark + shared workloads

Split the compression benchmark into reproducible size and CPU scripts
sharing deterministic workloads (lib/workloads.mjs). The CPU benchmark
measures serialize/deserialize overhead per payload, total CPU across
thousands of events, and compares gzip levels/brotli/deflate. Documents
how to run the size, CPU, and end-to-end (bench.bench.ts) benchmarks
against local and Vercel in scripts/README.md.

Co-Authored-By: Claude Fable 5 <noreply@anthropic.com>

* feat(world-vercel): advertise specVersion 5 to enable compression on Vercel

Now that workflow-server declares spec-5 support (vercel/workflow-server#520),
bump the Vercel world's advertised specVersion from 4 to 5 so new Vercel runs
are stamped spec 5 and become eligible for gzip payload compression. Payloads
stay opaque to the server (compression is client-side); spec 5 is a superset of
spec 4, so initial run attributes still work.

Co-Authored-By: Claude Fable 5 <noreply@anthropic.com>

* feat(core): emit OTel span attributes for compression impact

Track gzip payload compression on both the serialize (write) and
deserialize (read) paths via span attributes:
workflow.serialization.{operation,compressed,uncompressed_bytes,
stored_bytes,compression_ratio}. Sizes are measured at the compression
boundary (pre-encryption), so they reflect compression's effect rather
than the at-rest size.

The compression codec stays pure — compress/decompress optionally
populate a CompressionStats sink, threaded through CodecOptions to the
mode serializers and read by the dehydrate/hydrate wrappers, which set
attributes on the active span. Telemetry failures are swallowed so they
can never break the serialize/deserialize data path.

Co-Authored-By: Claude Fable 5 <noreply@anthropic.com>

* feat(core,web-shared): prefer zstd compression codec (gzip fallback)

Switch the payload compression codec to zstd, which benchmarks 3–7×
faster than gzip at an equal-or-better ratio on representative workloads
(compression runs at every step boundary, so the write CPU is a per-step
tax). zstd uses node:zlib (>= 22.15); gzip via the portable
CompressionStream remains the fallback when zstd is unavailable, and
WORKFLOW_COMPRESSION_CODEC=gzip forces it. Reads dispatch on the format
prefix, so 'zstd' and 'gzip' payloads are both always decodable.

zstd is Node-only (Web CompressionStream has no zstd), so the browser
o11y read path registers a WASM-backed decoder (@tootallnate/zstd-wasm)
via a new registerZstdDecoder hook; node:zlib handles Node-side reads
(runtime replay, CLI, server o11y). A new workflow.serialization.codec
span attribute reports which codec applied. gzip and zstd read support
co-ship, so the existing specVersion-5 capability gate is unchanged.

Verified end-to-end: spec-5 runs store zstd-prefixed payloads on disk
and replay/complete correctly; the WASM decoder round-trips node:zlib
zstd output. Benchmarks updated to compare zstd vs gzip.

Co-Authored-By: Claude Fable 5 <noreply@anthropic.com>

---------

Co-authored-by: Claude Fable 5 <noreply@anthropic.com>
2026-06-16 23:27:47 +00:00
Pranay Prakash 4b7a7203bf fix(core): make deploymentId 'latest' a no-op in non-Vercel worlds (#2397)
* fix(core): make deploymentId 'latest' a no-op in non-Vercel worlds

Previously, start({ deploymentId: 'latest' }) threw a WorkflowRuntimeError
in any World that doesn't implement resolveLatestDeploymentId() (local dev,
Postgres). That meant a workflow which opts into 'latest' on Vercel would
fail outright in local development.

Resolving 'latest' only means something in worlds with atomic, immutable
deployments. In other worlds there is nothing to resolve between, so instead
of throwing we now log a warning and fall back to the current deployment,
making 'latest' an effective no-op there.

- start.ts: warn + fall back to currentDeploymentId instead of throwing
- start.test.ts: replace the "should throw" test with a warn + fallback test
- e2e.test.ts: assert 'latest' completes (no-op) on non-Vercel worlds
- docs: note the no-op behavior in v4 + v5 start.mdx

Co-Authored-By: Claude Opus 4.8 <noreply@anthropic.com>

* fix(core): warn once for deploymentId 'latest' no-op; harden test cleanup

Address PR review:
- Gate the 'latest'-has-no-effect warning behind a once-per-process guard
  (mirrors the warnOnce pattern in constants.ts) so a workflow that hardcodes
  'latest' for Vercel doesn't flood local/Postgres dev logs on every run.
  Exposes _resetLatestNoOpWarnForTests() (@internal) for unit tests.
- start.test.ts: reset the guard in beforeEach and restore spies in afterEach
  via vi.restoreAllMocks() so a throwing assertion can't leak the
  runtimeLogger.warn spy into later tests; drop the manual mockRestore().
- Add a test asserting the warning fires exactly once across repeated
  'latest' starts while every run still falls back to the current deployment.

Co-Authored-By: Claude Opus 4.8 <noreply@anthropic.com>

---------

Co-authored-by: Claude Opus 4.8 <noreply@anthropic.com>
2026-06-16 16:09:49 -07:00
Karthik Kalyan 926a5e7c6a otel: explicit traceparent injection + linked-trace mode for bounded per-invocation traces (#2363)
* otel: explicit traceparent injection + linked-trace mode for bounded per-invocation traces

- Add WORKFLOW_TRACE_MODE ('linked' default, 'continuous' legacy) to the
  workflow and step queue handlers. In linked mode, WORKFLOW_V2/STEP spans
  start a new trace root with span links to the incoming delivery context
  and the run-origin context, and re-enqueued messages forward the
  ORIGINAL run-origin trace carrier unchanged.
- world-vercel now explicitly injects W3C traceparent/tracestate/baggage
  headers on outgoing workflow-server HTTP requests from inside the
  client span (no-op without an OTEL SDK registered).
- New workflow.trace.mode span attribute; unit tests for both modes and
  for header injection.

Co-Authored-By: Claude Opus 4.8 (1M context) <noreply@anthropic.com>

* changeset: call out behavioral telemetry changes of the linked default

Co-Authored-By: Claude Opus 4.8 (1M context) <noreply@anthropic.com>

* docs: add v5 observability tracing page

Documents OTEL spans/attributes, linked trace mode and WORKFLOW_TRACE_MODE,
span links, context propagation, and the v4 behavior-change callout.

Co-Authored-By: Claude Opus 4.8 (1M context) <noreply@anthropic.com>

* otel: human-friendly span names for workflow and step spans

WORKFLOW_V2/STEP prefixes with full machine names (workflow//./src/...//fn)
become workflow.execute / step.execute / workflow.start with the short
function name. New workflowDisplayName/stepDisplayName helpers in
@workflow/utils handle both raw and queue-sanitized name forms; full names
remain in the workflow.name/step.name attributes.

Co-Authored-By: Claude Opus 4.8 (1M context) <noreply@anthropic.com>

* changeset: merge span-name and linked-trace notes into one changeset

Co-Authored-By: Claude Opus 4.8 (1M context) <noreply@anthropic.com>

* docs: update trace-shape prose to renamed span names

Co-Authored-By: Claude Opus 4.8 (1M context) <noreply@anthropic.com>

* docs: replace ascii trace diagram with mermaid

Co-Authored-By: Claude Opus 4.8 (1M context) <noreply@anthropic.com>

* address review: empty carriers, shared trace helpers, mode warning, name edge cases, consumer span kind

- Treat an empty ({}) trace carrier as absent everywhere the trace-mode
  logic branches, so linked mode falls back to a fresh origin instead of
  forwarding a useless {} forever; workflow.trace.propagated now reports
  whether a usable carrier arrived.
- Extract the duplicated linked-mode logic into shared telemetry helpers
  getNextTraceCarrier() and buildInvocationSpanLinks(), used by both the
  workflow and step queue handlers; resume-hook now uses
  linkToTraceCarrier (gaining the isSpanContextValid guard).
- Warn once per distinct unrecognized WORKFLOW_TRACE_MODE value instead
  of silently selecting linked.
- shortNameFromSanitized: map default/__default to the module short name
  (mirroring parseName) and document the `$`-sanitization limitation.
- Queue-delivered workflow.execute spans now use the CONSUMER span kind,
  matching queue-delivered step.execute spans; docs span table and
  changeset updated accordingly.

Co-Authored-By: Claude Opus 4.8 (1M context) <noreply@anthropic.com>

---------

Co-authored-by: Claude Opus 4.8 (1M context) <noreply@anthropic.com>
2026-06-15 12:35:53 -07:00
Nathan Rajlich 1946718cea [next] Clarify serverExternalPackages warning (#2417) 2026-06-15 16:24:58 +00:00
Pranay Prakash 5dbeecbb82 docs: document run idempotency (#2011)
* docs: document run idempotency

* docs: address idempotency review feedback

* docs: make hook tokens the idempotency pattern

* docs: address toolbar idempotency feedback

* docs: clarify idempotency page description

* docs: scope idempotency descriptions

* docs: move step idempotency example under section

* docs: simplify idempotency guidance

* docs: simplify idempotency cookbook

* docs: add empty changeset

Signed-off-by: Nathan Rajlich <n@n8.io>

* docs: address idempotency review feedback

* feat: add hook ready promise

* docs: mention conflicting hook run id

* test: cover hook ready continuation scheduling

* feat: replace hook.ready with hook.hasConflict (Promise<boolean>)

- hook.hasConflict resolves true when the token is owned by another
  active hook, false once registration is committed — no throw, so
  workflows can branch on conflicts early. Awaiting it suspends the
  workflow to commit the hook registration (createHook alone does not).
- Chain the already-created fast-path through promiseQueue so
  resolution order matches event-log order (review feedback).
- Skip inline step execution when a suspension has an awaited hook
  creation so the hasConflict continuation can advance independently
  of step execution (review feedback).
- Update unit tests, e2e tests, workbench workflows, and v4/v5 docs.

Co-Authored-By: Claude Fable 5 <noreply@anthropic.com>

* docs: fix inconsistent hasConflict bullet in create-webhook reference

State both resolution values explicitly (true = token already owned,
false = registered) instead of a parenthetical that only described the
false case.

* docs: require docs preview links in PR descriptions for docs changes

Co-Authored-By: Claude Fable 5 <noreply@anthropic.com>

* docs: restore SWC Plugin heading in AGENTS.md

Co-Authored-By: Claude Fable 5 <noreply@anthropic.com>

* docs: adopt hook.hasConflict in run idempotency docs

- Primary claim pattern is now `if (await hook.hasConflict)` instead of
  try/catch on HookConflictError; payload awaits still reject with
  HookConflictError (with conflictingRunId) when the owner's run ID is
  needed.
- Route example returns the active owner via resumeHook()'s runId
  instead of threading conflictingRunId through the workflow result.
- Update claim-pattern prose across start(), getHookByToken(), world
  storage, scheduling, workflow composition, and cookbook idempotency
  pages (v4 + v5).
- Add @skip-typecheck marker to the cross-block route sample, fixing a
  pre-existing docs typecheck failure.

Co-Authored-By: Claude Fable 5 <noreply@anthropic.com>

* docs: move resume-or-start guidance into a dedicated resumeHook example

The early callout was too vague and out of place at the top of the API
reference. Replace it with a 'Resume or Start' example section that
explains the flow, shows the resume-first/start-then-retry route, and
links to the run idempotency pattern.

Co-Authored-By: Claude Fable 5 <noreply@anthropic.com>

* docs: detect the concurrent-start race via runId comparison instead of awaiting returnValue

The 'Resume or Start' example returned the just-started run's runId with
reused: false even when a concurrent request's run won the token race —
the payload had reached the actual owner, so the response pointed callers
at a run that exits as a duplicate. The foundations route handled the
race correctly but by awaiting run.returnValue, blocking the HTTP
response on full workflow completion.

resumeHook() always resolves against the actual active owner, so
comparing the resumed hook's runId with the started run's runId detects
the race in both examples — race-correct and non-blocking.

* feat: replace hook.hasConflict with hook.getConflict (Promise<Run | null>)

hasConflict's boolean didn't expose WHICH run owns the token, so the
duplicate run couldn't act on the conflict. getConflict resolves with
null once registration commits, or with a Run handle for the conflicting
run — letting the workflow return/log the owner's runId, inspect its
status, await its result, or cancel it and continue, all in code.

The workflow-mode create-hook module exposes the bundle's compiled Run
class (durable step-proxy methods) on a well-known symbol so the host-
side hook consumer can construct the conflicting run inside the VM.
Contexts without the class (plain unit tests) fall back to a { runId }
object, which is also the documented v4 shape (no native Run
serialization in v4).

Co-Authored-By: Claude Fable 5 <noreply@anthropic.com>

* docs: adopt hook.getConflict and add conflict-handling strategy guide

Run idempotency docs now use getConflict (resolves with the conflicting
Run in v5, { runId } in v4) and document code-driven conflict strategies
in place of static ID-reuse policies: reject the duplicate, adopt the
owner's result, inspect before deciding, signal the owner via
resumeHook, and supersede via cancel-and-reclaim.

Co-Authored-By: Claude Fable 5 <noreply@anthropic.com>

* fix: never resolve getConflict with a non-Run fallback shape

getConflict's contract is Promise<Run | null>. In the degenerate cases
where a real Run cannot be constructed — a hook_conflict event persisted
by an old world without conflictingRunId, or a context that never loaded
the workflow-mode create-hook module — reject with HookConflictError
instead of resolving with a { runId }-shaped impostor.

Test harnesses now register the Run class on the (VM) globalThis like
real bundles do.

Co-Authored-By: Claude Fable 5 <noreply@anthropic.com>

* refactor: make getConflict a method — hook.getConflict()

A property getter that triggers registration/suspension reads as passive
state; a method makes the side effect explicit. Update implementation,
types, tests, e2e workflows, docs, and changeset.

Co-Authored-By: Claude Fable 5 <noreply@anthropic.com>

* docs: getConflict is a method — hook.getConflict()

Co-Authored-By: Claude Fable 5 <noreply@anthropic.com>

* docs: typecheck every sample — drop skip-typecheck escape hatches

Route examples typecheck as-is since the runId-comparison rewrite;
strategy fragments are now complete self-contained workflows; the
publishing-libraries cross-block dependency uses the declare @setup
convention. 934 samples typechecked, none skipped by this PR.

Co-Authored-By: Claude Fable 5 <noreply@anthropic.com>

* review: guard Run class registration, fix anchors, clarify changeset

- Only register WORKFLOW_RUN_CLASS when the workflow runtime is present
  (WORKFLOW_CREATE_HOOK installed on globalThis), so host imports of the
  workflow-mode module neither mutate the host global nor expose the
  non-step-proxy host Run.
- Drop #run-idempotency link fragments — that section lands in the
  stacked docs PR (#2011), which restores the anchored links.
- Note in docs that getConflict() rejects with HookConflictError for
  legacy hook_conflict events lacking the owner's run ID.
- Changeset now calls out the hasConflict -> getConflict() replacement.

Co-Authored-By: Claude Fable 5 <noreply@anthropic.com>

* docs: restore run-idempotency anchors now that the section exists here

Co-Authored-By: Claude Fable 5 <noreply@anthropic.com>

* docs: describe fixed conflict policies generically, without naming other systems

Co-Authored-By: Claude Fable 5 <noreply@anthropic.com>

---------

Signed-off-by: Nathan Rajlich <n@n8.io>
Co-authored-by: Nathan Rajlich <n@n8.io>
Co-authored-by: Peter Wielander <mittgfu@gmail.com>
Co-authored-by: Claude Fable 5 <noreply@anthropic.com>
2026-06-14 01:03:19 -07:00
Pranay Prakash dde689a056 Render attr_set events and run attributes in observability UI (#2393)
- Teal diamond markers for attr_set events on the trace timeline with
  time tooltips (new trace viewer)
- attr_set payloads render changed/removed keys and the writer
  (workflow vs step + attempt) in the run sidebar and Events tab
- Run root span selection now shows run-level events (run lifecycle +
  attr_set) in the sidebar
- Attributes card on run details renders key-value rows with reserved
  $-prefixed keys badged and sorted after user keys
- attr_set added to MARKER_EVENT_TYPES, BOUNDARY_LABELS, event colors
  (teal), and the flat events list run-level grouping
- Docs: screenshots on the attributes page, served from docs/public

Co-authored-by: Claude Fable 5 <noreply@anthropic.com>
2026-06-13 14:58:16 -07:00
Pranay Prakash 3229d20614 fix(docs): repair broken links, fix the link linter, and version-correct v5 Card + edit links (#2391)
* fix(docs): repair broken links and make the docs link linter actually validate

The docs link linter (docs/scripts/lint.ts) had been silently passing
everything since the app moved under app/[lang]/ (#552): the
next-validate-link populate key 'docs/[[...slug]]' no longer matched the
real route, and the unpopulated [lang] homepage route produced a fallback
regex (^\/(.+)$) that matched every href. It also only scanned v4 content.

- Rewrite lint.ts to build explicit v4/v5 URL spaces from both fumadocs
  sources (including cookbook URL variants, app routes, worlds pages,
  public/ assets, and next.config.ts redirects) and validate each version's
  content against version-correct render semantics. Also validate
  frontmatter related/prerequisites references (version-relative) and
  heading fragments.
- Rewrite Card hrefs on v5 pages: the v5 routes rewrote inline markdown
  links from /docs/... to /v5/docs/... but Card renders its own Link, so
  Card hrefs escaped to the v4 routes and 404'd for v5-only pages (e.g.
  /v5/docs/observability linking to /docs/observability/attributes).
- Fix all dead content links surfaced by the working linter (56 across
  v4+v5): nonexistent use-workflow/use-step/start API pages now point at
  foundations/workflows-and-steps and workflow-api/start, getStepMetadata
  path corrected, /docs/worlds/local → /worlds/local, dead changelog/
  internal references removed or unlinked, retired common-patterns links
  point at the cookbook, and a dead #returnvalue anchor now targets
  #returns.
- Add an index page for api-reference/workflow-errors (both versions),
  which was linked from the API reference landing page but had no page.

🤖 Generated with [Claude Code](https://claude.com/claude-code)

Co-Authored-By: Claude Fable 5 <noreply@anthropic.com>

* fix(docs): add version prefix to 'Edit this page on GitHub' links

All "Edit this page on GitHub" links 404'd since the v4/v5 content split
(#1948): page.path is relative to the per-version content dir, but
EditSource built URLs against docs/content/docs/ without the v4/ or v5/
segment. Add a required version prop, passed from each page route.

Incorporates #2120 by Luke Howard (@gldkhoward), rebased onto the v5
route changes from this branch. Fixes #2119.

Co-authored-by: Luke Howard <dev@lukehoward.com.au>

🤖 Generated with [Claude Code](https://claude.com/claude-code)

Co-Authored-By: Claude Fable 5 <noreply@anthropic.com>

---------

Co-authored-by: Claude Fable 5 <noreply@anthropic.com>
2026-06-12 16:26:38 -07:00
Pranay Prakash 628795aa87 Add allowReservedAttributes option to start() (#2385)
* Add allowReservedAttributes option to start()

experimental_setAttributes already exposes allowReservedAttributes for
framework-level callers that own a $-prefixed sub-namespace, and the
run_created / run_started event schemas plus the local and Postgres
worlds already accept and validate the flag. start() was the one gap:
it always validated initial attributes with the reserved prefix
disallowed and had no way to opt out, so framework code could not seed
reserved attributes at run creation.

Thread the option through start():
- StartOptions.allowReservedAttributes, passed to client-side
  validation and forwarded on the run_created eventData
- carried in the queue runInput (new RunInputSchema field) and
  forwarded to run_started so the resilient/lazy run creation path
  validates identically

Co-Authored-By: Claude Fable 5 <noreply@anthropic.com>

* Add e2e coverage for reserved initial attributes via allowReservedAttributes

Verified locally against the nextjs-turbopack dev server: the reserved
key passes client and server validation, lands on the run at creation,
and survives the workflow's own attr_set writes.

Co-Authored-By: Claude Fable 5 <noreply@anthropic.com>

---------

Co-authored-by: Claude Fable 5 <noreply@anthropic.com>
2026-06-12 15:23:26 -07:00
Karthik Kalyan 3cf0e33562 fix(docs): right-align sidebar folder carets consistently (#2377)
SidebarFolderTrigger renders a <button>, which shrink-to-fits its
content, so the ms-auto chevron sat directly next to the folder name
for folders without an index link (e.g. How it works, AI Agents,
Testing). SidebarFolderLink renders an <a> that spans the full sidebar
width, so its chevron was pushed to the right edge. Add w-full to both
so every folder caret is right-aligned.

Co-authored-by: Claude Fable 5 <noreply@anthropic.com>
2026-06-12 07:16:17 -07:00
Pranay Prakash 055b66649a docs: move World SDK and getWorld under workflow/runtime, split out workflow/observability (#2375) 2026-06-12 01:42:43 -07:00
Pranay Prakash 01c8c0878a Replace hook.hasConflict with hook.getConflict() returning the conflicting Run (#2373)
* feat: replace hook.hasConflict with hook.getConflict (Promise<Run | null>)

hasConflict's boolean didn't expose WHICH run owns the token, so the
duplicate run couldn't act on the conflict. getConflict resolves with
null once registration commits, or with a Run handle for the conflicting
run — letting the workflow return/log the owner's runId, inspect its
status, await its result, or cancel it and continue, all in code.

The workflow-mode create-hook module exposes the bundle's compiled Run
class (durable step-proxy methods) on a well-known symbol so the host-
side hook consumer can construct the conflicting run inside the VM.
Contexts without the class (plain unit tests) fall back to a { runId }
object, which is also the documented v4 shape (no native Run
serialization in v4).

Co-Authored-By: Claude Fable 5 <noreply@anthropic.com>

* fix: never resolve getConflict with a non-Run fallback shape

getConflict's contract is Promise<Run | null>. In the degenerate cases
where a real Run cannot be constructed — a hook_conflict event persisted
by an old world without conflictingRunId, or a context that never loaded
the workflow-mode create-hook module — reject with HookConflictError
instead of resolving with a { runId }-shaped impostor.

Test harnesses now register the Run class on the (VM) globalThis like
real bundles do.

Co-Authored-By: Claude Fable 5 <noreply@anthropic.com>

* refactor: make getConflict a method — hook.getConflict()

A property getter that triggers registration/suspension reads as passive
state; a method makes the side effect explicit. Update implementation,
types, tests, e2e workflows, docs, and changeset.

Co-Authored-By: Claude Fable 5 <noreply@anthropic.com>

* review: guard Run class registration, fix anchors, clarify changeset

- Only register WORKFLOW_RUN_CLASS when the workflow runtime is present
  (WORKFLOW_CREATE_HOOK installed on globalThis), so host imports of the
  workflow-mode module neither mutate the host global nor expose the
  non-step-proxy host Run.
- Drop #run-idempotency link fragments — that section lands in the
  stacked docs PR (#2011), which restores the anchored links.
- Note in docs that getConflict() rejects with HookConflictError for
  legacy hook_conflict events lacking the owner's run ID.
- Changeset now calls out the hasConflict -> getConflict() replacement.

Co-Authored-By: Claude Fable 5 <noreply@anthropic.com>

* refactor: resolve the conflicting Run through the serialization class registry

Replace the bespoke WORKFLOW_RUN_CLASS global with the registry the
serialization pipeline already uses to revive Run instances:

- The SWC plugin already auto-registers the workflow bundle's compiled
  Run in globalThis[workflow-class-registry], but under a path-derived
  classId the host cannot know statically. The workflow-mode create-hook
  module now aliases it under a stable id (class//workflow//Run) via a
  new aliasSerializationClass() helper (a plain registry entry —
  registerSerializationClass cannot be reused since the plugin's IIFE
  already defined the non-configurable classId property).

- createConflictingRun() looks the class up with
  getSerializationClass(RUN_CLASS_ID, ctx.globalThis) and constructs
  through its WORKFLOW_DESERIALIZE hook, exactly as the Instance reviver
  would for a serialized Run crossing from a step into the workflow.

- Because the registry is keyed per-global, no environment guard is
  needed: a stray host-side import registers the host Run on the host
  registry, which is the correct class for that context. The
  WORKFLOW_CREATE_HOOK guard, the ??=, and the WORKFLOW_RUN_CLASS symbol
  are all deleted.

Verified: 1156 core unit tests; compiled workbench bundle contains the
stable alias alongside the plugin's path-derived registration with zero
WORKFLOW_RUN_CLASS references; all 5 hookGetConflict e2e tests pass
against a local nextjs-turbopack dev server, including conflict
resolution reading conflict.status through a durable step.

---------

Co-authored-by: Claude Fable 5 <noreply@anthropic.com>
Co-authored-by: Nathan Rajlich <n@n8.io>
2026-06-12 07:52:36 +00:00
Pranay Prakash e163422551 Add hook.hasConflict for early hook conflict detection (#2015)
* feat: add hook ready promise

* test: cover hook ready continuation scheduling

* feat: replace hook.ready with hook.hasConflict (Promise<boolean>)

- hook.hasConflict resolves true when the token is owned by another
  active hook, false once registration is committed — no throw, so
  workflows can branch on conflicts early. Awaiting it suspends the
  workflow to commit the hook registration (createHook alone does not).
- Chain the already-created fast-path through promiseQueue so
  resolution order matches event-log order (review feedback).
- Skip inline step execution when a suspension has an awaited hook
  creation so the hasConflict continuation can advance independently
  of step execution (review feedback).
- Update unit tests, e2e tests, workbench workflows, and v4/v5 docs.

Co-Authored-By: Claude Fable 5 <noreply@anthropic.com>

* docs: fix inconsistent hasConflict bullet in create-webhook reference

State both resolution values explicitly (true = token already owned,
false = registered) instead of a parenthetical that only described the
false case.

* docs: require docs preview links in PR descriptions for docs changes

Co-Authored-By: Claude Fable 5 <noreply@anthropic.com>

* docs: restore SWC Plugin heading in AGENTS.md

Co-Authored-By: Claude Fable 5 <noreply@anthropic.com>

---------

Co-authored-by: Claude Fable 5 <noreply@anthropic.com>
Co-authored-by: Nathan Rajlich <n@n8.io>
2026-06-11 22:12:06 +00:00
Peter Wielander b3279f8b17 [core] V2: unify wait+step queue dispatch in suspension processing (#1925)
* [core] V2: pre-schedule the wait timer before inline-executing a step

Fix `Promise.race(step, sleep)` semantics in V2 mixed suspensions
without losing inline step execution.

Inline `await executeStep(...)` blocks the V2 handler for the full
step duration, but `wait_completed` events are only created on the
*next* loop iteration's "complete elapsed waits" pass. So if the
sleep is shorter than the step, replay always picked the step
because the wait_completed event hadn't been written yet —
`sleepWinsRaceWorkflow` returned `'step'` instead of `'sleep'`.

Fix: when a suspension contains both an owned inline step and at
least one pending wait, queue a delayed self-message with
`delaySeconds = suspensionResult.timeoutSeconds` *before* starting
inline execution. The queued continuation fires in a separate
function invocation while the step is still running. That parallel
invocation's "complete elapsed waits" pass writes wait_completed,
replay observes the elapsed wait, and `Promise.race` resolves with
the sleep correctly. The original (still-running) inline invocation
finishes its step, sees `run_completed` on the next loop iteration,
and exits.

This preserves inline-step execution speed for the step-wins case:
the step finishes inline and the workflow returns directly. The
eagerly-queued wait continuation fires after the step has won and
just no-ops on the terminal run.

Test plan:
- New e2e tests `sleepWinsRaceWorkflow` and `stepWinsRaceWorkflow`
  exercising `Promise.race` between a step function and `sleep()`,
  in both directions.
- Verified locally against `nextjs-turbopack` workbench: both pass.
  Event log confirms `wait_completed` is created at t≈1s after
  `wait_created` (1s sleep) instead of at t≈11s after the inline
  step finishes.

Eager-processing changelog updated with a "Mixed Suspensions"
section describing the pre-scheduled wait approach and its
rationale.

Co-Authored-By: Claude Opus 4.7 (1M context) <noreply@anthropic.com>

* [world-local] Honor delaySeconds before message delivery

The local queue's `queue()` enqueue path ignored the `delaySeconds`
option entirely — every message was delivered immediately, regardless
of the requested delay. VQS-side queues (used by world-vercel and
world-postgres) honor delaySeconds at the broker, so this brings
world-local in line with production semantics.

The runtime needs this to land before the wait-as-continuation
unification in the next commit: that change starts queueing wait
timers as fresh delayed continuations instead of returning
`{ timeoutSeconds }`. Without delaySeconds support, those wait
continuations would fire instantly in dev and trigger spurious
replays.

Sleep happens outside the queue's worker semaphore so a delayed
message doesn't tie up a worker slot during its delay window — other
immediate messages are free to dispatch in parallel.

New tests in queue.test.ts cover:
- delaySeconds > 0 → setTimeout called with the right ms value
- delaySeconds === 0 → no setTimeout (immediate dispatch)
- delaySeconds omitted → no setTimeout (immediate dispatch)

* [core] V2: unify wait+step queue dispatch in suspension processing

Replace the asymmetric "steps go to the queue, waits become a
{ timeoutSeconds } return value" pattern with a single Promise.all
batch that queues every pending operation we are not running inline.

Before this change, suspension processing had three branches that
all needed to keep the wait/step asymmetry consistent:

- pendingSteps.length === 0 returned { timeoutSeconds }
- inlineStep + waits eagerly queued a delayed self-message AND set
  inlineStep to undefined (Option A) AND returned { timeoutSeconds }
- inlineStep retry path returned { timeoutSeconds } if there were waits

After this change, every suspension goes through one path:

  for non-inline pendingSteps: queue stepId message
  if timeoutSeconds defined:    queue delayed continuation
  await Promise.all(dispatches)
  if !inlineStep: return
  await executeStep(inlineStep)

Behaviorally, this restores inline step execution even when the
suspension also has a wait (Option A's carve-out is no longer
necessary): the wait timer fires in a separate function invocation
on the queue, in parallel with the inline step. If the sleep wins
the race, that parallel invocation observes wait_completed via the
"complete elapsed waits" pass and finishes the run; if the step
wins, the wait continuation fires later and no-ops on the terminal
run via the existing terminal-event check.

Other cleanups:
- The inline-step retry path no longer needs to forward
  suspensionResult.timeoutSeconds — the wait timer was already
  enqueued as part of the unified dispatch above.
- A dead post-step `if (timeoutSeconds && pendingSteps.length === 1)`
  block (just a comment, no body) is removed; the loop's
  "complete elapsed waits" pass handles the same case correctly.
- Step queueing now uses a shared `traceCarrier` rather than
  re-serializing per step.

Retry/throttle and hook-conflict paths still return { timeoutSeconds }
since their semantics are "redeliver THIS message after a delay"
rather than "schedule a fresh wait timer." Those can be unified in
a follow-up.

Test plan:
- New e2e tests `sleepWinsRaceWorkflow` and `stepWinsRaceWorkflow`
  pass against the `nextjs-turbopack` workbench.
- Event log inspection confirms wait_completed fires at t≈1s (after
  wait_created at t≈0s) for the sleep-wins case, and that the inline
  step runs only once (no duplicate step_started events that the
  earlier eager-queue approach produced in dev).
- All 842 @workflow/core unit tests pass.
- All 346 @workflow/world-local unit tests pass (with the
  delaySeconds support added in the previous commit).

Requires the world-local delaySeconds fix in the prior commit;
without it, wait continuations would fire instantly in dev and the
parallel replay would re-enter handleSuspension before the wait
elapsed (recoverable via existing redelivery, but inefficient).

* [docs] V2 unified suspension dispatch + changeset

Update the "Mixed Suspensions" section in eager-processing.mdx to
describe the unified parallel-dispatch model:

- All non-inline pendingSteps are queued with stepId
- The wait timer (if any) is queued as a delayed continuation
- All dispatched in one Promise.all batch
- One owned step is then inline-executed (if any)

The doc previously described Option A (the carve-out where waits
forced all steps to be queued); the unified model removes that
carve-out and explains why the wait continuation works in parallel
with the inline step.

Also notes the dependency on world-local's new delaySeconds support
(landed earlier in the same PR series).

Changeset bumps both @workflow/core and @workflow/world-local since
both packages have user-observable behavior changes.

* [core] Dedupe wait continuations on the wait's correlationId

While a wait is pending, every replay pass over the run re-observes it
(once per step completion in Promise.all([steps..., sleep()]), etc.) and
would enqueue another delayed continuation — each a spurious replay when
the wait elapses, and each a fresh message that resets the
delivery-attempt runaway guard. Key the continuation on the wait's
correlationId so the worlds' idempotency dedupe collapses them.

Near-elapsed waits (<= 2s) are enqueued without the key: a continuation
delivered marginally early (clock skew; the ceil() on the delay can
leave a ~0 margin) re-observes its wait as pending and must be able to
enqueue a fresh short-delay retry. VQS idempotency records persist until
message-retention TTL — reusing the key there would drop the retry and
stall the run permanently.

Also adapts wait-completion-replay tests (from #2038) to the unified
dispatch model: the hook-branch step now executes inline (registered in
the test world, which now returns a step entity from step_started), so
each scenario performs one extra loop-iteration event fetch.

Co-Authored-By: Claude Fable 5 <noreply@anthropic.com>

* [core] Always key wait continuations; bucket the key for near-elapsed waits

CI caught sleepWinsRaceWorkflow failing across the world-postgres lanes:
world-postgres serializes KEY-LESS workflow messages per run
(inflightWorkflowRuns), so a key-less wait continuation parks behind the
flow message that is inline-executing the racing step — wait_completed
lands after step_completed and the race resolves to the step. Keyed
messages take the concurrent dedupe path, so the continuation must
always carry an idempotency key.

The near-elapsed exception (<= 2s) now uses a second-bucketed suffix
instead of omitting the key: an early-delivered continuation re-observes
its wait as pending and re-enqueues with >= 1s delay, which guarantees a
later bucket — a fresh key that dedupe windows cannot drop — while
same-instant duplicates still collapse.

Verified against a local world-postgres setup (express workbench,
Graphile worker): sleepWins/stepWins pass 3/3 with wait_completed at
t+1s; the event log confirms the continuation fires in parallel with
the in-flight inline step.

Co-Authored-By: Claude Fable 5 <noreply@anthropic.com>

* [core] Clamp wait-continuation delays; chain long waits with hop-keyed dedupe

Addresses PR review: the unified dispatch passed delaySeconds to the
queue unclamped while keying the continuation on the bare wait
correlationId. On world-vercel (23h max delay, 24h VQS message
retention) a sleep() longer than the max either failed the dispatch or
was delivered early with its re-enqueue silently dropped by the
still-live idempotency record - stalling the run permanently.

- New runtime/wait-continuation.ts owns delay + idempotency-key
  selection: delays clamp to 23h and longer waits chain across hops,
  with the hop index suffixed to the key so re-observations within a
  hop window dedupe while each hop delivery gets a fresh key. Near-
  elapsed threshold and max delay are named constants; full rationale
  moved out of the runtime.ts comment block. Unit tests pin the key
  selection including chain advancement.
- SuspensionHandlerResult: timeoutSeconds/timeoutWaitCorrelationId
  collapsed into waitTimeout?: { seconds, correlationId } so the
  pairing can't drift (review nit).
- runtime.test.ts ack-ordering harness adapted to the unified model:
  step_created now answers EntityConflictError so the handler observes
  the step without owning it and must queue it (the carve-out the tests
  relied on - "pending wait disables inline execution" - is exactly
  what this branch removes).

Co-Authored-By: Claude Fable 5 <noreply@anthropic.com>

* [world-local] Abort pending queue sleeps on close()

Addresses PR review: a pending delayed message kept the dev process's
event loop alive for its full delay, and close() only closed the HTTP
agent - a sleep that fired afterwards attempted delivery against the
closed agent and logged a spurious "[local world] Queue operation
failed" error during test/CLI shutdown.

One AbortController owned by the queue now cancels the delaySeconds
sleep, the timeoutSeconds re-delivery sleep, and the retry backoff on
close(); the resulting AbortError is already swallowed by the existing
isAbortError check. close() is idempotent since shutdown paths may
invoke it twice.

Co-Authored-By: Claude Fable 5 <noreply@anthropic.com>

* [docs] Wait-continuation clamping + hop chaining; changeset

eager-processing.mdx pseudocode now shows the continuation's
idempotency key and clamped delay (PR review nit); the dedupe prose
covers the two key variations (hop suffix for chained long waits,
second bucket for near-elapsed waits). Changeset mentions long-sleep
chaining and world-local's abort-on-close.

Co-Authored-By: Claude Fable 5 <noreply@anthropic.com>

---------

Co-authored-by: Claude Opus 4.7 (1M context) <noreply@anthropic.com>
Co-authored-by: Pranay Prakash <pranay.gp@gmail.com>
2026-06-11 14:05:07 -07:00
Pranay Prakash ce5dedca79 docs(observability): remove MVP implementation detail bullet (#2367)
Co-authored-by: v0agent <it+v0agent@vercel.com>
2026-06-11 12:27:24 -07:00
Pranay Prakash ae8d6feeda Add native v4 workflow attribute events (#2226)
* Add native workflow attribute events

* Fix abbreviated attributes docs sample

* Document attribute replay ordering for step races

* Address native attribute review feedback

* Validate before claiming attr_set dedup lock; clearer start() attribute errors

- world-local: claim the attr_set correlation lock only after validation,
  so a validation failure does not permanently mark the correlationId as
  written and wedge the run in a re-invoke loop on retry
- world-postgres: distinguish a concurrently-deleted run from a cap
  violation when the guarded attributes update matches no rows
- core: reject non-string initial attribute values in start() with a
  clear error instead of a downstream schema failure

Co-Authored-By: Claude Fable 5 <noreply@anthropic.com>

* Add attribute edge-case tests across all layers

- core: normalizeAttributeChanges unit tests (non-object inputs, FatalError
  wrapping, key/value/batch limits, boundary lengths, UTF-8 byte counting)
- core: start() rejects reserved keys, oversized keys/values, and over-cap
  initial attribute batches before any write
- world-local + world-postgres: per-run cap enforced against existing
  attributes (upsert-at-cap allowed, removal frees room), oversized values
  rejected on attr_set, invalid initial attributes rejected on run_created
- e2e: validation DX workflow asserting every invalid write throws a
  catchable FatalError naming the violated rule and limit, with the run
  staying healthy; start() rejects invalid initial attributes client-side

Co-Authored-By: Claude Fable 5 <noreply@anthropic.com>

* Remove accidentally committed local e2e diagnostics artifact

Co-Authored-By: Claude Fable 5 <noreply@anthropic.com>

* Bump world-vercel to spec version 4 for native attributes

The deployed workflow-server (vercel/workflow-server#469) materializes
native attr_set events and accepts initial run attributes, but
world-vercel still advertised spec v3 — so start(..., { attributes })
rejected itself client-side ('requires spec version 4') on every Vercel
deployment, failing the new e2e seeding test across the prod matrix.
New runs are now stamped v4.

Co-Authored-By: Claude Fable 5 <noreply@anthropic.com>

* Reject duplicate correlated attr_set before materializing in Postgres

A redelivered duplicate — including one carrying different changes for
the same correlationId — previously re-applied the run attributes update
and only then failed the event insert, leaving the snapshot out of sync
with the event log. Pre-check the event log for the correlationId before
mutating; the unique index still guards the truly-concurrent race, which
is idempotent (deterministic replay carries identical changes). Also
apply the suggested docs wording for initial attributes.

Co-Authored-By: Claude Fable 5 <noreply@anthropic.com>

* Apply suggestion from @VaguelySerious

Signed-off-by: Peter Wielander <mittgfu@gmail.com>

* Fail the run on World-rejected attribute writes; un-nest runtime test

Two fixes from review:

- runtime.test.ts: the pre-existing test "propagates transient
  step_created failures..." was accidentally nested inside the new
  attribute-race test, failing the new test ("Calling the test function
  inside another test function is not allowed") and preventing the old
  test from running. Restored it verbatim at describe level.

- A workflow-body attr_set the World rejects as invalid (e.g. the
  cumulative per-run attribute cap, which only the World can check) is
  deterministic: redelivering the orchestrator message replays the same
  write into the same rejection, wedging the run in redelivery with no
  terminal event. handleSuspension now wraps such rejections in
  FatalError, and workflowEntrypoint fails the run with the validation
  error instead of rejecting the delivery. Transient storage errors
  still propagate and retry via redelivery.

Co-Authored-By: Claude Fable 5 <noreply@anthropic.com>

---------

Signed-off-by: Peter Wielander <mittgfu@gmail.com>
Co-authored-by: Claude Fable 5 <noreply@anthropic.com>
Co-authored-by: Peter Wielander <mittgfu@gmail.com>
Co-authored-by: Peter Wielander <peter.wielander@vercel.com>
2026-06-11 10:19:08 -07:00
Peter Wielander b549342c5c [docs] Add "Step executed multiple times" error page (#2310) 2026-06-10 20:37:22 +02:00
Karthik Kalyan 3ae0ae2917 Deprecate DurableAgent and update it with WorkflowAgent in v5 docs (#2285)
* docs: deprecate DurableAgent in v5

* docs: fix workflow docs CI failures

* docs: trim deprecated DurableAgent guidance

* docs: point v5 cookbook to WorkflowAgent

* docs: fix v5 cookbook navigation

* docs: align WorkflowAgent guide

* docs: add WorkflowAgent cookbook heading

* docs: expand WorkflowAgent cookbook handoff
2026-06-08 16:02:18 -07:00
Rihan Arfan 5b448ceb03 docs: add nitro changelog (#2232) 2026-06-08 16:06:55 +01:00
Peter Wielander 249196935a [docs] Reduce noise in changelog files (#2075) 2026-06-02 12:17:59 +02:00
Pranay Prakash 2a3b11bcb4 Retry replay divergence before failing event logs (#2212)
(cherry picked from commit 813cd9a9de)
2026-06-02 08:48:00 +02:00
Nathan Rajlich 8d0928b2a2 fix(core,errors): classify SDK encryption failures as RUNTIME_ERROR (#2145)
* fix(core,errors): classify SDK encryption failures as RUNTIME_ERROR

SDK-level AES-GCM encrypt/decrypt failures are never the user's fault,
but the run-failure classifier was tagging them as USER_ERROR because
the native Web Crypto OperationError (most commonly raised by
AESCipherJob.onDone on GCM auth-tag mismatch) does not match any
RUNTIME_ERROR_CHECKS entry.

Introduce a new RuntimeDecryptionError (subclass of WorkflowRuntimeError)
that the encryption module throws when subtle.encrypt/subtle.decrypt
fails, with the original DOMException as cause plus diagnostic context
(operation, byteLength, printable/hex format prefix of the input
header). classifyRunError now picks it up via RUNTIME_ERROR_CHECKS, so
these failures surface as RUNTIME_ERROR with a proper named class for
dashboards and triage.

* Trim changeset description to one sentence

* Trim historical-context comments

* docs: add runtime-decryption-failed troubleshooting page (v4 + v5)

* fix(core): round-trip RuntimeDecryptionError context, fix formatPrefix, propagate through serialization wrappers

Addresses review feedback on #2145:

- Add a RuntimeDecryptionError reducer/reviver (+ SerializableSpecial
  entry + globalThis registration) so its `context` (operation,
  byteLength, formatPrefix) survives the dehydrate/hydrate run-error
  round trip instead of being dropped by the generic Error reducer.

- Stop capturing `formatPrefix` in the low-level encryption layer, which
  only sees the stripped AES payload (nonce bytes), not the outer `encr`
  marker. The serialization layer now attaches the real envelope prefix.

- Rethrow RuntimeDecryptionError unchanged from the serialize/dehydrate
  catch blocks instead of reframing it as a SerializationError, so an
  encryption failure during dehydration stays a RUNTIME_ERROR rather than
  being misclassified as USER_ERROR.

* fix(core): enrich stream decrypt errors with envelope prefix + fix lint

- Mirror the catch/enrich/rethrow block from serialization/encryption.ts
  around the stream-path aesGcmDecrypt() call so auth-tag failures on
  encrypted stream frames also carry context.formatPrefix = 'encr'
  (addresses review feedback). Add a tampered-frame test.
- Fix all auto-fixable Biome lint findings in the touched files
  (template literals, useless try/catch wrappers, optional chaining,
  non-null assertions).
2026-05-29 18:53:17 +00:00
Peter Wielander 409b1033d9 Allow setting workflow attributes from steps (#2157) 2026-05-29 19:38:10 +02:00
Peter Wielander d7f7c69719 [docs] Document experimental attributes feature (#2141) 2026-05-29 11:10:00 +00:00
Peter Wielander 1e6b1fdea2 Attributes MVP (experimental and write-only) and CI hardening (#2134)
* fix(core): scan inline sourcemaps during error remapping

* Attributes MVP (experimental and write-only) (#2088)
2026-05-28 18:06:46 +00:00
Karthik Kalyan c58cae6612 [Docs] Cookbook update for child workflows pattern (#2100)
* docs(cookbook): replace child workflow polling with hook resume pattern

Recommend startAndWait() with withChildCompletionHook() for v4 and v5 child
workflow orchestration instead of getRun().status polling loops.

Co-authored-by: Cursor <cursoragent@cursor.com>

* Fix child-workflows cookbook review feedback

Tighten resumeParentCompletion to a discriminated union so hook.resume
typechecks, add zod to the vitest workbench, remove unused resumeHook
import, and add an empty changeset per AGENTS.md.

Co-authored-by: Cursor <cursoragent@cursor.com>

* docs(cookbook): trim child-workflows hook resume guide

Remove redundant polling comparison copy, the getRun() alternative section, and v5-only start() tips to keep the cookbook focused on the hook pattern.

Co-authored-by: Cursor <cursoragent@cursor.com>

---------

Co-authored-by: Cursor <cursoragent@cursor.com>
2026-05-25 16:02:19 -07:00
Karthik Kalyan ff167d005d [Docs] Fix cookbook pattern for AI SDK (#2099)
* Fix cookbook pattern for AI SDK

The AI SDK cookbook entry presented `streamText` inside a `"use step"`
turn function with tools also marked `"use step"`. That implies tools
are individually durable, but the `"use step"` directive is a no-op
when called from another step — so tools run as plain inline functions
inside `runTurn`, and the durability boundary is the entire turn.

Changes:

- Remove the `"use step"` directive from tool implementations in the
  workflow code sample and add an explanatory comment.
- Update the frontmatter summary and intro paragraph to drop the
  inaccurate "tools remain durable steps" claim.
- Add a "Tools are not individually durable" entry to Pitfalls with
  consequences and mitigations (idempotency or `DurableAgent`).
- Add a `runTurn` durability-boundary bullet to "How it works".
- Add a "Tool call durability" row to the `streamText` vs `DurableAgent`
  comparison table.
- Fix two misleading Key APIs bullets that claimed tools wrap
  `"use step"` functions and that `"use step"` makes tool executions
  durable.

Applied identically to both v4 and v5 cookbook entries.

Co-authored-by: Cursor <cursoragent@cursor.com>

* Apply suggestion from @VaguelySerious

Co-authored-by: Peter Wielander <mittgfu@gmail.com>
Signed-off-by: Karthik Kalyan <105607645+karthikscale3@users.noreply.github.com>

* Correct outdated DurableAgent guidance in AI SDK cookbook.

The callout and comparison table incorrectly claimed DurableAgent lacks stopWhen, structured output, and onStepFinish — update them to reflect the actual implementation and clarify when raw streamText() is still appropriate.

Co-authored-by: Cursor <cursoragent@cursor.com>

* Reword tool comment to describe current behavior, not a changelog.

Address review feedback: the inline comment should explain how tools run inside runTurn without referencing removed "use step" directives.

Co-authored-by: Cursor <cursoragent@cursor.com>

---------

Signed-off-by: Karthik Kalyan <105607645+karthikscale3@users.noreply.github.com>
Co-authored-by: Cursor <cursoragent@cursor.com>
Co-authored-by: Peter Wielander <mittgfu@gmail.com>
2026-05-25 11:15:36 -07:00
Nathan Rajlich 070bd0cea9 [next] make lazyDiscovery the default in withWorkflow (#1805)
* [next] make lazyDiscovery the default in withWorkflow

Flips the default for `workflows.lazyDiscovery` from `false` to `true`
so new projects get deferred workflow discovery automatically on Next.js
versions that support deferred entries (>= 16.2.0-canary.48). Older
versions continue to fall back to eager discovery.

Users can still opt back into eager discovery explicitly by passing
`workflows: { lazyDiscovery: false }`.

Also:
- Remove the now-redundant `lazyDiscovery: true` from the Next.js
  workbench apps.
- Reword the fallback warning for clarity when lazy is the default.
- Update the local-build e2e assertion to match the new warning text.
- Update the withWorkflow docs with the new default.

* [workbench] remove commented 'export default nextConfig' lines
2026-05-22 14:11:34 +00:00
Rich Haines cf256b56f1 [docs] Replace local ai-agent-detection with @vercel/agent-readability (#1580) 2026-05-22 13:43:43 +00:00
Karthik Kalyan c5023646d1 [docs] Add cookbook entry on upgrading workflows (#1874)
Co-authored-by: Peter Wielander <mittgfu@gmail.com>
2026-05-22 13:35:09 +00:00
Ismael 1bc75ce079 fix(docs): disable Geist Mono ligatures in code blocks (#2031)
Shiki wraps each highlighted token in its own <span>, which breaks Geist
Mono programming ligatures like `===`, `!==`, `=>`. The ligature glyph is
rendered at the advance width of a single character (~8.4px) instead of
three (~25.2px), causing it to visually overlap the preceding token.

Disable `font-variant-ligatures` inside `pre code` so each character
renders at its true monospace width.

Co-authored-by: Claude Opus 4.7 (1M context) <noreply@anthropic.com>
2026-05-19 23:28:32 -07:00
Pranay Prakash 9d2a9261fd Expose conflicting run id on hook conflicts (#2012)
* Expose conflicting run id on hook conflicts

* Mark hook conflict run id as future required

* Address hook conflict docs review

* Address hook conflict review comments

* Fix hook conflict docs typecheck
2026-05-18 17:31:20 -07:00