-
Notifications
You must be signed in to change notification settings - Fork 10.2k
agents: update nav + add quickstart #20339
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Merged
Merged
Changes from 63 commits
Commits
Show all changes
65 commits
Select commit
Hold shift + click to select a range
8b4409d
commit
elithrar 0063eaf
sidebar ordering
elithrar 6a871eb
name
elithrar 75ff06f
add API reference
elithrar 0215713
fix intro
elithrar 9e043e8
store and sync state
elithrar 5152c59
SDK ref
elithrar e065236
initial state
elithrar 92f6ce4
fix MDX syntax
elithrar f673904
improve API ref
elithrar 8f93e0a
fix broken link
elithrar 129a10b
re-title
elithrar b8b1d21
updates
elithrar 15f20cf
fix frontmatter
elithrar 4ada4fe
calling agents
elithrar d6b891a
updates
elithrar ec0f5e8
quickstart
elithrar 6546dba
agents
elithrar 2034344
update
elithrar d507cef
updates
elithrar 45c5c11
fix
elithrar eebde1f
SSE
elithrar 2ba1cda
sse
elithrar 47baffc
auth
elithrar 2056f6b
add redirect
elithrar 5c3154d
ok
elithrar 334c2a1
unique partial
elithrar dbd9ff0
headers
elithrar c97e6f6
agents docs
elithrar 0665bdd
updates
elithrar 601d7fb
more
elithrar 55eff01
agents-sdk -> agents
elithrar 50b6bbc
changelog headers / order
elithrar 60b8bf4
fix image name
elithrar 2887519
import Badge
elithrar 283ca9b
fix
elithrar 06a2a7f
IMAGE COMPONENT
elithrar ae52ec0
fixed image
elithrar 16580de
reorder
elithrar 474e64b
update
elithrar ef2b3c5
update API ref
elithrar 5cf750a
update
elithrar 15c033e
update
elithrar e75b385
\n
elithrar 13adc2f
fix example
elithrar 31ee719
ok
elithrar 988d91a
Fix
elithrar 151b99a
example linting
elithrar 64d3f27
fix
elithrar 4f17542
fix
elithrar 3100d2c
date
elithrar 9bb3e9f
fix
elithrar 3602165
fix
elithrar bc22f39
ok
elithrar 2625119
reference
elithrar 9981116
update
elithrar 8df9a0b
fix changelog
elithrar e732381
fix typo
elithrar 1e74471
ok
elithrar 99bbebc
ok
elithrar 77c4e1a
icon
elithrar d9bdb21
ok
elithrar 367e3fe
k
elithrar 17cf352
Apply suggestions from code review
elithrar eed1cf6
agents -> agents-sdk elsewhere
elithrar File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Binary file not shown.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
136 changes: 136 additions & 0 deletions
136
src/content/changelog/agents/2025-03-18-npm-i-agents.mdx
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| 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. | ||
Oxyjun marked this conversation as resolved.
Show resolved
Hide resolved
|
||
| - [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). | ||
Oxyjun marked this conversation as resolved.
Show resolved
Hide resolved
|
||
|
|
||
| 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. | ||
Oops, something went wrong.
Oops, something went wrong.
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
Uh oh!
There was an error while loading. Please reload this page.