Skip to content
Merged
Show file tree
Hide file tree
Changes from 63 commits
Commits
Show all changes
65 commits
Select commit Hold shift + click to select a range
8b4409d
commit
elithrar Feb 26, 2025
0063eaf
sidebar ordering
elithrar Feb 26, 2025
6a871eb
name
elithrar Feb 26, 2025
75ff06f
add API reference
elithrar Feb 27, 2025
0215713
fix intro
elithrar Feb 27, 2025
9e043e8
store and sync state
elithrar Feb 27, 2025
5152c59
SDK ref
elithrar Feb 27, 2025
e065236
initial state
elithrar Feb 27, 2025
92f6ce4
fix MDX syntax
elithrar Feb 27, 2025
f673904
improve API ref
elithrar Feb 27, 2025
8f93e0a
fix broken link
elithrar Feb 27, 2025
129a10b
re-title
elithrar Feb 27, 2025
b8b1d21
updates
elithrar Mar 6, 2025
15f20cf
fix frontmatter
elithrar Mar 6, 2025
4ada4fe
calling agents
elithrar Mar 6, 2025
d6b891a
updates
elithrar Mar 8, 2025
ec0f5e8
quickstart
elithrar Mar 8, 2025
6546dba
agents
elithrar Mar 10, 2025
2034344
update
elithrar Mar 10, 2025
d507cef
updates
elithrar Mar 10, 2025
45c5c11
fix
elithrar Mar 11, 2025
eebde1f
SSE
elithrar Mar 11, 2025
2ba1cda
sse
elithrar Mar 11, 2025
47baffc
auth
elithrar Mar 11, 2025
2056f6b
add redirect
elithrar Mar 11, 2025
5c3154d
ok
elithrar Mar 11, 2025
334c2a1
unique partial
elithrar Mar 11, 2025
dbd9ff0
headers
elithrar Mar 11, 2025
c97e6f6
agents docs
elithrar Mar 13, 2025
0665bdd
updates
elithrar Mar 14, 2025
601d7fb
more
elithrar Mar 14, 2025
55eff01
agents-sdk -> agents
elithrar Mar 14, 2025
50b6bbc
changelog headers / order
elithrar Mar 14, 2025
60b8bf4
fix image name
elithrar Mar 14, 2025
2887519
import Badge
elithrar Mar 14, 2025
283ca9b
fix
elithrar Mar 14, 2025
06a2a7f
IMAGE COMPONENT
elithrar Mar 14, 2025
ae52ec0
fixed image
elithrar Mar 14, 2025
16580de
reorder
elithrar Mar 14, 2025
474e64b
update
elithrar Mar 14, 2025
ef2b3c5
update API ref
elithrar Mar 15, 2025
5cf750a
update
elithrar Mar 15, 2025
15c033e
update
elithrar Mar 15, 2025
e75b385
\n
elithrar Mar 15, 2025
13adc2f
fix example
elithrar Mar 16, 2025
31ee719
ok
elithrar Mar 17, 2025
988d91a
Fix
elithrar Mar 17, 2025
151b99a
example linting
elithrar Mar 17, 2025
64d3f27
fix
elithrar Mar 17, 2025
4f17542
fix
elithrar Mar 17, 2025
3100d2c
date
elithrar Mar 17, 2025
9bb3e9f
fix
elithrar Mar 17, 2025
3602165
fix
elithrar Mar 17, 2025
bc22f39
ok
elithrar Mar 17, 2025
2625119
reference
elithrar Mar 17, 2025
9981116
update
elithrar Mar 17, 2025
8df9a0b
fix changelog
elithrar Mar 17, 2025
e732381
fix typo
elithrar Mar 17, 2025
1e74471
ok
elithrar Mar 17, 2025
99bbebc
ok
elithrar Mar 17, 2025
77c4e1a
icon
elithrar Mar 17, 2025
d9bdb21
ok
elithrar Mar 17, 2025
367e3fe
k
elithrar Mar 17, 2025
17cf352
Apply suggestions from code review
elithrar Mar 18, 2025
eed1cf6
agents -> agents-sdk elsewhere
elithrar Mar 18, 2025
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
9 changes: 9 additions & 0 deletions public/_redirects
Original file line number Diff line number Diff line change
Expand Up @@ -98,6 +98,15 @@

# agents
/agents/build/prompts/ /workers/get-started/prompting/ 301
/agents/examples/browse-the-web/ /agents/api-reference/browse-the-web/ 301
/agents/examples/manage-and-sync-state/ /agents/api-reference/store-and-sync-state/ 301
/agents/examples/rag/ /agents/api-reference/rag/ 301
/agents/examples/run-workflows/ /agents/api-reference/run-workflows/ 301
/agents/examples/schedule-tasks/ /agents/api-reference/schedule-tasks/ 301
/agents/examples/using-ai-models/ /agents/api-reference/using-ai-models/ 301
/agents/examples/websockets/ /agents/api-reference/websockets/ 301
/agents/examples/sdk/ /agents/api-reference/agents-api/ 301
/agents/examples/build-mcp-server/ /agents/api-reference/build-mcp-server/ 301

# ai
/ai/ /use-cases/ai/ 301
Expand Down
Binary file added src/assets/images/agents/npm-i-agents.apng
Binary file not shown.
10 changes: 5 additions & 5 deletions src/content/changelog/agents/2025-02-25-agents-sdk.mdx
Original file line number Diff line number Diff line change
Expand Up @@ -9,23 +9,23 @@ date: 2025-02-25T14:00:00Z

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.

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 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:

```sh
npm create cloudflare@latest agents-starter -- --template="cloudflare/agents-starter"
# open up README.md and follow the instructions
```

You can also add an Agent to any existing Workers application by installing the `agents-sdk` package directly
You can also add an Agent to any existing Workers application by installing the `agents` package directly

```sh
npm i agents-sdk
npm i agents
```

... and then define your first Agent:

```ts
import { Agent } from 'agents-sdk';
import { Agent } from 'agents';

export class YourAgent extends Agent<Env> {
// Build it out
Expand All @@ -37,4 +37,4 @@ export class YourAgent extends Agent<Env> {
}
```

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.
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.
136 changes: 136 additions & 0 deletions src/content/changelog/agents/2025-03-18-npm-i-agents.mdx
Original file line number Diff line number Diff line change
@@ -0,0 +1,136 @@
---
title: npm i agents
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.
products:
- agents
- workers
date: 2025-03-18T14:00:00Z
---

import { Badge, MetaInfo, Render, TypeScriptExample } from "~/components"
import { Image } from 'astro:assets';
import npmAgentsAnimated from "~/assets/images/agents/npm-i-agents.apng"

<Image src={npmAgentsAnimated} alt="npm i agents" width="1000" height="541" />

#### `agents-sdk` -> `agents` <Badge text="Updated" variant="tip" size="small" />

📝 **We've renamed the Agents package to `agents`**!

If you've already been building with the Agents SDK, you can update your dependencies to use the new package name, and replace references to `agents-sdk` with `agents`:

```sh
# Install the new package
npm i agents
```

```sh
# Remove the old (deprecated) package
npm uninstall agents-sdk

# Find instances of the old package name in your codebase
grep -r 'agents-sdk' .
# Replace instances of the old package name with the new one
# (or use find-replace in your editor)
sed -i 's/agents-sdk/agents/g' $(grep -rl 'agents-sdk' .)
```

All future updates will be pushed to the new `agents` package, and the older package has been marked as deprecated.

#### Agents SDK updates <Badge text="New" variant="tip" size="small" />

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

- You can now set `cors: true` when using `routeAgentRequest` to return permissive default CORS headers to Agent responses.
- The regular client now syncs state on the agent (just like the React version)
- `useAgentChat` bug fixes for passing headers/credentials, includng properly clearing cache on unmount.
- Experimental `/schedule` module with a prompt/schema for adding scheduling to your app (with evals!)
- 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.

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

<TypeScriptExample>

```ts
// via https://github.com/cloudflare/agents/tree/main/examples/cross-domain
export default {
async fetch(request: Request, env: Env) {
return (
// Set { cors: true } to enable CORS headers.
(await routeAgentRequest(request, env, { cors: true })) ||
new Response("Not found", { status: 404 })
);
},
} satisfies ExportedHandler<Env>;
```

</TypeScriptExample>

#### Call Agent methods from your client code <Badge text="New" variant="tip" size="small" />

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.

<TypeScriptExample>

```ts
// server.ts
import { unstable_callable, Agent, type StreamingResponse } from "agents";
import type { Env } from "../server";

export class Rpc extends Agent<Env> {
// Use the decorator to define a callable method
@unstable_callable({
description: "rpc test",
})
async getHistory() {
return this.sql`SELECT * FROM history ORDER BY created_at DESC LIMIT 10`;
}
}
```
```tsx
// client.tsx
const { call } = useAgent({ agent: "rpc" });

const fetchUserHistory = async () => {
try {
setLoading(true);
// Call methods directly on the Agent!
const result = await call("getHistory");
addToast(`RPC result: ${result}`, "success");
} catch (error) {
addToast(`Error: ${error}`, "error");
} finally {
setLoading(false);
}
};
```

</TypeScriptExample>

#### agents-starter <Badge text="Updated" variant="tip" size="small" />

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:

- Upgraded to use the latest [wrangler v4](/changelog/2025-03-13-wrangler-v4/) release.
- [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).

If you're new to Agents, you can install and run the `agents-starter` project in two commands:

```sh
# Install it
$ npm create cloudflare@latest agents-starter -- --template="cloudflare/agents-starter"
# Run it
$ npm run start
```

#### More documentation <Badge text="Updated" variant="tip" size="small" />

We've heard your feedback on the Agents SDK documentation, and we're shipping more API reference material and usage examples, including:

- Expanded [API reference documentation](/agents/api-reference/), covering the methods and properties exposed by the Agents SDK, as well as more usage examples.
- 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.
- New documentation on how to [call agents](/agents/api-reference/calling-agents/) and (optionally) authenticate clients before they connect to your Agents.

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.

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.
Loading
Loading