Skip to content

Commit 32be3ca

Browse files
committed
fix config
1 parent 220e6c0 commit 32be3ca

File tree

4 files changed

+93
-8
lines changed

4 files changed

+93
-8
lines changed

src/content/docs/agents/api-reference/configuration.mdx

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -42,8 +42,11 @@ Below is a minimal `wrangler.jsonc` file that defines the configuration for an A
4242
"durable_objects": {
4343
"bindings": [
4444
{
45+
// Required:
4546
"name": "MyAgent", // How your Agent is called from your Worker
4647
"class_name": "MyAgent", // Must match the class name of the Agent in your code
48+
// Optional: set this if the Agent is defined in another Worker script
49+
"script_name": "the-other-worker"
4750
},
4851
],
4952
},

src/content/docs/agents/concepts/workflows.mdx

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -3,21 +3,22 @@ title: Workflows
33
pcx_content_type: concept
44
sidebar:
55
order: 3
6-
76
---
87

98
import { Render } from "~/components";
109

11-
### What are workflows?
10+
## What are workflows?
11+
1212
A workflow is the orchestration layer that coordinates how an agent's components work together. It defines the structured paths through which tasks are processed, tools are called, and results are managed. While agents make dynamic decisions about what to do, workflows provide the underlying framework that governs how those decisions are executed.
1313

14-
#### Understanding Workflows in Agent Systems
14+
### Understanding Workflows in Agent Systems
1515

1616
Think of a workflow like the operating procedures of a company. The company (agent) can make various decisions, but how those decisions get implemented follows established processes (workflows). For example, when you book a flight through a travel agent, they might make different decisions about which flights to recommend, but the process of actually booking the flight follows a fixed sequence of steps.
1717

1818
Let's examine a basic agent workflow:
1919

20-
#### Core Components of a Workflow
20+
### Core Components of a Workflow
21+
2122
A workflow typically consists of several key elements:
2223

2324
1. **Input Processing**
@@ -28,4 +29,3 @@ Workflows manage how external tools and services are accessed. They handle authe
2829
The workflow maintains the state of ongoing processes, tracking progress through multiple steps and ensuring consistency across operations.
2930
4. **Output Handling**
3031
Results from the agent's actions are processed according to defined rules, whether that means storing data, triggering notifications, or formatting responses.
31-

src/content/docs/agents/examples/browse-the-web.mdx

Lines changed: 7 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -21,7 +21,9 @@ interface Env {
2121
}
2222

2323
export class MyAgent extends Agent<Env> {
24-
24+
constructor(env: Env) {
25+
super(env);
26+
}
2527
}
2628
```
2729

@@ -35,7 +37,7 @@ npm install @cloudflare/puppeteer --save-dev
3537

3638
<WranglerConfig>
3739

38-
```jsonc title=
40+
```jsonc
3941
"browser": {
4042
"binding": "MYBROWSER"
4143
},
@@ -73,7 +75,9 @@ interface Env {
7375
}
7476

7577
export class MyAgent extends Agent<Env> {
76-
78+
constructor(env: Env) {
79+
super(env);
80+
}
7781
}
7882
```
7983

src/content/docs/agents/examples/run-workflows.mdx

Lines changed: 78 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -9,3 +9,81 @@ sidebar:
99
import { MetaInfo, Render, Type, TypeScriptExample, WranglerConfig } from "~/components";
1010

1111
TODO - show how to invoke a Workflow from an Agent
12+
13+
Agents can trigger asynchronous [Workflows](/workflows/), allowing your Agent to run complex, multi-step tasks in the background. This can include post-processing files that a user has uploaded, updating the embeddings in a [vector database](/vectorize/), and/or managing long-running user-lifecycle email or SMS notification workflows.
14+
15+
Because an Agent is just like a Worker script, it can create Workflows defined in the same project (script) as the Agent _or_ in a different project.
16+
17+
## Trigger a Workflow
18+
19+
<TypeScriptExample>
20+
21+
```ts
22+
interface Env {
23+
BROWSER: Fetcher;
24+
}
25+
26+
export class MyAgent extends Agent<Env> {
27+
28+
}
29+
```
30+
31+
</TypeScriptExample>
32+
33+
<WranglerConfig>
34+
35+
```jsonc
36+
{
37+
"$schema": "node_modules/wrangler/config-schema.json",
38+
"name": "agents-example",
39+
"main": "src/index.ts",
40+
"compatibility_date": "2025-02-23",
41+
"compatibility_flags": ["nodejs_compat"],
42+
// Create a binding between your Agent and your Workflow
43+
"workflows": [{ "name": "EMAIL_WORKFLOW", "class_name": "EmailWorkflow" }],
44+
"durable_objects": {
45+
"bindings": [
46+
{
47+
"name": "MyAgent",
48+
"class_name": "MyAgent",
49+
},
50+
],
51+
},
52+
"migrations": [
53+
{
54+
"tag": "v1",
55+
// Mandatory for the Agent to store state
56+
"new_sqlite_classes": ["MyAgent"],
57+
},
58+
],
59+
"observability": {
60+
"enabled": true,
61+
},
62+
}
63+
```
64+
65+
</WranglerConfig>
66+
67+
## Trigger a Workflow from another project
68+
69+
You can also call a Workflow that is defined in a different Workers script from your Agent by setting the `script_name` property in the `workflows` binding of your Agent:
70+
71+
<WranglerConfig>
72+
73+
```jsonc
74+
{
75+
// ...
76+
"workflows": [
77+
{ "name": "EMAIL_WORKFLOW",
78+
"class_name": "EmailWorkflow",
79+
// Set script_name to the name of the Worker that contains the EmailWorkflow definition
80+
"script_name": "email-workflow-prod"
81+
},
82+
],
83+
// ...
84+
}
85+
```
86+
87+
</WranglerConfig>
88+
89+
Refer to the [cross-script calls](/workflows/build/workers-api/#cross-script-calls) section of the Workflows documentation for more examples.

0 commit comments

Comments
 (0)