Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
7 changes: 7 additions & 0 deletions .changeset/assistant-alias.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,7 @@
---
"agents": minor
---

Add `agents/assistant`, an additive entrypoint that exports `Assistant` as an
alias for `@cloudflare/think`'s `Think` base class while preserving the existing
`Think` export.
2 changes: 1 addition & 1 deletion README.md
Original file line number Diff line number Diff line change
Expand Up @@ -129,7 +129,7 @@ The agent is a Durable Object, so it needs a binding and a SQLite migration in `
| ------------------------------------------------------- | ------------------------------------------------------------------------------------------------- |
| [`agents`](packages/agents) | Core SDK — `Agent` class, routing, state, scheduling, MCP, email, workflows, x402, browser agents |
| [`@cloudflare/ai-chat`](packages/ai-chat) | Higher-level AI chat — persistent messages, resumable streaming, tool execution |
| [`@cloudflare/think`](packages/think) | Opinionated chat agent base — agentic loop, stream resumption, client tools, workspace tools |
| [`@cloudflare/think`](packages/think) | Opinionated chat agent base, also available as `Assistant` from `agents/assistant` |
| [`@cloudflare/codemode`](packages/codemode) | LLMs write executable code that calls your tools, instead of one tool call at a time |
| [`@cloudflare/shell`](packages/shell) | Sandboxed JS execution + virtual filesystem (`Workspace`) for agents |
| [`@cloudflare/voice`](packages/voice) | Voice pipeline — STT, TTS, VAD, streaming, SFU utilities |
Expand Down
1 change: 1 addition & 0 deletions packages/agents/AGENTS.md
Original file line number Diff line number Diff line change
Expand Up @@ -11,6 +11,7 @@ Each export maps to a public entry point that users `import` from. These are the
| `agents` | `src/index.ts` | Agent base class, routing, connections, RPC, state, scheduling, SQL |
| `agents/client` | `src/client.ts` | Browser/Node WebSocket client (`AgentClient`) via partysocket |
| `agents/react` | `src/react.tsx` | `useAgent` React hook, state sync, RPC from components |
| `agents/assistant` | `src/assistant.ts` | `Assistant` alias for the opinionated `@cloudflare/think` chat/session agent |
| `agents/chat` | `src/chat/index.ts` | Shared chat primitives used by `@cloudflare/ai-chat` and `@cloudflare/think` |
| `agents/mcp` | `src/mcp/index.ts` | `McpAgent` base class for building MCP servers |
| `agents/mcp/client` | `src/mcp/client.ts` | MCP client manager (connect to remote MCP servers from an Agent) |
Expand Down
31 changes: 25 additions & 6 deletions packages/agents/README.md
Original file line number Diff line number Diff line change
Expand Up @@ -234,23 +234,23 @@ segments, subject to the platform's current facet nesting limits.

### Agent Tools

Run chat-capable sub-agents as tools from a parent chat agent. Think agents and
`AIChatAgent` subclasses are supported. The child keeps its own messages, tools,
SQLite storage, and resumable stream, while the parent broadcasts
Run chat-capable sub-agents as tools from a parent chat agent. Assistant/Think
agents and `AIChatAgent` subclasses are supported. The child keeps its own
messages, tools, SQLite storage, and resumable stream, while the parent broadcasts
`agent-tool-event` frames so the UI can render the child timeline inline.

```typescript
import { Think } from "@cloudflare/think";
import { Assistant } from "agents/assistant";
import { agentTool } from "agents/agent-tools";
import { z } from "zod";

export class Researcher extends Think<Env> {
export class Researcher extends Assistant<Env> {
getSystemPrompt() {
return "Research the requested topic and end with a concise summary.";
}
}

export class Assistant extends Think<Env> {
export class Support extends Assistant<Env> {
getTools() {
return {
research: agentTool(Researcher, {
Expand Down Expand Up @@ -390,6 +390,25 @@ See [Workflows](../../docs/workflows.md) and [Human in the Loop](../../docs/huma

For AI-powered chat experiences with persistent conversations, streaming responses, and tool support, see [`@cloudflare/ai-chat`](../ai-chat/README.md).

For the opinionated assistant framework with the full agentic loop, Session
storage, workspace tools, sub-agent RPC, and durable chat recovery, import
`Assistant` from `agents/assistant`. This is an additive alias for
`@cloudflare/think`'s `Think` base class, so existing `@cloudflare/think`
imports continue to work.

```typescript
import { Assistant } from "agents/assistant";
import { createWorkersAI } from "workers-ai-provider";

export class Support extends Assistant<Env> {
getModel() {
return createWorkersAI({ binding: this.env.AI })(
"@cf/moonshotai/kimi-k2.6"
);
}
}
```

```typescript
import { AIChatAgent } from "@cloudflare/ai-chat";

Expand Down
12 changes: 11 additions & 1 deletion packages/agents/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -56,6 +56,7 @@
},
"peerDependencies": {
"@cloudflare/ai-chat": ">=0.8.0 <1.0.0",
"@cloudflare/think": ">=0.8.6 <1.0.0",
"@tanstack/ai": ">=0.10.2 <1.0.0",
"@x402/core": "^2.0.0",
"@x402/evm": "^2.0.0",
Expand All @@ -69,6 +70,9 @@
"@cloudflare/ai-chat": {
"optional": true
},
"@cloudflare/think": {
"optional": true
},
"@tanstack/ai": {
"optional": true
},
Expand Down Expand Up @@ -107,6 +111,11 @@
"import": "./dist/agent-tools.js",
"require": "./dist/agent-tools.js"
},
"./assistant": {
"types": "./dist/assistant.d.ts",
"import": "./dist/assistant.js",
"require": "./dist/assistant.js"
},
"./codemode/ai": {
"types": "./dist/codemode/ai.d.ts",
"import": "./dist/codemode/ai.js",
Expand Down Expand Up @@ -245,7 +254,8 @@
],
"nx": {
"implicitDependencies": [
"!@cloudflare/ai-chat"
"!@cloudflare/ai-chat",
"!@cloudflare/think"
]
},
"scripts": {
Expand Down
2 changes: 2 additions & 0 deletions packages/agents/src/assistant.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,2 @@
export * from "@cloudflare/think";
export { Think as Assistant } from "@cloudflare/think";
12 changes: 12 additions & 0 deletions packages/agents/src/tests-d/assistant-alias.test-d.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,12 @@
import { Assistant, Think } from "../assistant";

const assistantConstructor: typeof Think = Assistant;
const thinkConstructor: typeof Assistant = Think;

class TestAssistant extends Assistant<Cloudflare.Env> {}
class TestThink extends Think<Cloudflare.Env> {}

void assistantConstructor;
void thinkConstructor;
void TestAssistant;
void TestThink;
3 changes: 3 additions & 0 deletions pnpm-lock.yaml

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

Loading