Skip to content

Commit 9635010

Browse files
committed
fix closing tag
1 parent 60d0f2f commit 9635010

File tree

2 files changed

+28
-1
lines changed

2 files changed

+28
-1
lines changed

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

Lines changed: 24 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -8,4 +8,27 @@ sidebar:
88

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

11-
Each Agent is a JavaScript class that extends the `Agent` class from the `@cloudflare/workers-agents` package. Agents are designed to run in a separate thread from the main Worker, allowing them to perform long-running tasks without blocking the main thread.
11+
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.
12+
13+
<TypeScriptExample>
14+
15+
```ts
16+
import { Agent } from "@cloudflare/agents";
17+
18+
class MyAgent extends Agent {
19+
// Define methods on the Agent
20+
}
21+
22+
export default MyAgent;
23+
```
24+
25+
</TypeScriptExample>
26+
27+
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.
28+
29+
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.
30+
31+
## Agent
32+
33+
TODO - agent class
34+

src/content/docs/agents/examples/schedule-tasks.mdx

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -15,6 +15,8 @@ Scheduled tasks can do anything a request or message from a user can: make reque
1515

1616
You can call `this.schedule` within any method on an Agent, and schedule tens-of-thousands of tasks per individual Agent:
1717

18+
<TypeScriptExample>
19+
1820
```ts
1921
import { Agent } from "@cloudflare/agents"
2022

@@ -60,6 +62,8 @@ this.cancelSchedule(task.id);
6062

6163
Calling `await this.schedule` returns a `Schedule`, which includes the task's randomly generated `id`. You can use this `id` to retrieve or cancel the task in the future.
6264

65+
Tasks that set a callback for a method that does not exist will fail silently.
66+
6367
:::note[Maximum scheduled tasks]
6468

6569
Each task is mapped to a row in the Agent's underlying [SQLite database](/sqlite-in-durable-objects/), which means that each task can be up to 2MB in size. The maximum number of tasks must be `(task_size * tasks) + all_other_state < maximum_database_size` (currently 1GB per Agent).

0 commit comments

Comments
 (0)