Skip to content

Commit 188fd18

Browse files
committed
Add release notes for Agents SDK + AI SDK v5 update
1 parent fc54a67 commit 188fd18

File tree

1 file changed

+249
-0
lines changed

1 file changed

+249
-0
lines changed
Lines changed: 249 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,249 @@
1+
---
2+
title: Agents SDK v0.1.0-beta adds AI SDK v5 support, automatic message migration, and enhanced tool workflows
3+
description: The latest release transforms the Agents SDK with full AI SDK v5 compatibility, seamless legacy message migration, intelligent tool confirmation detection, and streamlined React hooks for building production-ready AI chat interfaces.
4+
products:
5+
- agents
6+
- workers
7+
date: 2025-09-03
8+
---
9+
10+
We've shipped a major 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.
11+
12+
This update adds tool confirmation detection, enhanced React hooks with automatic tool resolution, improved error handling for streaming responses, and seamless migration utilities that work behind the scenes.
13+
14+
This makes it ideal for building production AI chat interfaces, agent workflows, human-in-the-loop systems, or any application requiring reliable message handling across SDK versions — all while maintaining backward compatibility.
15+
16+
## Core Changes
17+
18+
### 1. Message Type Updates
19+
20+
**Before (AI SDK v4):**
21+
22+
```typescript
23+
import type { Message } from "ai";
24+
25+
const message: Message = {
26+
id: "123",
27+
role: "user",
28+
content: "Hello, assistant!",
29+
};
30+
```
31+
32+
**After (AI SDK v5):**
33+
34+
```typescript
35+
import type { UIMessage } from "ai";
36+
// or alias for compatibility
37+
import type { UIMessage as Message } from "ai";
38+
39+
const message: UIMessage = {
40+
id: "123",
41+
role: "user",
42+
parts: [
43+
{
44+
type: "text",
45+
text: "Hello, assistant!",
46+
},
47+
],
48+
};
49+
```
50+
51+
### 2. Enhanced useAgentChat Hook
52+
53+
**New automatic tool resolution:**
54+
55+
```typescript
56+
import { useAgentChat, type AITool } from "agents/ai-react";
57+
58+
// Define tools with execute functions for automatic resolution
59+
const tools = {
60+
getLocalTime: {
61+
description: "Get current local time",
62+
inputSchema: z.object({}),
63+
execute: async () => new Date().toLocaleString(), // Auto-executes
64+
},
65+
getWeatherInformation: {
66+
description: "Get weather for a location",
67+
inputSchema: z.object({
68+
location: z.string(),
69+
}),
70+
// No execute function = requires confirmation
71+
},
72+
} satisfies Record<string, AITool>;
73+
74+
const { messages, sendMessage, addToolResult } = useAgentChat({
75+
agent,
76+
experimental_automaticToolResolution: true,
77+
tools, // Automatic detection based on execute function presence
78+
});
79+
```
80+
81+
### 3. Simplified Message Sending
82+
83+
**New v5 message format:**
84+
85+
```typescript
86+
// Send message with new parts structure
87+
sendMessage({
88+
role: "user",
89+
parts: [{ type: "text", text: input }],
90+
});
91+
```
92+
93+
### 4. Tool Definition Migration
94+
95+
**Before:**
96+
97+
```typescript
98+
const tools = {
99+
weather: {
100+
description: "Get weather information",
101+
parameters: z.object({
102+
city: z.string(),
103+
}),
104+
execute: async (args) => {
105+
// Implementation
106+
},
107+
},
108+
};
109+
```
110+
111+
**After:**
112+
113+
```typescript
114+
const tools = {
115+
weather: {
116+
description: "Get weather information",
117+
inputSchema: z.object({
118+
city: z.string(),
119+
}),
120+
execute: async (args) => {
121+
// Implementation
122+
},
123+
},
124+
};
125+
```
126+
127+
### 5. Enhanced Tool Confirmation Logic
128+
129+
**Before (manual logic in components):**
130+
131+
```typescript
132+
const pendingToolCallConfirmation = messages.some((m) =>
133+
m.parts?.some(
134+
(part) =>
135+
isToolUIPart(part) &&
136+
part.state === "input-available" &&
137+
// Manual check inside the component
138+
!(tools as Record<string, any>)[getToolName(part)]?.execute,
139+
),
140+
);
141+
```
142+
143+
**After (simplified with automatic detection):**
144+
145+
```typescript
146+
const pendingToolCallConfirmation = messages.some((m) =>
147+
m.parts?.some(
148+
(part) => isToolUIPart(part) && part.state === "input-available",
149+
),
150+
);
151+
```
152+
153+
### 6. Type Safety Improvements
154+
155+
**New enum-based message types:**
156+
157+
```typescript
158+
export enum MessageType {
159+
CF_AGENT_CHAT_MESSAGES = "cf_agent_chat_messages",
160+
CF_AGENT_USE_CHAT_REQUEST = "cf_agent_use_chat_request",
161+
CF_AGENT_USE_CHAT_RESPONSE = "cf_agent_use_chat_response",
162+
CF_AGENT_CHAT_CLEAR = "cf_agent_chat_clear",
163+
CF_AGENT_CHAT_REQUEST_CANCEL = "cf_agent_chat_request_cancel",
164+
}
165+
166+
export type OutgoingMessage<ChatMessage extends UIMessage = UIMessage> =
167+
| {
168+
type: MessageType.CF_AGENT_CHAT_MESSAGES;
169+
messages: ChatMessage[];
170+
}
171+
| {
172+
type: MessageType.CF_AGENT_USE_CHAT_RESPONSE;
173+
id: string;
174+
body: string;
175+
done: boolean;
176+
error?: boolean;
177+
};
178+
```
179+
180+
## 🔧 Breaking Changes
181+
182+
### Message Format Migration
183+
184+
- **Type change**: `Message``UIMessage` (with automatic conversion)
185+
- **Structure change**: `content: string``parts: [{type: "text", text}]`
186+
- **Import updates**: Some imports moved to scoped packages like `@ai-sdk/react`
187+
188+
### Tool Definition Updates
189+
190+
```typescript
191+
// Before
192+
const tools = {
193+
weather: {
194+
parameters: z.object({ city: z.string() }),
195+
},
196+
};
197+
198+
// After
199+
const tools = {
200+
weather: {
201+
inputSchema: z.object({ city: z.string() }),
202+
},
203+
};
204+
```
205+
206+
## Migration Path
207+
208+
### Automatic Data Migration (Recommended)
209+
210+
**No action required!** The SDK automatically handles all message format conversions:
211+
212+
- Loading messages from database
213+
- Processing incoming messages
214+
- All message entry points
215+
216+
### Manual Migration (Optional)
217+
218+
For advanced use cases, migration utilities are available:
219+
220+
```typescript
221+
import { autoTransformMessages, analyzeCorruption } from "agents";
222+
223+
// Analyze existing messages
224+
const stats = analyzeCorruption(messages);
225+
console.log(`Found ${stats.legacyString} legacy messages`);
226+
227+
// Manual transformation (usually not needed)
228+
const cleanMessages = autoTransformMessages(anyFormatMessages);
229+
```
230+
231+
## Resources
232+
233+
- [Migration Guide](https://github.com/cloudflare/agents/blob/main/docs/migration-to-ai-sdk-v5.md) - Comprehensive migration documentation
234+
- [AI SDK v5 Documentation](https://ai-sdk.dev/docs/migration-guides/migration-guide-5-0) - Official AI SDK migration guide
235+
- [GitHub Issues](https://github.com/cloudflare/agents/issues) - Report bugs or request features
236+
237+
## Feedback Welcome
238+
239+
This is a **beta release** - we'd love your feedback! Please test it in your development environment and let us know:
240+
241+
We're particularly interested in feedback on:
242+
243+
- **Migration experience** - How smooth was the upgrade process?
244+
- **Tool confirmation workflow** - Does the new automatic detection work as expected?
245+
- **Message format handling** - Any edge cases with legacy message conversion?
246+
247+
---
248+
249+
_Note: This is a beta release. While we've tested extensively, please validate thoroughly in your development environment before considering production use._

0 commit comments

Comments
 (0)