[Docs] Fix cookbook pattern for AI SDK#2099
Conversation
|
📊 Benchmark Results
workflow with no steps💻 Local Development
▲ Production (Vercel)
🔍 Observability: Next.js (Turbopack) | Nitro workflow with 1 step💻 Local Development
▲ Production (Vercel)
🔍 Observability: Nitro | Next.js (Turbopack) workflow with 10 sequential steps💻 Local Development
▲ Production (Vercel)
🔍 Observability: Nitro | Next.js (Turbopack) workflow with 25 sequential steps💻 Local Development
▲ Production (Vercel)
🔍 Observability: Nitro | Next.js (Turbopack) workflow with 50 sequential steps💻 Local Development
▲ Production (Vercel)
🔍 Observability: Nitro | Next.js (Turbopack) Promise.all with 10 concurrent steps💻 Local Development
▲ Production (Vercel)
🔍 Observability: Nitro | Next.js (Turbopack) Promise.all with 25 concurrent steps💻 Local Development
▲ Production (Vercel)
🔍 Observability: Nitro | Next.js (Turbopack) Promise.all with 50 concurrent steps💻 Local Development
▲ Production (Vercel)
🔍 Observability: Next.js (Turbopack) | Nitro Promise.race with 10 concurrent steps💻 Local Development
▲ Production (Vercel)
🔍 Observability: Next.js (Turbopack) | Nitro Promise.race with 25 concurrent steps💻 Local Development
▲ Production (Vercel)
🔍 Observability: Next.js (Turbopack) | Nitro Promise.race with 50 concurrent steps💻 Local Development
▲ Production (Vercel)
🔍 Observability: Nitro | Next.js (Turbopack) workflow with 10 sequential data payload steps (10KB)💻 Local Development
▲ Production (Vercel)
🔍 Observability: Nitro | Next.js (Turbopack) workflow with 25 sequential data payload steps (10KB)💻 Local Development
▲ Production (Vercel)
🔍 Observability: Nitro | Next.js (Turbopack) workflow with 50 sequential data payload steps (10KB)💻 Local Development
▲ Production (Vercel)
🔍 Observability: Nitro | Next.js (Turbopack) workflow with 10 concurrent data payload steps (10KB)💻 Local Development
▲ Production (Vercel)
🔍 Observability: Nitro | Next.js (Turbopack) workflow with 25 concurrent data payload steps (10KB)💻 Local Development
▲ Production (Vercel)
🔍 Observability: Next.js (Turbopack) | Nitro workflow with 50 concurrent data payload steps (10KB)💻 Local Development
▲ Production (Vercel)
🔍 Observability: Next.js (Turbopack) | Nitro Stream Benchmarks (includes TTFB metrics)workflow with stream💻 Local Development
▲ Production (Vercel)
🔍 Observability: Nitro | Next.js (Turbopack) stream pipeline with 5 transform steps (1MB)💻 Local Development
▲ Production (Vercel)
🔍 Observability: Nitro | Next.js (Turbopack) 10 parallel streams (1MB each)💻 Local Development
▲ Production (Vercel)
🔍 Observability: Next.js (Turbopack) | Nitro fan-out fan-in 10 streams (1MB each)💻 Local Development
▲ Production (Vercel)
🔍 Observability: Next.js (Turbopack) | Nitro SummaryFastest Framework by WorldWinner determined by most benchmark wins
Fastest World by FrameworkWinner determined by most benchmark wins
Column Definitions
Worlds:
❌ Some benchmark jobs failed:
Check the workflow run for details. |
🧪 E2E Test Results❌ Some tests failed Summary
❌ Failed Tests▲ Vercel Production (2 failed)astro (1 failed):
nuxt (1 failed):
📦 Local Production (1 failed)nextjs-turbopack-stable-lazy-discovery-enabled (1 failed):
Details by Category❌ ▲ Vercel Production
✅ 💻 Local Development
❌ 📦 Local Production
✅ 🐘 Local Postgres
✅ 🪟 Windows
✅ 📋 Other
❌ Some E2E test jobs failed:
Check the workflow run for details. |
027316f to
c661ac8
Compare
2c782ac to
cd5e4b7
Compare
| }); | ||
|
|
||
| // Tools are plain async functions in this pattern. `streamText` calls them | ||
| // from inside `runTurn` (a step), and the `"use step"` directive is a no-op |
There was a problem hiding this comment.
I feel like this comment is more of a changelog than describing the current state? Since we removed the "use step"
VaguelySerious
left a comment
There was a problem hiding this comment.
LGTM assuming this was tested, some wording nits
Co-authored-by: Peter Wielander <mittgfu@gmail.com> Signed-off-by: Karthik Kalyan <105607645+karthikscale3@users.noreply.github.com>
Summary
The AI SDK cookbook entry (
docs/content/docs/v{4,5}/cookbook/integrations/ai-sdk.mdx) showsstreamTextinside a"use step"turn function with the example tools (lookupOrder,processRefund) also marked"use step". That presentation implies tool calls are individually durable, but per Workflows & Steps the"use step"directive is a no-op when called from another step. So in this pattern tools run as plain inline functions insiderunTurn, and the durability boundary is the entire turn — if anything in the turn throws, every tool call that already ran is replayed.This PR fixes the cookbook to reflect that reality and gives readers an explicit migration path (idempotent tools or
DurableAgent).Changes (applied identically to v4 and v5)
"use step"directive fromlookupOrderandprocessRefundin the workflow code sample, with an inline comment explaining why.summaryand intro paragraph: dropped the inaccurate "tools remain durable steps" claim; explicitly call out the per-turn durability boundary.runTurn, not the tool call.processRefund) can run multiple times if the turn retries.DurableAgent(each tool call becomes its own durable step).runTurndurability-boundary bullet to How it works.tool()no longer claims tools wrap"use step"functions / are replayed from the log."use step"is now described as applied torunTurn, not to "tool executions".Test plan
/cookbook/integrations/ai-sdkpage on v4 and v5.#tools-are-not-individually-durable) resolves from the intro paragraph, How it works, and Key APIs cross-links.Made with Cursor