Skip to content

Commit 3757f30

Browse files
committed
commit
1 parent f99009d commit 3757f30

File tree

15 files changed

+57
-29
lines changed

15 files changed

+57
-29
lines changed

public/_redirects

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -98,6 +98,13 @@
9898

9999
# agents
100100
/agents/build/prompts/ /workers/get-started/prompting/ 301
101+
/agents/examples/browse-the-web/ /agents/api-reference/browse-the-web/ 301
102+
/agents/examples/manage-and-sync-state/ /agents/api-reference/manage-and-sync-state/ 301
103+
/agents/examples/rag/ /agents/api-reference/rag/ 301
104+
/agents/examples/run-workflows/ /agents/api-reference/run-workflows/ 301
105+
/agents/examples/schedule-tasks/ /agents/api-reference/schedule-tasks/ 301
106+
/agents/examples/using-ai-models/ /agents/api-reference/using-ai-models/ 301
107+
/agents/examples/websockets/ /agents/api-reference/websockets/ 301
101108

102109
# ai
103110
/ai/ /use-cases/ai/ 301
File renamed without changes.

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

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -2,11 +2,11 @@
22
title: API Reference
33
pcx_content_type: navigation
44
sidebar:
5-
order: 5
6-
group:
7-
hideIndex: true
5+
order: 3
86
---
97

108
import { DirectoryListing } from "~/components"
119

10+
Learn more about what Agents can do, the `Agent` class, and the APIs that Agents expose:
11+
1212
<DirectoryListing />

src/content/docs/agents/examples/manage-and-sync-state.mdx renamed to src/content/docs/agents/api-reference/manage-and-sync-state.mdx

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -198,7 +198,7 @@ The SQL API exposed to an Agent is similar to the one [within Durable Objects](/
198198

199199
### Use Agent state as model context
200200

201-
You can combine the state and SQL APIs in your Agent with its ability to [call AI models](/agents/examples/using-ai-models/) to include historical context within your prompts to a model. Modern Large Language Models (LLMs) often have very large context windows (up to millions of tokens), which allows you to pull relevant context into your prompt directly.
201+
You can combine the state and SQL APIs in your Agent with its ability to [call AI models](/agents/api-reference/using-ai-models/) to include historical context within your prompts to a model. Modern Large Language Models (LLMs) often have very large context windows (up to millions of tokens), which allows you to pull relevant context into your prompt directly.
202202

203203
For example, you can use an Agent's built-in SQL database to pull history, query a model with it, and append to that history ahead of the next call to the model:
204204

src/content/docs/agents/examples/rag.mdx renamed to src/content/docs/agents/api-reference/rag.mdx

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -8,9 +8,9 @@ sidebar:
88

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

11-
Agents can use Retrieval Augmented Generation (RAG) to retrieve relevant information and use it augment [calls to AI models](/agents/examples/using-ai-models/). Store a user's chat history to use as context for future conversations, summarize documents to bootstrap an Agent's knowledge base, and/or use data from your Agent's [web browsing](/agents/examples/browse-the-web/) tasks to enhance your Agent's capabilities.
11+
Agents can use Retrieval Augmented Generation (RAG) to retrieve relevant information and use it augment [calls to AI models](/agents/api-reference/using-ai-models/). Store a user's chat history to use as context for future conversations, summarize documents to bootstrap an Agent's knowledge base, and/or use data from your Agent's [web browsing](/agents/api-reference/browse-the-web/) tasks to enhance your Agent's capabilities.
1212

13-
You can use the Agent's own [SQL database](/agents/examples/manage-and-sync-state) as the source of truth for your data and store embeddings in [Vectorize](/vectorize/) (or any other vector-enabled database) to allow your Agent to retrieve relevant information.
13+
You can use the Agent's own [SQL database](/agents/api-reference/manage-and-sync-state) as the source of truth for your data and store embeddings in [Vectorize](/vectorize/) (or any other vector-enabled database) to allow your Agent to retrieve relevant information.
1414

1515
### Vector search
1616

File renamed without changes.
File renamed without changes.

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

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -100,7 +100,7 @@ export default MyAgent;
100100

101101
:::note
102102

103-
To learn more about how to manage state within an Agent, refer to the documentation on [managing and syncing state](/agents/examples/manage-and-sync-state/).
103+
To learn more about how to manage state within an Agent, refer to the documentation on [managing and syncing state](/agents/api-reference/manage-and-sync-state/).
104104

105105
:::
106106

src/content/docs/agents/examples/using-ai-models.mdx renamed to src/content/docs/agents/api-reference/using-ai-models.mdx

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -16,15 +16,15 @@ A user can disconnect during a long-running response from a modern reasoning mod
1616

1717
## Calling AI Models
1818

19-
You can call models from any method within an Agent, including from HTTP requests using the [`onRequest`](/agents/api-reference/sdk/) handler, when a [scheduled task](/agents/examples/schedule-tasks/) runs, when handling a WebSocket message in the [`onMessage`](/agents/examples/websockets/) handler, or from any of your own methods.
19+
You can call models from any method within an Agent, including from HTTP requests using the [`onRequest`](/agents/api-reference/sdk/) handler, when a [scheduled task](/agents/api-reference/schedule-tasks/) runs, when handling a WebSocket message in the [`onMessage`](/agents/api-reference/websockets/) handler, or from any of your own methods.
2020

2121
Importantly, Agents can call AI models on their own — autonomously — and can handle long-running responses that can take minutes (or longer) to respond in full.
2222

2323
### Long-running model requests {/*long-running-model-requests*/}
2424

2525
Modern [reasoning models](https://platform.openai.com/docs/guides/reasoning) or "thinking" model can take some time to both generate a response _and_ stream the response back to the client.
2626

27-
Instead of buffering the entire response, or risking the client disconecting, you can stream the response back to the client by using the [WebSocket API](/agents/examples/websockets/).
27+
Instead of buffering the entire response, or risking the client disconecting, you can stream the response back to the client by using the [WebSocket API](/agents/api-reference/websockets/).
2828

2929
<TypeScriptExample filename="src/index.ts">
3030

@@ -75,7 +75,7 @@ export class MyAgent extends Agent<Env> {
7575

7676
</TypeScriptExample>
7777

78-
You can also persist AI model responses back to [Agent's internal state](/agents/examples/manage-and-sync-state/) by using the `this.setState` method. For example, if you run a [scheduled task](/agents/examples/schedule-tasks/), you can store the output of the task and read it later. Or, if a user disconnects, read the message history back and send it to the user when they reconnect.
78+
You can also persist AI model responses back to [Agent's internal state](/agents/api-reference/manage-and-sync-state/) by using the `this.setState` method. For example, if you run a [scheduled task](/agents/api-reference/schedule-tasks/), you can store the output of the task and read it later. Or, if a user disconnects, read the message history back and send it to the user when they reconnect.
7979

8080
### Workers AI
8181

@@ -214,7 +214,7 @@ export class MyAgent extends Agent<Env> {
214214

215215
Agents can call models across any service, including those that support the OpenAI API. For example, you can use the OpenAI SDK to use one of [Google's Gemini models](https://ai.google.dev/gemini-api/docs/openai#node.js) directly from your Agent.
216216

217-
Agents can stream responses back over HTTP using Server Sent Events (SSE) from within an `onRequest` handler, or by using the native [WebSockets](/agents/examples/websockets/) API in your Agent to responses back to a client, which is especially useful for larger models that can take over 30+ seconds to reply.
217+
Agents can stream responses back over HTTP using Server Sent Events (SSE) from within an `onRequest` handler, or by using the native [WebSockets](/agents/api-reference/websockets/) API in your Agent to responses back to a client, which is especially useful for larger models that can take over 30+ seconds to reply.
218218

219219
<TypeScriptExample filename="src/index.ts">
220220

src/content/docs/agents/examples/websockets.mdx renamed to src/content/docs/agents/api-reference/websockets.mdx

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -120,7 +120,7 @@ function AgentInterface() {
120120
```
121121
</TypeScriptExample>
122122

123-
The `useAgent` hook automatically handles the lifecycle of the connection, ensuring that it is properly initialized and cleaned up when the component mounts and unmounts. You can also [combine `useAgent` with `useState`](/agents/examples/manage-and-sync-state/) to automatically synchronize state across all clients connected to your Agent.
123+
The `useAgent` hook automatically handles the lifecycle of the connection, ensuring that it is properly initialized and cleaned up when the component mounts and unmounts. You can also [combine `useAgent` with `useState`](/agents/api-reference/manage-and-sync-state/) to automatically synchronize state across all clients connected to your Agent.
124124

125125
## Handling WebSocket events
126126

0 commit comments

Comments
 (0)