Skip to content
Merged
Show file tree
Hide file tree
Changes from 12 commits
Commits
Show all changes
43 commits
Select commit Hold shift + click to select a range
2062d62
wip
elithrar Feb 23, 2025
36db5d8
Merge branch 'production' into agents-1.0
elithrar Feb 23, 2025
63eaf79
WIP - fixing typos (#20203)
rita3ko Feb 23, 2025
eee0530
onward
elithrar Feb 23, 2025
84eef5f
add tools and human loop images
rita3ko Feb 23, 2025
7416e63
limits, schedules
elithrar Feb 23, 2025
4b6b372
fix config title
elithrar Feb 23, 2025
220e6c0
fix
elithrar Feb 23, 2025
32be3ca
fix config
elithrar Feb 23, 2025
60d0f2f
websockets
elithrar Feb 24, 2025
9635010
fix closing tag
elithrar Feb 24, 2025
b67a3c6
caution
elithrar Feb 24, 2025
3363272
Apply suggestions from code review
Oxyjun Feb 24, 2025
c43f550
state state state
elithrar Feb 24, 2025
7267caf
sql API yo yo yo
elithrar Feb 24, 2025
f9f6c4e
agents: Apply suggestions from code review
elithrar Feb 24, 2025
99cbca4
fix sidebar ordering
elithrar Feb 24, 2025
afc175d
fix sidebar
elithrar Feb 24, 2025
51c6167
state
elithrar Feb 24, 2025
4b9864a
update overview
rita3ko Feb 24, 2025
68928f6
ai models
elithrar Feb 24, 2025
731d6bb
guides, ai models
elithrar Feb 24, 2025
f7c6141
Merge branch 'production' into agents-1.0
elithrar Feb 24, 2025
34667bc
d1
elithrar Feb 24, 2025
2747050
useAgent
elithrar Feb 24, 2025
e8f3978
fix 'er up
elithrar Feb 24, 2025
1036423
browse, fix syntax
elithrar Feb 24, 2025
fbe1d28
testing
elithrar Feb 24, 2025
4c835c9
fix
elithrar Feb 24, 2025
ba11185
fix
elithrar Feb 25, 2025
c90c75c
workflows
elithrar Feb 25, 2025
ae05a2e
@cloudflare/agents -> agents-sdk
elithrar Feb 25, 2025
6aa1260
fix links
elithrar Feb 25, 2025
2001aa1
fix ordering + testing title
elithrar Feb 25, 2025
196a5ba
update index
rita3ko Feb 25, 2025
23c5fee
update index
rita3ko Feb 25, 2025
4fc9c2f
headers
elithrar Feb 25, 2025
71b07d9
remove updated
elithrar Feb 25, 2025
73f6421
index.mdx
elithrar Feb 25, 2025
4b22f32
callback
elithrar Feb 25, 2025
3740f53
rag
elithrar Feb 25, 2025
f09fa7e
fin
elithrar Feb 25, 2025
2d777dd
fix links
elithrar Feb 25, 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
3 changes: 3 additions & 0 deletions public/_redirects
Original file line number Diff line number Diff line change
Expand Up @@ -96,6 +96,9 @@
/access/ssh/short-live-cert-server/ /cloudflare-one/connections/connect-networks/use-cases/ssh/ssh-infrastructure-access/ 301
/access/ssh/ssh-guide/ /cloudflare-one/connections/connect-networks/use-cases/ssh/ 301

# agents
/agents/build/prompts/ /agents/building-with-ai/prompting/ 301

# ai
/ai/ /use-cases/ai/ 301

Expand Down
7,363 changes: 7,363 additions & 0 deletions src/assets/images/agents/agent-workflow.svg
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
7,356 changes: 7,356 additions & 0 deletions src/assets/images/agents/co-pilot.svg
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
7,367 changes: 7,367 additions & 0 deletions src/assets/images/agents/human-in-the-loop.svg
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
7,348 changes: 7,348 additions & 0 deletions src/assets/images/agents/workflow-automation.svg
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
72 changes: 72 additions & 0 deletions src/content/docs/agents/api-reference/configuration.mdx
Original file line number Diff line number Diff line change
@@ -0,0 +1,72 @@
---
title: Configuration
pcx_content_type: concept
sidebar:
order: 3
---

import { MetaInfo, Render, Type, WranglerConfig } from "~/components";

An Agent is configured like any other Cloudflare Workers project, and uses [a wrangler configuration](/workers/wrangler/configuration/) file to define where your code is and what services (bindings) it will use.

The typical file structure for an Agent project created from `npm create cloudflare@latest -- --template cloudflare/agents` follows:

```sh
.
|-- package-lock.json
|-- package.json
|-- public
| `-- index.html
|-- src
| `-- index.ts // your Agent definition
|-- test
| |-- index.spec.ts // your tests
| `-- tsconfig.json
|-- tsconfig.json
|-- vitest.config.mts
|-- worker-configuration.d.ts
`-- wrangler.jsonc // your Workers & Agent configuration
```

Below is a minimal `wrangler.jsonc` file that defines the configuration for an Agent, including the entry point, `durable_object` namespace, and code `migrations`:

<WranglerConfig>

```jsonc
{
"$schema": "node_modules/wrangler/config-schema.json",
"name": "agents-example",
"main": "src/index.ts",
"compatibility_date": "2025-02-23",
"compatibility_flags": ["nodejs_compat"],
"durable_objects": {
"bindings": [
{
// Required:
"name": "MyAgent", // How your Agent is called from your Worker
"class_name": "MyAgent", // Must match the class name of the Agent in your code
// Optional: set this if the Agent is defined in another Worker script
"script_name": "the-other-worker"
},
],
},
"migrations": [
{
"tag": "v1",
// Mandatory for the Agent to store state
"new_sqlite_classes": ["MyAgent"],
},
],
"observability": {
"enabled": true,
},
}
```

</WranglerConfig>

The configuration includes:

- A `main` field that points to the entry point of your Agent, which is typically a TypeScript (or JavaScript) file.
- A `durable_objects` field that defines the [Durable Object namespace](/durable-objects/reference/glossary/) that your Agents will run within.
- A `migrations` field that defines the code migrations that your Agent will use. This field is mandatory and must contain at least one migration. The `new_sqlite_classes` field is mandatory for the Agent to store state.
13 changes: 13 additions & 0 deletions src/content/docs/agents/api-reference/index.mdx
Original file line number Diff line number Diff line change
@@ -0,0 +1,13 @@
---
title: Agents API Reference
pcx_content_type: navigation
sidebar:
order: 3
group:
hideIndex: true

---

import { DirectoryListing } from "~/components"

<DirectoryListing />
34 changes: 34 additions & 0 deletions src/content/docs/agents/api-reference/sdk.mdx
Original file line number Diff line number Diff line change
@@ -0,0 +1,34 @@
---
title: Agents SDK
pcx_content_type: concept
sidebar:
order: 2

---

import { MetaInfo, Render, Type, WranglerConfig } from "~/components";

At its most basic, an Agent is a JavaScript class that extends the `Agent` class from the `@cloudflare/agents` 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.

<TypeScriptExample>

```ts
import { Agent } from "@cloudflare/agents";

class MyAgent extends Agent {
// Define methods on the Agent
}

export default MyAgent;
```

</TypeScriptExample>

An Agent can have many (millions of) instances: each instance is a separate micro-server that runs independently of the others. This allows Agents to scale horizontally: an Agent can be associated with a single user, or many thousands of users, depending on the agent you're building.

Instances of an Agent are addressed by a unique identifier: that identifier (ID) can be the user ID, an email address, GitHub username, a flight ticket number, an invoice ID, or any other identifier that helps to uniquely identify the instance and for whom it is acting on behalf of.

## Agent

TODO - agent class

13 changes: 13 additions & 0 deletions src/content/docs/agents/building-with-ai/index.mdx
Original file line number Diff line number Diff line change
@@ -0,0 +1,13 @@
---
title: Building with AI
pcx_content_type: navigation
sidebar:
order: 5
group:
hideIndex: true

---

import { DirectoryListing } from "~/components"

<DirectoryListing />
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@ pcx_content_type: navigation
title: llms.txt
external_link: /llms.txt
sidebar:
order: 20
order: 102
head: []
description: Provide context to your AI models & tools when building on Cloudflare.
---
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@
title: Prompting AI Models
pcx_content_type: concept
sidebar:
order: 2
order: 101
---

import { Tabs, TabItem, GlossaryTooltip, Type, Badge, TypeScriptExample } from "~/components";
Expand Down
10 changes: 0 additions & 10 deletions src/content/docs/agents/capabilities/control-web-browsers.mdx

This file was deleted.

114 changes: 0 additions & 114 deletions src/content/docs/agents/capabilities/mcp-server.mdx

This file was deleted.

9 changes: 0 additions & 9 deletions src/content/docs/agents/capabilities/run-models.mdx

This file was deleted.

11 changes: 0 additions & 11 deletions src/content/docs/agents/capabilities/send-email.mdx

This file was deleted.

9 changes: 0 additions & 9 deletions src/content/docs/agents/capabilities/webrtc-realtime.mdx

This file was deleted.

31 changes: 31 additions & 0 deletions src/content/docs/agents/concepts/calling-llms.mdx
Original file line number Diff line number Diff line change
@@ -0,0 +1,31 @@
---
title: Calling LLMs
pcx_content_type: concept
sidebar:
order: 6

---

import { Render } from "~/components";

### Understanding LLM Providers and Model Types

Different LLM providers offer models optimized for specific types of tasks. When building AI systems, choosing the right model is crucial for both performance and cost efficiency.

#### Reasoning Models
Models like OpenAI's o1, Anthropic's Claude, and DeepSeek's R1 are particularly well-suited for complex reasoning tasks. These models excel at:
- Breaking down problems into steps
- Following complex instructions
- Maintaining context across long conversations
- Generating code and technical content

For example, when implementing a travel booking system, you might use a reasoning model to analyze travel requirements and generate appropriate booking strategies.

#### Instruction Models
Models like GPT-4 and Claude Instant are optimized for following straightforward instructions efficiently. They work well for:
- Content generation
- Simple classification tasks
- Basic question answering
- Text transformation

These models are often more cost-effective for straightforward tasks that don't require complex reasoning.
Loading
Loading