You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
Copy file name to clipboardExpand all lines: src/content/changelog/agents/2025-02-25-agents-sdk.mdx
+5-5Lines changed: 5 additions & 5 deletions
Display the source diff
Display the rich diff
Original file line number
Diff line number
Diff line change
@@ -9,23 +9,23 @@ date: 2025-02-25T14:00:00Z
9
9
10
10
We've released the [agents-sdk](http://blog.cloudflare.com/build-ai-agents-on-cloudflare/), a package and set of tools that help you build and ship AI Agents.
11
11
12
-
You can get up and running with a [chat-based AI Agent](https://github.com/cloudflare/agents-starter) (and deploy it to Workers) that uses the `agents-sdk`, tool calling, and state syncing with a React-based front-end by running the following command:
12
+
You can get up and running with a [chat-based AI Agent](https://github.com/cloudflare/agents-starter) (and deploy it to Workers) that uses the Agents SDK, tool calling, and state syncing with a React-based front-end by running the following command:
You can also add an Agent to any existing Workers application by installing the `agents-sdk` package directly
19
+
You can also add an Agent to any existing Workers application by installing the `agents` package directly
20
20
21
21
```sh
22
-
npm i agents-sdk
22
+
npm i agents
23
23
```
24
24
25
25
... and then define your first Agent:
26
26
27
27
```ts
28
-
import { Agent } from'agents-sdk';
28
+
import { Agent } from'agents';
29
29
30
30
exportclassYourAgentextendsAgent<Env> {
31
31
// Build it out
@@ -37,4 +37,4 @@ export class YourAgent extends Agent<Env> {
37
37
}
38
38
```
39
39
40
-
Head over to the [Agents documentation](/agents/) to learn more about the `agents-sdk`, the SDK APIs, as well as how to test and deploying agents to production.
40
+
Head over to the [Agents documentation](/agents/) to learn more about the Agents SDK, the SDK APIs, as well as how to test and deploying agents to production.
description: Install the latest version of the `agents` SDK to build multi-agent applications, use the new RPC API, and visit the latest documentation updates.
4
+
products:
5
+
- agents
6
+
- workers
7
+
date: 2025-03-17T14:00:00Z
8
+
---
9
+
10
+

11
+
12
+
#### Multi-Agent applications and RPC
13
+
14
+
We've added a number of big new features to the Agents SDK over the past few weeks, including:
15
+
16
+
- TODO
17
+
- TODO
18
+
- TODO: the regular client now syncs state on the agent (just like the react version)
19
+
- TODO: useAgentChat bug fixes for passing headers/credentials, properly clearing cache on unmount, etc
20
+
- TODO: experiemental /schedule module with a prompt/schema for adding scheduling to your app (with evals!)
21
+
22
+
We've also fixed a nubmer of bugs with state synchronization and the React hooks.
23
+
24
+
### Call Agent methods from your client code
25
+
26
+
We've added a new [`@callable` decorator](/agents/api-reference/client-api/) 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.
27
+
28
+
<TypeScriptExample>
29
+
30
+
```ts
31
+
32
+
```
33
+
34
+
</TypeScriptExample>
35
+
36
+
#### agents-starter
37
+
38
+
TODO
39
+
40
+
- TODO
41
+
- Upgraded to use the latest [wrangler v4](/changelog/2025-03-13-wrangler-v4/) release.
42
+
-[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).
43
+
44
+
#### More documentation
45
+
46
+
We've contined to build out the Agents SDK documentation, including:
47
+
48
+
- Expanded [API reference documentation](/agents/api-reference/), covering the methods and properties exposed by the Agents SDK, as well as more usage examples.
49
+
- A new [Client API](/agents/api-reference/client-api/) reference that documents `useAgent`, `useAgentChat` and the new `@callable` decorator exposed by the SDK.
50
+
- New documentation on how to [call agents](/agents/api-refererence/calling-agents/) and authenticate clients, using [Server-Sent Events (SSE)](/agents/api-refererence/http-sse/).
51
+
52
+
#### `agents-sdk` -> `agents`
53
+
54
+
We've also renamed the Agents package to just `agents` (it's cleaner). If you've already been building with the Agents SDK, you can update your dependencies to use the new package name:
55
+
56
+
```sh
57
+
# Remove the old (deprecated) package
58
+
npm uninstall agents-sdk
59
+
60
+
# Install the new package
61
+
npm i agents
62
+
63
+
# Find instances of the old package name in your codebase
64
+
grep -r 'agents-sdk'.
65
+
# Replace instances of the old package name with the new one
66
+
# (or use find-replace in your editor)
67
+
sed -i 's/agents-sdk/agents/g'$(grep -rl 'agents-sdk' .)
68
+
```
69
+
70
+
If you're still wondering what Agents are, [read our blog on building AI Agents on Cloudflare](https://blog.cloudflare.com/build-ai-agents-on-cloudflare/) and/or visit the [Agents documentation](/agents/) to learn more.
This page provides an overview of the Agent SDK API, including the `Agent` class, methods and properties built-in to the `agents-sdk`.
11
+
This page provides an overview of the Agent SDK API, including the `Agent` class, methods and properties built-in to the Agents SDK.
12
12
13
-
An Agent is a JavaScript class that extends the `Agent` class from the `agents-sdk` package. An Agent encapsulates all of the logic for an Agent, including how clients can connect to it, how it stores state, the methods it exposes, and any error handling.
13
+
An Agent is a JavaScript class that extends the `Agent` class from the Agents SDK package. An Agent encapsulates all of the logic for an Agent, including how clients can connect to it, how it stores state, the methods it exposes, and any error handling.
14
14
15
15
<TypeScriptExample>
16
16
17
17
```ts
18
-
import { Agent } from"agents-sdk";
18
+
import { Agent } from"agents";
19
19
20
20
classMyAgentextendsAgent {
21
21
// Define methods on the Agent
@@ -34,14 +34,14 @@ Instances of an Agent are addressed by a unique identifier: that identifier (ID)
34
34
35
35
### Agent
36
36
37
-
Writing an Agent requires you to define a class that extends the `Agent` class from the `agents-sdk` package. An Agent encapsulates all of the logic for an Agent, including how clients can connect to it, how it stores state, the methods it exposes, and any error handling.
37
+
Writing an Agent requires you to define a class that extends the `Agent` class from the Agents SDK package. An Agent encapsulates all of the logic for an Agent, including how clients can connect to it, how it stores state, the methods it exposes, and any error handling.
38
38
39
39
You can also define your own methods on an Agent: it's technically valid to publish an Agent only has your own methods exposed, and create/get Agents directly from a Worker.
40
40
41
41
Your own methods can access the Agent's environment variables and bindings on `this.env`, state on `this.setState`, and call other methods on the Agent via `this.yourMethodName`.
42
42
43
43
```ts
44
-
import { Agent } from"agents-sdk";
44
+
import { Agent } from"agents";
45
45
46
46
interfaceEnv {
47
47
// Define environment variables & bindings here
@@ -361,7 +361,7 @@ function agentFetch(
361
361
362
362
### React API
363
363
364
-
The `agents-sdk` provides a React API for simplifying connection and routing to Agents from front-end frameworks, including React Router (Remix), Next.js, and Astro.
364
+
The Agents SDK provides a React API for simplifying connection and routing to Agents from front-end frameworks, including React Router (Remix), Next.js, and Astro.
365
365
366
366
#### useAgent
367
367
@@ -397,7 +397,7 @@ function useAgent<State = unknown>(
397
397
398
398
### Chat Agent
399
399
400
-
The `agents-sdk` exposes an `AIChatAgent` class that extends the `Agent` class and exposes an `onChatMessage` method that simplifies building interactive chat agents.
400
+
The Agents SDK exposes an `AIChatAgent` class that extends the `Agent` class and exposes an `onChatMessage` method that simplifies building interactive chat agents.
401
401
402
402
You can combine this with the `useAgentChat` React hook from the `agents-sdk/ai-react` package to manage chat state and messages between a user and your Agent(s).
403
403
@@ -473,6 +473,6 @@ To learn more about how to manage state within an Agent, refer to the documentat
473
473
474
474
### Next steps
475
475
476
-
*[Build a chat Agent](/agents/getting-started/build-a-chat-agent/) using the `agents-sdk` and deploy it to Workers.
476
+
*[Build a chat Agent](/agents/getting-started/build-a-chat-agent/) using the Agents SDK and deploy it to Workers.
477
477
* Learn more [using WebSockets](/agents/api-reference/websockets/) to build interactive Agents and stream data back from your Agent.
478
-
*[Orchestrate asynchronous workflows](/agents/api-reference/run-workflows) from your Agent by combining the `agents-sdk` and [Workflows](/workflows).
478
+
*[Orchestrate asynchronous workflows](/agents/api-reference/run-workflows) from your Agent by combining the Agents SDK and [Workflows](/workflows).
Copy file name to clipboardExpand all lines: src/content/docs/agents/api-reference/http-sse.mdx
+3-3Lines changed: 3 additions & 3 deletions
Display the source diff
Display the rich diff
Original file line number
Diff line number
Diff line change
@@ -104,11 +104,11 @@ Both WebSockets and Server-Sent Events (SSE) enable real-time communication betw
104
104
* While SSE works well for simple streaming scenarios, WebSockets are better suited for applications requiring minutes or hours of connection time, as they maintain a more stable connection with built-in ping/pong mechanisms to keep connections alive.
105
105
* WebSockets use their own protocol (ws:// or wss://), separating them from HTTP after the initial handshake. This separation allows WebSockets to better handle binary data transmission and implement custom subprotocols for specialized use cases.
106
106
107
-
If you're unsure of which is better for your use-case, we recommend WebSockets. The [WebSockets API documentation](/agents/api-reference/websockets/) provides detailed information on how to use WebSockets with the `agents-sdk`.
107
+
If you're unsure of which is better for your use-case, we recommend WebSockets. The [WebSockets API documentation](/agents/api-reference/websockets/) provides detailed information on how to use WebSockets with the Agents SDK.
108
108
109
109
### Next steps
110
110
111
111
* Review the [API documentation](/agents/api-reference/agents-api/) for the Agents class to learn how to define
112
-
*[Build a chat Agent](/agents/getting-started/build-a-chat-agent/) using the `agents-sdk` and deploy it to Workers.
112
+
*[Build a chat Agent](/agents/getting-started/build-a-chat-agent/) using the Agents SDK and deploy it to Workers.
113
113
* Learn more [using WebSockets](/agents/api-reference/websockets/) to build interactive Agents and stream data back from your Agent.
114
-
*[Orchestrate asynchronous workflows](/agents/api-reference/run-workflows) from your Agent by combining the `agents-sdk` and [Workflows](/workflows).
114
+
*[Orchestrate asynchronous workflows](/agents/api-reference/run-workflows) from your Agent by combining the Agents SDK and [Workflows](/workflows).
0 commit comments