fcakyon/claude-codex-settings / plugins/cloudflare-skills/skills/agents-sdk
agents-sdk
VerifiedBuild, debug, or review Cloudflare Agents SDK applications using the agents package.
| File | Kind | Size |
|---|---|---|
| SKILL.md | skill md | 12.0 KB |
| references/browse-the-web.md | markdown | 1.6 KB |
| references/callable.md | markdown | 2.1 KB |
| references/client-sdk.md | markdown | 1.2 KB |
| references/codemode.md | markdown | 2.8 KB |
| references/configuration.md | markdown | 1.8 KB |
| references/durable-execution.md | markdown | 1.7 KB |
| references/email.md | markdown | 3.5 KB |
| references/human-in-the-loop.md | markdown | 929 B |
| references/mcp.md | markdown | 1.3 KB |
| references/observability.md | markdown | 1.3 KB |
| references/queue-retries.md | markdown | 1.4 KB |
| references/routing.md | markdown | 1.8 KB |
| references/server-driven-messages.md | markdown | 868 B |
| references/skill-feedback.md | markdown | 2.7 KB |
| references/state-scheduling.md | markdown | 1.5 KB |
| references/streaming-chat.md | markdown | 1.4 KB |
| references/think.md | markdown | 2.9 KB |
| references/voice.md | markdown | 1.9 KB |
| references/webhooks-push.md | markdown | 2.4 KB |
| references/workflows.md | markdown | 2.3 KB |
references/think.md
View on GitHub# Think (Experimental)
Fetch https://developers.cloudflare.com/agents/harnesses/think/index.md for complete documentation.
`@cloudflare/think` — a higher-level chat agent class that handles the `streamText` loop, tool execution, and message persistence for you. You provide `getModel()` and `getSystemPrompt()`; Think handles the rest.
```bash
npm install @cloudflare/think
```
## Minimal Agent
```typescript
import { Think } from "@cloudflare/think";
import { createWorkersAI } from "workers-ai-provider";
import { routeAgentRequest } from "agents";
export class MyAgent extends Think<Env> {
getModel() {
return createWorkersAI({ binding: this.env.AI })("@cf/meta/llama-4-scout-17b-16e-instruct");
}
getSystemPrompt() {
return "You are a helpful assistant.";
}
}
export default {
fetch: (req, env) => routeAgentRequest(req, env)
};
```
## Wrangler Config
```jsonc
{
"compatibility_flags": ["nodejs_compat", "experimental"],
"durable_objects": {
"bindings": [{ "name": "MyAgent", "class_name": "MyAgent" }]
},
"migrations": [{ "tag": "v1", "new_sqlite_classes": ["MyAgent"] }],
"ai": { "binding": "AI" }
}
```
**Note:** Think requires the `experimental` compatibility flag.
## Custom Tools
```typescript
import { tool } from "ai";
import { z } from "zod";
export class MyAgent extends Think<Env> {
getTools() {
return {
getWeather: tool({
description: "Get weather",
parameters: z.object({ city: z.string() }),
execute: async ({ city }) => `72°F in ${city}`
})
};
}
}
```
## Lifecycle Hooks
| Hook | When | Use for |
|------|------|---------|
| `configureSession()` | Agent starts | Set up memory, context providers |
| `beforeTurn(ctx)` | Before each LLM call | Per-turn model/tools/system prompt; return `TurnConfig` |
| `onChunk(chunk)` | Each streaming chunk | Progress tracking |
| `onChatResponse(result)` | After LLM turn completes | Chaining, follow-up `saveMessages` |
| `onChatError(error)` | On LLM error | Error handling |
```typescript
async beforeTurn(ctx: TurnContext): Promise<TurnConfig> {
if (ctx.continuation) {
return { model: cheaperModel };
}
return {};
}
```
## Sub-Agents
```typescript
const child = this.subAgent(SpecialistAgent, "specialist-1");
await child.chat("Analyze this data...", (chunk) => {
// stream callback
});
```
## Client
Same React hooks as `AIChatAgent`:
```tsx
const agent = useAgent({ agent: "MyAgent", name: "session-1" });
const { messages, input, handleInputChange, handleSubmit } = useAgentChat({ agent });
```
## Think vs AIChatAgent
| | Think | AIChatAgent |
|-|-------|-------------|
| `streamText` loop | Built-in | You write it |
| Tool execution | Automatic | You wire it |
| Customization | Override hooks | Full control in `onChatMessage` |
| Built-in tools | Workspace, execute, browser | None |
| Compatibility flag | Requires `experimental` | Standard |
Related skills
| Skill | Stars | Updated | Works with | Status | Install |
|---|---|---|---|---|---|
| finishing-a-development-branchobra/superpowersUse when implementation is complete, all tests pass, and you need to decide how to integrate the work | Stars: 322k | Updated | Claude CodeCodex | Verified | Install |
| systematic-debuggingobra/superpowersUse when encountering any bug, test failure, or unexpected behavior, before proposing fixes | Stars: 322k | Updated | Claude CodeCodex | Verified | Install |
| test-driven-developmentobra/superpowersUse when implementing any feature or bugfix, before writing implementation code | Stars: 322k | Updated | Claude CodeCodex | Verified | Install |
| skill-creatoranthropics/skillsCreate new skills, modify and improve existing skills, and measure skill performance. Use when users want to create a skill from scratch, edit, or optimize an existing skill, run evals to test a skill, benchmark skill performance with variance analysis, or optimize a skill's description for better triggering accuracy. | Stars: 197k | Updated | Claude CodeCodex | Verified | Install |