From e876063edd1d873810f6ed527e209ff96c6748cd Mon Sep 17 00:00:00 2001 From: "github-actions[bot]" <41898282+github-actions[bot]@users.noreply.github.com> Date: Thu, 14 May 2026 20:13:57 +0000 Subject: [PATCH] docs(ai): update durable agents guide to use ToolLoopAgent (#1975) The AI SDK renamed `Experimental_Agent` to `ToolLoopAgent`. Update the "Building Durable AI Agents" page's API route snippet (v4 and v5) so it matches the current AI SDK API. Co-authored-by: Cursor Signed-off-by: Karthik Kalyan <105607645+karthikscale3@users.noreply.github.com> --- docs/content/docs/ai/index.mdx | 11 ++++++----- 1 file changed, 6 insertions(+), 5 deletions(-) diff --git a/docs/content/docs/ai/index.mdx b/docs/content/docs/ai/index.mdx index 393462507b..90958b5dac 100644 --- a/docs/content/docs/ai/index.mdx +++ b/docs/content/docs/ai/index.mdx @@ -120,16 +120,17 @@ The core code that makes all of this happen is quite simple. Here's a breakdown -Our API route makes a simple call to [AI SDK's `Agent` class](https://ai-sdk.dev/docs/agents/overview), which is a simple wrapper around [AI SDK's `streamText` function](https://ai-sdk.dev/docs/reference/ai-sdk-core/stream-text#streamtext). This is also where we pass tools to the agent. +Our API route makes a simple call to [AI SDK's `ToolLoopAgent` class](https://ai-sdk.dev/docs/agents/overview), which encapsulates the LLM call, tool execution loop, and stopping conditions on top of [AI SDK's `streamText` function](https://ai-sdk.dev/docs/reference/ai-sdk-core/stream-text#streamtext). This is also where we pass tools to the agent. ```typescript title="app/api/chat/route.ts" lineNumbers -import { Experimental_Agent as Agent } from "ai"; -import type { LanguageModel } from "ai"; +import { ToolLoopAgent } from "ai"; +import type { UIMessage } from "ai"; +import { convertToModelMessages, createUIMessageStreamResponse } from "ai"; export async function POST(req: Request) { const { messages }: { messages: UIMessage[] } = await req.json(); - const agent = new Agent({ // [!code highlight] - model: gateway("bedrock/claude-4-5-haiku-20251001-v1"), + const agent = new ToolLoopAgent({ // [!code highlight] + model: "bedrock/claude-4-5-haiku-20251001-v1", instructions: FLIGHT_ASSISTANT_PROMPT, tools: flightBookingTools, });