Skip to content

Commit 8df9a0b

Browse files
committed
fix changelog
1 parent 9981116 commit 8df9a0b

File tree

1 file changed

+39
-21
lines changed

1 file changed

+39
-21
lines changed

src/content/changelog/agents/2025-03-18-npm-i-agents.mdx

Lines changed: 39 additions & 21 deletions
Original file line numberDiff line numberDiff line change
@@ -41,39 +41,59 @@ Future updates will be pushed to the new `agents` package, and the older package
4141

4242
We've added a number of big new features to the Agents SDK over the past few weeks, including:
4343

44-
- TODO
45-
- TODO: you can now set `cors: true` when using `routeAgentRequest` to return permissive default CORS headers to Agent responses.
46-
- TODO: the regular client now syncs state on the agent (just like the react version)
47-
- TODO: useAgentChat bug fixes for passing headers/credentials, properly clearing cache on unmount, etc
48-
- TODO: experiemental /schedule module with a prompt/schema for adding scheduling to your app (with evals!)
44+
- You can now set `cors: true` when using `routeAgentRequest` to return permissive default CORS headers to Agent responses.
45+
- Te regular client now syncs state on the agent (just like the React version)
46+
- `useAgentChat` bug fixes for passing headers/credentials, includng properly clearing cache on unmount.
47+
- Experimental `/schedule` module with a prompt/schema for adding scheduling to your app (with evals!)
48+
- Changed the internal `zod` schema to be compatible with the limitations of Google's Gemini models by removing the discriminated union, allowing you to use Gemini models with the scheduling API.
4949

5050
We've also fixed a number of bugs with state synchronization and the React hooks.
5151

52+
<TypeScriptExample>
53+
54+
```ts
55+
// via https://github.com/cloudflare/agents/tree/main/examples/cross-domain
56+
export default {
57+
async fetch(request: Request, env: Env) {
58+
return (
59+
// Set { cors: true } to enable CORS headers.
60+
(await routeAgentRequest(request, env, { cors: true })) ||
61+
new Response("Not found", { status: 404 })
62+
);
63+
},
64+
} satisfies ExportedHandler<Env>;
65+
```
66+
67+
</TypeScriptExample>
68+
5269
#### Call Agent methods from your client code <Badge text="New" variant="tip" size="small" />
5370

54-
We've added a new [`@callable()`](/agents/api-reference/agents-api/) decorator for defining methods that can be called directly from clients. This allows you call methods from within your client code: you can call methods (with arguments) and get native JavaScript objects back.
71+
We've added a new [`@unstable_callable()`](/agents/api-reference/agents-api/) decorator for defining methods that can be called directly from clients. This allows you call methods from within your client code: you can call methods (with arguments) and get native JavaScript objects back.
5572

5673
<TypeScriptExample>
5774

5875
```ts
5976
// server.ts
60-
import { Agent, callable } from 'agents';
61-
62-
class MyAgent extends Agent {
63-
@callable()
64-
async getHistory(limit: number = 10): Promise<string[]> {
65-
// Allow a client to directly fetch chat history
66-
return this.state.chatHistory.slice(-limit)
67-
}
68-
}
69-
77+
import { unstable_callable, Agent, type StreamingResponse } from "agents";
78+
import type { Env } from "../server";
79+
80+
export class Rpc extends Agent<Env> {
81+
// Use the decorator to define a callable method
82+
@unstable_callable({
83+
description: "rpc test",
84+
})
85+
async getHistory() {
86+
return this.sql`SELECT * FROM history ORDER BY created_at DESC LIMIT 10`;
87+
}
88+
```
89+
```tsx
7090
// client.tsx
7191
const { call } = useAgent({ agent: "rpc" });
7292

7393
const fetchUserHistory = async () => {
7494
try {
7595
setLoading(true);
76-
// Call methods directly on the Agent
96+
// Call methods directly on the Agent!
7797
const result = await call("getHistory");
7898
addToast(`RPC result: ${result}`, "success");
7999
} catch (error) {
@@ -82,18 +102,16 @@ const fetchUserHistory = async () => {
82102
setLoading(false);
83103
}
84104
};
85-
86105
```
106+
87107
</TypeScriptExample>
88108
89109
#### agents-starter <Badge text="Updated" variant="tip" size="small" />
90110
91111
The [`agents-starter`](https://github.com/cloudflare/agents-starter) project — a real-time, chat-based example application with tool-calling & human-in-the-loop built using the Agents SDK — has seen the following updates:
92112
93-
- TODO
94113
- Upgraded to use the latest [wrangler v4](/changelog/2025-03-13-wrangler-v4/) release.
95114
- [Workers AI](/workers-ai/) is now the default AI provider in the [`agents-starter`](https://github.com/cloudflare/agents-starter) project: this uses the new [structured outputs](/changelog/2025-02-25-json-mode/) (or "JSON mode") support now in Workers AI and the [`workers-ai-provider`](https://sdk.vercel.ai/providers/community-providers/cloudflare-workers-ai#generateobject).
96-
- Changed the internal `zod` schema to be compatible with the limitations of Google's Gemini models, allowing you to use Gemini models with the starter.
97115
98116
If you're new to Agents, you can install and run the `agents-starter` project in two commands:
99117
@@ -109,7 +127,7 @@ $ npm run start
109127
We've heard your feedback on the Agents SDK documentation, and we're shipping more API reference material and usage examples, including:
110128
111129
- Expanded [API reference documentation](/agents/api-reference/), covering the methods and properties exposed by the Agents SDK, as well as more usage examples.
112-
- More [Client API](/agents/api-reference/agents-api/#client-api) documentation that documents `useAgent`, `useAgentChat` and the new `@callable` RPC decorator exposed by the SDK.
130+
- More [Client API](/agents/api-reference/agents-api/#client-api) documentation that documents `useAgent`, `useAgentChat` and the new `@unstable_callable` RPC decorator exposed by the SDK.
113131
- New documentation on how to [call agents](/agents/api-reference/calling-agents/) and (optionally) authenticate clients before they connect to your Agents.
114132
115133
Note that the Agents SDK is continually growing: the type definitions included in the SDK will always include the latest APIs exposed by the `agents` package.

0 commit comments

Comments
 (0)