Skip to content
Merged
268 changes: 268 additions & 0 deletions src/content/changelog/agents/2025-09-03-agents-sdk-beta-v5.mdx
Original file line number Diff line number Diff line change
@@ -0,0 +1,268 @@
---
title: Agents SDK v0.1.0 and workers-ai-provider v2.0.0 with AI SDK v5 support
description: The latest release updates the Agents SDK with full AI SDK v5 compatibility, updated workers-ai-provider v2.0.0 with enhanced streaming and tool support, seamless legacy message migration, tool confirmation detection, and React hooks for building production-ready AI chat interfaces.
products:
- agents
- workers
date: 2025-09-10
---

We've shipped a new release for the [Agents SDK](https://github.com/cloudflare/agents) bringing full compatibility with [AI SDK v5](https://ai-sdk.dev/docs/introduction) and introducing automatic message migration that handles all legacy formats transparently.

This release includes improved streaming and tool support, tool confirmation detection (for "human in the loop" systems), enhanced React hooks with automatic tool resolution, improved error handling for streaming responses, and seamless migration utilities that work behind the scenes.

This makes it ideal for building production AI chat interfaces with Cloudflare Workers AI models, agent workflows, human-in-the-loop systems, or any application requiring reliable message handling across SDK versions — all while maintaining backward compatibility.

Additionally, we've updated workers-ai-provider v2.0.0, the official provider for Cloudflare Workers AI models, to be compatible with AI SDK v5.

#### useAgentChat(options)

Creates a new chat interface with enhanced v5 capabilities.

```ts
// Basic chat setup
const { messages, sendMessage, addToolResult } = useAgentChat({
agent,
experimental_automaticToolResolution: true,
tools,
});

// With custom tool confirmation
const chat = useAgentChat({
agent,
experimental_automaticToolResolution: true,
toolsRequiringConfirmation: ["dangerousOperation"],
});
```

#### Automatic Tool Resolution

Tools are automatically categorized based on their configuration:

```ts
const tools = {
// Auto-executes (has execute function)
getLocalTime: {
description: "Get current local time",
inputSchema: z.object({}),
execute: async () => new Date().toLocaleString(),
},

// Requires confirmation (no execute function)
deleteFile: {
description: "Delete a file from the system",
inputSchema: z.object({
filename: z.string(),
}),
},

// Server-executed (no client confirmation)
analyzeData: {
description: "Analyze dataset on server",
inputSchema: z.object({ data: z.array(z.number()) }),
serverExecuted: true,
},
} satisfies Record<string, AITool>;
```

#### Message Handling

Send messages using the new v5 format with parts array:

```ts
// Text message
sendMessage({
role: "user",
parts: [{ type: "text", text: "Hello, assistant!" }],
});

// Multi-part message with file
sendMessage({
role: "user",
parts: [
{ type: "text", text: "Analyze this image:" },
{ type: "image", image: imageData },
],
});
```

#### Tool Confirmation Detection

Simplified logic for detecting pending tool confirmations:

```ts
const pendingToolCallConfirmation = messages.some((m) =>
m.parts?.some(
(part) => isToolUIPart(part) && part.state === "input-available",
),
);

// Handle tool confirmation
if (pendingToolCallConfirmation) {
await addToolResult({
toolCallId: part.toolCallId,
tool: getToolName(part),
output: "User approved the action",
});
}
```

### Automatic Message Migration

Seamlessly handle legacy message formats without code changes.

```ts
// All these formats are automatically converted:

// Legacy v4 string content
const legacyMessage = {
role: "user",
content: "Hello world",
};

// Legacy v4 with tool calls
const legacyWithTools = {
role: "assistant",
content: "",
toolInvocations: [
{
toolCallId: "123",
toolName: "weather",
args: { city: "SF" },
state: "result",
result: "Sunny, 72°F",
},
],
};

// Automatically becomes v5 format:
// {
// role: "assistant",
// parts: [{
// type: "tool-call",
// toolCallId: "123",
// toolName: "weather",
// args: { city: "SF" },
// state: "result",
// result: "Sunny, 72°F"
// }]
// }
```

### Tool Definition Updates

Migrate tool definitions to use the new `inputSchema` property.

```ts
// Before (AI SDK v4)
const tools = {
weather: {
description: "Get weather information",
parameters: z.object({
city: z.string(),
}),
execute: async (args) => {
return await getWeather(args.city);
},
},
};

// After (AI SDK v5)
const tools = {
weather: {
description: "Get weather information",
inputSchema: z.object({
city: z.string(),
}),
execute: async (args) => {
return await getWeather(args.city);
},
},
};
```

### Cloudflare Workers AI Integration

Seamless integration with Cloudflare Workers AI models through the updated workers-ai-provider v2.0.0.

#### Model Setup with Workers AI

Use Cloudflare Workers AI models directly in your agent workflows:

```ts
import { createWorkersAI } from "workers-ai-provider";
import { useAgentChat } from "agents/ai-react";

// Create Workers AI model (v2.0.0 - same API, enhanced v5 internals)
const model = createWorkersAI({
binding: env.AI,
})("@cf/meta/llama-3.2-3b-instruct");
```

#### Enhanced File and Image Support

Workers AI models now support v5 file handling with automatic conversion:

```ts
// Send images and files to Workers AI models
sendMessage({
role: "user",
parts: [
{ type: "text", text: "Analyze this image:" },
{
type: "file",
data: imageBuffer,
mediaType: "image/jpeg",
},
],
});

// Workers AI provider automatically converts to proper format
```

#### Streaming with Workers AI

Enhanced streaming support with automatic warning detection:

```ts
// Streaming with Workers AI models
const result = await streamText({
model: createWorkersAI({ binding: env.AI })("@cf/meta/llama-3.2-3b-instruct"),
messages,
onChunk: (chunk) => {
// Enhanced streaming with warning handling
console.log(chunk);
},
});
```

### Import Updates

Update your imports to use the new v5 types:

```ts
// Before (AI SDK v4)
import type { Message } from "ai";
import { useChat } from "ai/react";

// After (AI SDK v5)
import type { UIMessage } from "ai";
// or alias for compatibility
import type { UIMessage as Message } from "ai";
import { useChat } from "@ai-sdk/react";
```

## Resources

- [Migration Guide](https://github.com/cloudflare/agents/blob/main/docs/migration-to-ai-sdk-v5.md) - Comprehensive migration documentation
- [AI SDK v5 Documentation](https://ai-sdk.dev/docs/migration-guides/migration-guide-5-0) - Official AI SDK migration guide
- [An Example PR showing the migration from AI SDK v4 to v5](https://github.com/cloudflare/agents-starter/pull/105)
- [GitHub Issues](https://github.com/cloudflare/agents/issues) - Report bugs or request features

## Feedback Welcome

We'd love your feedback! We're particularly interested in feedback on:

- **Migration experience** - How smooth was the upgrade process?
- **Tool confirmation workflow** - Does the new automatic detection work as expected?
- **Message format handling** - Any edge cases with legacy message conversion?
Original file line number Diff line number Diff line change
@@ -0,0 +1,13 @@
---
title: Bidirectional tunnel health checks are compatible with all Magic on-ramps
description: Bidirectional tunnel health check return packets are accepted by any Magic on-ramp
date: 2025-09-05
---

All bidirectional tunnel health check return packets are accepted by any Magic on-ramp.

Previously, when a Magic tunnel had a bidirectional health check configured, the bidirectional health check would pass when the return packets came back to Cloudflare over the same tunnel that was traversed by the forward packets.

There are SD-WAN devices, like VeloCloud, that do not offer controls to steer traffic over one tunnel versus another in a high availability tunnel configuration.

Now, when a Magic tunnel has a bidirectional health check configured, the bidirectional health check will pass when the return packet traverses over any tunnel in a high availability configuration.
Original file line number Diff line number Diff line change
@@ -0,0 +1,9 @@
---
title: Custom IKE ID for IPsec Tunnels
description: Customers can now set a custom IKE ID for their IPsec Tunnels
date: 2025-09-08
---

Now, Magic WAN customers can configure a custom IKE ID for their IPsec tunnels. Customers that are using Magic WAN and a VeloCloud SD-WAN device together can utilize this new feature to create a high availability configuration.

This feature is available via API only. Customers can read the Magic WAN documentation to learn more about the [Custom IKE ID feature and the API call to configure it](/magic-wan/configuration/common-settings/custom-ike-id-ipsec/).
3 changes: 1 addition & 2 deletions src/content/docs/1.1.1.1/troubleshooting.mdx
Original file line number Diff line number Diff line change
Expand Up @@ -8,10 +8,9 @@ head:
- tag: title
content: Troubleshooting DNS Resolver
slug: 1.1.1.1/troubleshooting

---

import { Render } from "~/components"
import { Render } from "~/components";

This guide will help you diagnose and resolve common issues with Cloudflare's DNS Resolver. Before proceeding with manual troubleshooting steps, you can [verify your connection](/1.1.1.1/check/) to automatically gather relevant information.

Expand Down
4 changes: 3 additions & 1 deletion src/content/docs/magic-transit/how-to/advertise-prefixes.mdx
Original file line number Diff line number Diff line change
Expand Up @@ -150,6 +150,8 @@ Optionally, you can use BGP to control the advertisement status of your prefix

Prefixes can be advertised from Cloudflare's network in a supported on-demand method such as BGP Control, or dynamically via the UI, API, or [Magic Network Monitoring](/magic-transit/magic-network-monitoring/). During the onboarding of your on-demand prefixes, please specify whether you want BGP-controlled advertisement or dynamic advertisement (via dashboard/API/Magic Network Monitoring).

Our network architecture utilizes multiple, redundant Route Reflectors, ensuring that the failure of any single reflector does not impact overall network resiliency or traffic forwarding. For maximum resiliency, we recommend peering with all three of Cloudflare's redundant Route Reflectors, as this architecture ensures the failure of any single reflector does not impact overall network availability or traffic forwarding.

To begin using BGP control, contact your account team with the following information:

- BGP endpoint IP addresses
Expand Down Expand Up @@ -251,4 +253,4 @@ neighbor 173.245.63.66 {
neighbor 141.101.67.22 {
description "CF RR#3 CDG";
}
```
```
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@
pcx_content_type: how-to
title: Check tunnel health in the dashboard
sidebar:
order: 3
order: 2
---

import { Render } from "~/components";
Expand All @@ -11,18 +11,20 @@ import { Render } from "~/components";
file="tunnel-health/check-tunnel-healthchecks-dash"
product="networking-services"
params={{
dashInfo: "The dashboard shows the view of tunnel health as measured from each Cloudflare location where your traffic is likely to land.",
dashInfo:
"The dashboard shows the view of tunnel health as measured from each Cloudflare location where your traffic is likely to land.",
productPath: "**Magic WAN** > **Network health**",
graphQL: "/magic-wan/analytics/query-tunnel-health/",
notificationsPath: "[notifications wizard](/magic-wan/configuration/common-settings/configure-magic-tunnel-health-alerts/)"
notificationsPath:
"[notifications wizard](/magic-wan/configuration/common-settings/configure-magic-tunnel-health-alerts/)",
}}
/>

<Render
file="tunnel-health/health-checks-compatible-cmb-eu"
product="networking-services"
params={{
productName: "Magic WAN"
productName: "Magic WAN",
}}
/>

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,8 @@ pcx_content_type: how-to
title: Configure Magic Tunnel health alerts
head: []
description: Use the API to set up and configure Magic Tunnel health alerts
sidebar:
order: 4
---

import { Render } from "~/components";
Expand All @@ -13,8 +15,9 @@ import { Render } from "~/components";
params={{
magicWord: "Magic WAN",
productName: "Magic WAN",
magicTunnelHealthCheckCalculation: "/magic-wan/reference/how-cloudflare-calculates-magic-tunnel-health-alerts/",
magicTunnelHealthCheckCalculation:
"/magic-wan/reference/how-cloudflare-calculates-magic-tunnel-health-alerts/",
networkAnalyticsPath: "/magic-wan/analytics/network-analytics/",
healthChecks: "/magic-wan/reference/tunnel-health-checks/",
}}
/>
/>
Loading
Loading