From 6b92affa4019bfcfbdec2fb31349e250b0bc145d Mon Sep 17 00:00:00 2001 From: Harshil Agrawal Date: Fri, 16 May 2025 15:02:01 +0200 Subject: [PATCH 1/2] add instruction on adding DO binding --- src/content/docs/agents/index.mdx | 19 ++++++++++++++++++- 1 file changed, 18 insertions(+), 1 deletion(-) diff --git a/src/content/docs/agents/index.mdx b/src/content/docs/agents/index.mdx index 752e856a1633af..4de98b36fd3110 100644 --- a/src/content/docs/agents/index.mdx +++ b/src/content/docs/agents/index.mdx @@ -22,6 +22,7 @@ import { TabItem, Tabs, TypeScriptExample, + WranglerConfig, } from "~/components"; The Agents SDK enables you to build and deploy AI-powered agents that can autonomously perform tasks, communicate with clients in real time, call AI models, persist state, schedule tasks, run asynchronous workflows, browse the web, query data from your database, support human-in-the-loop interactions, and [a lot more](/agents/api-reference/). @@ -50,7 +51,7 @@ And then define your first Agent by creating a class that extends the `Agent` cl ```ts -import { Agent, AgentNamespace } from 'agents'; +import { Agent, AgentNamespace } from "agents"; export class MyAgent extends Agent { // Define methods on the Agent: @@ -65,6 +66,21 @@ export class MyAgent extends Agent { +Lastly, add the [Durable Objects](/durable-objects/) binding to your wrangler file: + + +```toml +[[durable_objects.bindings]] +name = "MyAgent" +class_name = "MyAgent" + +[[migrations]] +tag = "v1" +new_sqlite_classes = ["MyAgent"] + +``` + + Dive into the [Agent SDK reference](/agents/api-reference/agents-api/) to learn more about how to use the Agents SDK package and defining an `Agent`. ### Why build agents on Cloudflare? @@ -110,3 +126,4 @@ Run machine learning models, powered by serverless GPUs, on Cloudflare's global Build stateful agents that guarantee executions, including automatic retries, persistent state that runs for minutes, hours, days, or weeks. +``` From 9765463ef891368488b3a2d3c0131ae20bce570a Mon Sep 17 00:00:00 2001 From: Harshil Agrawal Date: Fri, 16 May 2025 15:03:58 +0200 Subject: [PATCH 2/2] minor formatting fix --- src/content/docs/agents/index.mdx | 1 - 1 file changed, 1 deletion(-) diff --git a/src/content/docs/agents/index.mdx b/src/content/docs/agents/index.mdx index 4de98b36fd3110..a8b972051138aa 100644 --- a/src/content/docs/agents/index.mdx +++ b/src/content/docs/agents/index.mdx @@ -126,4 +126,3 @@ Run machine learning models, powered by serverless GPUs, on Cloudflare's global Build stateful agents that guarantee executions, including automatic retries, persistent state that runs for minutes, hours, days, or weeks. -```