Skip to content
5 changes: 3 additions & 2 deletions src/content/docs/agents/api-reference/agents-api.mdx
Original file line number Diff line number Diff line change
Expand Up @@ -87,6 +87,7 @@ flowchart TD
| **Workflows** | `runWorkflow()`, `waitForApproval()` | [Run Workflows](/agents/api-reference/run-workflows/) |
| **MCP Client** | `addMcpServer()`, `removeMcpServer()`, `getMcpServers()` | [MCP Client API](/agents/api-reference/mcp-client-api/ ) |
| **AI Models** | Workers AI, OpenAI, Anthropic bindings | [Using AI models](/agents/api-reference/using-ai-models/) |
| **Protocol messages** | `shouldSendProtocolMessages()`, `isConnectionProtocolEnabled()` | [Protocol messages](/agents/api-reference/protocol-messages/) |
| **Context** | `getCurrentAgent()` | [getCurrentAgent()](/agents/api-reference/get-current-agent/) |
| **Observability** | `observability.emit()` | [Observability](/agents/api-reference/observability/) |

Expand Down Expand Up @@ -143,7 +144,7 @@ For AI chat applications, extend `AIChatAgent` instead of `Agent`:
```ts
import { AIChatAgent } from "agents/ai-chat-agent";

class ChatAgent extends AIChatAgent<Env> {
class ChatAgent extends AIChatAgent {
async onChatMessage(onFinish) {
// this.messages contains the conversation history
// Return a streaming response
Expand Down Expand Up @@ -179,7 +180,7 @@ export default {
new Response("Not found", { status: 404 })
);
},
};
} satisfies ExportedHandler<Env>;
```

Refer to [Routing](/agents/api-reference/routing/) for custom paths, CORS, and instance naming patterns.
Expand Down
4 changes: 2 additions & 2 deletions src/content/docs/agents/api-reference/browse-the-web.mdx
Original file line number Diff line number Diff line change
Expand Up @@ -29,7 +29,7 @@ interface Env {
BROWSER: Fetcher;
}

export class MyAgent extends Agent<Env> {
export class MyAgent extends Agent {
async browse(browserInstance: Fetcher, urls: string[]) {
let responses = [];
for (const url of urls) {
Expand Down Expand Up @@ -116,7 +116,7 @@ interface Env {
BROWSERBASE_API_KEY: string;
}

export class MyAgent extends Agent<Env> {
export class MyAgent extends Agent {
constructor(env: Env) {
super(env);
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -543,7 +543,7 @@

return Response.json(result);
},
};
} satisfies ExportedHandler<Env>;
```

</TypeScriptExample>
Expand Down Expand Up @@ -710,12 +710,12 @@

### `SyntaxError: Invalid or unexpected token`

If your dev server fails with `SyntaxError: Invalid or unexpected token` when using `@callable()`, set `"target": "ES2021"` in your `tsconfig.json`. This ensures that Vite's esbuild transpiler downlevels TC39 decorators instead of passing them through as native syntax.

Check warning on line 713 in src/content/docs/agents/api-reference/callable-methods.mdx

View workflow job for this annotation

GitHub Actions / Semgrep

semgrep.style-guide-potential-date-year

Potential year found. Documentation should strive to represent universal truth, not something time-bound. (add [skip style guide checks] to commit message to skip)

```json
{
"compilerOptions": {
"target": "ES2021"

Check warning on line 718 in src/content/docs/agents/api-reference/callable-methods.mdx

View workflow job for this annotation

GitHub Actions / Semgrep

semgrep.style-guide-potential-date-year

Potential year found. Documentation should strive to represent universal truth, not something time-bound. (add [skip style guide checks] to commit message to skip)
}
}
```
Expand Down
Loading
Loading