[AIT-1073] Vercel WDK docs for AI Transport#3463
Conversation
|
Important Review skippedAuto reviews are disabled on this repository. Please check the settings in the CodeRabbit UI or the ⚙️ Run configurationConfiguration used: Repository UI Review profile: CHILL Plan: Pro Run ID: You can disable this status message by setting the Use the checkbox below for a quick retry:
✨ Finishing Touches🧪 Generate unit tests (beta)
Thanks for using CodeRabbit! It's free for OSS, and your support helps us grow. If you like it, consider giving us a shout-out. Comment |
b84eb55 to
7e2d018
Compare
zknill
left a comment
There was a problem hiding this comment.
There should be a skill in this repo called /write-docs that encodes some of the anti-llm language rules. Might be worth running it on the diff.
|
|
||
| A WDK step that produces agent output publishes it as a single Step, using the WDK step id as that Step's `stepId`. That is the join between the two systems: WDK's retryable unit and AI Transport's supersedable unit share one identifier. | ||
|
|
||
| Read the id with [`getStepMetadata()`](https://useworkflow.dev/docs/api-reference/workflow/get-step-metadata) from the `workflow` package, inside the step. WDK step ids are stable across retries of the same step and unique across workflow runs, so they pass straight into `createStep` with no prefixing. This is where the composition is lighter than [Temporal's](/docs/ai-transport/frameworks/temporal), whose per-workflow activity ids need the `stepIdFor` helper to stay distinct on the channel. |
There was a problem hiding this comment.
I don't think we need to reference temporal here
| { | ||
| name: 'Vercel WDK', | ||
| link: '/docs/ai-transport/frameworks/workflow-devkit', | ||
| }, |
|
|
||
| ## Suspend and resume across workflows <a id="suspend-resume"/> | ||
|
|
||
| A [suspend](/docs/ai-transport/features/human-in-the-loop) does not park the workflow to wait. The WDK step holding the Run calls `run.suspend()`, publishes `ai-run-suspend`, and returns; the workflow completes. When the client posts a continuation invocation (a tool result or an approval response), the agent route starts a fresh workflow. That workflow's `openRun` step calls `createRun` as usual; the SDK reads the existing `runId` the continuation's trigger names and publishes `ai-run-resume` rather than `ai-run-start`. |
There was a problem hiding this comment.
Drop first sentence, it reads weird: A suspend does not park the workflow to wait.
|
|
||
| The invocation is a poke and a pointer. Its HTTP body carries no session content, only the id of the channel event the client just published; the agent reads that event from the channel to learn what to do. One workflow run per HTTP POST, so continuations are new workflow runs on the same AI Transport `runId`, not resumes of the original workflow. | ||
|
|
||
| WDK's own hooks can hold a workflow open while it waits for external input. The composition here ends the workflow instead, because the continuation arrives as a fresh POST from the AI Transport client and its trigger already points at the channel event that resumes the Run. The client stays identical to the [Vercel AI SDK integration](/docs/ai-transport/frameworks/vercel-ai-sdk-ui), with no workflow-aware code on the browser side. |
There was a problem hiding this comment.
"The composition" reads weird here, maybe "The design in the Getting Started workflow" with a link.
|
|
||
| In local development the runtime stores run state in `.workflow-data/`; add that directory to `.gitignore`. | ||
|
|
||
| ## Define the workflow <a id="define-workflow"/> |
There was a problem hiding this comment.
I mentioned in slack that we could make these H3s under a H2, so that the ToC reads nicer
|
|
||
| `runInference` adopts the Run and runs one model call. `stripToolExecutes` and `stopWhen: stepCountIs(1)` keep the Vercel AI SDK from running its own tool loop, so the model emits its tool-call parts and stops; the workflow drives the loop. `runInference` then routes the pending calls: a tool with a server `execute` becomes a `runTool` step; anything else suspends the Run for the client to answer. This guide uses a single server tool; the [framework page](/docs/ai-transport/frameworks/workflow-devkit#tool-calls) and [tool calling](/docs/ai-transport/features/tool-calling) cover client-executed and approval-gated tools. | ||
|
|
||
| `awaitAttemptVisible` covers the one retry hazard. When WDK re-runs an inference, the superseding `ai-step-start` is not in the read model the instant it publishes, so reading the prompt too early would trail the failed attempt's half-streamed reply as an assistant prefill that real providers reject. The guard waits for the retry's attempt to reflect and returns at once on the first attempt. |
There was a problem hiding this comment.
I mentioned in slack that this is the only bit I didn't really understand.
There was a problem hiding this comment.
awaitAttemptVisible was a leftover from the previous fused "open + first inference" step. The guard is not needed anymore, I've removed it from the docs and from the WDK demo in ably/ably-ai-transport-js#258
Document running the AI Transport SDK on Vercel Workflow Development Kit (Vercel WDK), the in-app durable-execution integration, alongside the existing Temporal one. - frameworks/workflow-devkit: how AI Transport composes with Vercel WDK. The workflow opens the Run and runs each model call and tool as its own WDK step, using the WDK step id as the AI Transport Step id so a retry supersedes the failed attempt on the channel rather than appending beside it. Covers the driver-owned tool loop for server, client-executed, and approval-gated tools, channel-routed cancels, and suspend and resume across workflows. - getting-started/workflow-devkit: a Next.js walkthrough that opens the Run and runs each inference as its own retryable step, with a flaky tool that shows a retry superseding the failed attempt on the channel. Add the two framework diagrams, nav entries under By SDK and Frameworks, and cross-links from the Steps, durable-execution, tool-calling, concepts, roadmap, going-to-production, and Temporal pages. Co-Authored-By: Claude Opus 4.8 (1M context) <noreply@anthropic.com>
Two documentation-wide accuracy fixes against @ably/ai-transport v0.5.0.
AgentSession no longer has close(): teardown is end(), which closes any
still-open Run as `cancelled` then detaches. detach() alone is reserved for
durable cross-process handoff. Every agent-side example that tore down with
session.close() now uses session.end(), and the connections concept describes
the ClientSession/AgentSession teardown split correctly. Client-side
ClientSession.close() is unchanged.
StepEndReason is `complete` | `failed` | `cancelled`: a cancel arriving while a
Step is open closes ai-step-end{cancelled} before the Run ends. The Steps
concept, the AgentSession step-end reference (including the end() default
derivation), and the wire-protocol step-reason header and ai-step-end rows now
list all three. The Run-level run-reason (RunEndReason) is left as
complete/cancelled/error.
Co-Authored-By: Claude Opus 4.8 (1M context) <noreply@anthropic.com>


Description
Docs for running the AI Transport SDK with Vercel Workflow DevKit (WDK), alongside the existing Temporal integration.
frameworks/workflow-devkit.mdx) — how AIT composes with WDK: one activity per Step, WDK step ids used asstepIds (no helper needed), channel-routed cancels, and how the driver-owned loop handles server, client, and approval-gated tool calls.getting-started/workflow-devkit.mdx) — a Next.js walkthrough mirroring the Temporal one.Based on the WDK demo from ably/ably-ai-transport-js#253
Resolves AIT-1073
Checklist