Skip to content
Draft
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
30 changes: 30 additions & 0 deletions .changeset/serious-vans-compare.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,30 @@
---
"agents": minor
"@cloudflare/ai-chat": minor
"@cloudflare/codemode": minor
"@cloudflare/think": minor
---

Update the published packages to support AI SDK v7.

This release moves the package peer ranges from `ai@6` and `@ai-sdk/*@3` to
`ai@7` and `@ai-sdk/*@4`. Consumers need to update their AI SDK dependencies
when upgrading these packages.

Only the current implementations were migrated. New optimisations and APIs made
available by AI SDK v7, such as broader result-shape audits or stream helper
migrations, are intentionally out of scope for this release.

Top-level API notes:

- `@cloudflare/think` keeps the existing `system`, `onStepFinish`, and
`experimental_telemetry` names where callers already use them, while
translating to AI SDK v7 options internally.
- `@cloudflare/think` now also accepts `TurnConfig.telemetry` and forwards it
ahead of `experimental_telemetry` when present.
- `@cloudflare/think` adapts AI SDK v7 `onToolExecutionEnd` events back into
the existing `ToolCallResultContext` shape. `stepNumber` is now `undefined`
for tool completion callbacks because AI SDK v7 no longer provides that value
on the tool execution end event.
- `@cloudflare/ai-chat` updates the `AIChatAgent.onChatMessage` callback type
from `StreamTextOnFinishCallback` to `GenerateTextOnFinishCallback`.
4 changes: 2 additions & 2 deletions agent-think/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -16,13 +16,13 @@
"test:e2e": "vitest run --config tests-e2e/vitest.config.ts"
},
"dependencies": {
"@ai-sdk/openai": "^3.0.70",
"@ai-sdk/openai": "^4.0.0",
"@cloudflare/ai-chat": "workspace:*",
"@cloudflare/think": "workspace:*",
"@cloudflare/workspace": "0.0.0-alpha.11",
"@platformatic/vfs": "^0.4.0",
"agents": "workspace:*",
"ai": "^6.0.202",
"ai": "^7.0.0",
"diff": "^9.0.0",
"isomorphic-git": "^1.38.5",
"react": "^19.2.7",
Expand Down
9 changes: 1 addition & 8 deletions agent-think/src/run-context.ts
Original file line number Diff line number Diff line change
Expand Up @@ -52,14 +52,7 @@ export function buildRunTelemetry(
) {
validateRunTarget(target);
return {
metadata: {
agentId,
agentName,
conversationId: agentId,
repository: target.repo,
issueNumber: target.issueNumber,
...(target.requestedBy ? { requestedBy: target.requestedBy.login } : {})
}
functionId: `${agentName}:${target.repo}#${target.issueNumber}:${agentId}`
};
}

Expand Down
9 changes: 1 addition & 8 deletions agent-think/test/run-context.test.ts
Original file line number Diff line number Diff line change
Expand Up @@ -25,14 +25,7 @@ describe("agent-think run context", () => {

it("keeps identity on every inference and recovery continuation", () => {
expect(buildRunTelemetry(target, "session-209", "ThinkAgent")).toEqual({
metadata: {
agentId: "session-209",
agentName: "ThinkAgent",
conversationId: "session-209",
repository: "cloudflare/workers-oauth-provider",
issueNumber: 209,
requestedBy: "mattzcarey"
}
functionId: "ThinkAgent:cloudflare/workers-oauth-provider#209:session-209"
});
});

Expand Down
2 changes: 1 addition & 1 deletion examples/a2a/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,7 @@
"@cloudflare/kumo": "^2.6.0",
"@phosphor-icons/react": "^2.1.10",
"agents": "*",
"ai": "^6.0.202",
"ai": "^7.0.0",
"react": "^19.2.7",
"react-dom": "^19.2.7",
"workers-ai-provider": "^3.3.0"
Expand Down
2 changes: 1 addition & 1 deletion examples/a2a/src/server.ts
Original file line number Diff line number Diff line change
Expand Up @@ -126,7 +126,7 @@ class AIAgentExecutor implements AgentExecutor {
const workersai = createWorkersAI({ binding: this.getEnv().AI });
const result = await generateText({
model: workersai("@cf/moonshotai/kimi-k2.7-code"),
system:
instructions:
"You are a helpful AI assistant. Keep responses concise and clear.",
messages: [{ role: "user", content: userText }]
});
Expand Down
2 changes: 1 addition & 1 deletion examples/agent-skills/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,7 @@
"@cloudflare/think": "*",
"@phosphor-icons/react": "^2.1.10",
"agents": "*",
"ai": "^6.0.202",
"ai": "^7.0.0",
"react": "^19.2.7",
"react-dom": "^19.2.7"
},
Expand Down
2 changes: 1 addition & 1 deletion examples/agents-as-tools/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -18,7 +18,7 @@
"@phosphor-icons/react": "^2.1.10",
"@streamdown/code": "^1.1.1",
"agents": "*",
"ai": "^6.0.202",
"ai": "^7.0.0",
"react": "^19.2.7",
"react-dom": "^19.2.7",
"streamdown": "^2.5.0",
Expand Down
2 changes: 1 addition & 1 deletion examples/ai-chat/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -16,7 +16,7 @@
"@phosphor-icons/react": "^2.1.10",
"@streamdown/code": "^1.1.1",
"agents": "*",
"ai": "^6.0.202",
"ai": "^7.0.0",
"nanoid": "^5.1.16",
"react": "^19.2.7",
"react-dom": "^19.2.7",
Expand Down
6 changes: 3 additions & 3 deletions examples/ai-chat/src/server.ts
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,7 @@ import {
convertToModelMessages,
pruneMessages,
tool,
stepCountIs
isStepCount
} from "ai";
import { z } from "zod";

Expand Down Expand Up @@ -89,7 +89,7 @@ export class ChatAgent extends AIChatAgent {
model: workersai("@cf/moonshotai/kimi-k2.7-code", {
sessionAffinity: this.sessionAffinity
}),
system:
instructions:
"You are a helpful assistant. You can check the weather, get the user's timezone, " +
"run calculations, and browse the web. " +
"For simple one-shot reads, prefer the Quick Action tools: browser_markdown (read a " +
Expand Down Expand Up @@ -172,7 +172,7 @@ export class ChatAgent extends AIChatAgent {
}
})
},
stopWhen: stepCountIs(20)
stopWhen: isStepCount(20)
});

return result.toUIMessageStreamResponse();
Expand Down
2 changes: 1 addition & 1 deletion examples/assistant/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -18,7 +18,7 @@
"@phosphor-icons/react": "^2.1.10",
"@streamdown/code": "^1.1.1",
"agents": "*",
"ai": "^6.0.202",
"ai": "^7.0.0",
"nanoid": "^5.1.16",
"react": "^19.2.7",
"react-dom": "^19.2.7",
Expand Down
2 changes: 1 addition & 1 deletion examples/auth-agent/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,7 @@
"@cloudflare/kumo": "^2.6.0",
"@phosphor-icons/react": "^2.1.10",
"agents": "*",
"ai": "^6.0.202",
"ai": "^7.0.0",
"react": "^19.2.7",
"react-dom": "^19.2.7",
"workers-ai-provider": "^3.3.0"
Expand Down
2 changes: 1 addition & 1 deletion examples/auth-agent/src/server.ts
Original file line number Diff line number Diff line change
Expand Up @@ -30,7 +30,7 @@ export class ChatAgent extends AIChatAgent<Env> {
model: workersai("@cf/moonshotai/kimi-k2.7-code", {
sessionAffinity: this.sessionAffinity
}),
system: `You are a helpful assistant. The authenticated user's GitHub login is ${this.name}. Address them by their login occasionally.`,
instructions: `You are a helpful assistant. The authenticated user's GitHub login is ${this.name}. Address them by their login occasionally.`,
messages: await convertToModelMessages(this.messages)
});

Expand Down
2 changes: 1 addition & 1 deletion examples/browser-live-view/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,7 @@
"@phosphor-icons/react": "^2.1.10",
"@streamdown/code": "^1.1.1",
"agents": "*",
"ai": "^6.0.202",
"ai": "^7.0.0",
"react": "^19.2.7",
"react-dom": "^19.2.7",
"streamdown": "^2.5.0"
Expand Down
4 changes: 2 additions & 2 deletions examples/browser-quick-actions/README.md
Original file line number Diff line number Diff line change
Expand Up @@ -37,7 +37,7 @@ To let a model decide when to browse, use the AI SDK tools instead — this is w

```ts
import { createQuickActionTools } from "agents/browser/ai";
import { generateText, stepCountIs } from "ai";
import { generateText, isStepCount } from "ai";
import { createWorkersAI } from "workers-ai-provider";

const workersai = createWorkersAI({ binding: this.env.AI });
Expand All @@ -48,7 +48,7 @@ const { text } = await generateText({
model: workersai("@cf/moonshotai/kimi-k2.7-code"),
prompt: `Page: ${url}\n\nQuestion: ${question}`,
tools,
stopWhen: stepCountIs(6)
stopWhen: isStepCount(6)
});
```

Expand Down
2 changes: 1 addition & 1 deletion examples/browser-quick-actions/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,7 @@
"@cloudflare/kumo": "^2.6.0",
"@phosphor-icons/react": "^2.1.10",
"agents": "*",
"ai": "^6.0.202",
"ai": "^7.0.0",
"react": "^19.2.7",
"react-dom": "^19.2.7",
"workers-ai-provider": "^3.3.0"
Expand Down
6 changes: 3 additions & 3 deletions examples/browser-quick-actions/src/server.ts
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@ import {
browserScreenshot
} from "agents/browser";
import { createQuickActionTools } from "agents/browser/ai";
import { generateText, stepCountIs } from "ai";
import { generateText, isStepCount } from "ai";
import { createWorkersAI } from "workers-ai-provider";

// `Env` is the ambient interface generated by `wrangler types` into env.d.ts
Expand Down Expand Up @@ -75,14 +75,14 @@ export class QuickActionsAgent extends Agent<Env> {

const result = await generateText({
model: workersai("@cf/moonshotai/kimi-k2.7-code"),
system:
instructions:
"You are a research assistant. Use the browser_* tools to read the " +
"page the user references, then answer concisely. Prefer " +
"browser_markdown to read a page and browser_extract for structured " +
"data. Always base your answer on what the tools return.",
prompt: `Page: ${url}\n\nQuestion: ${question}`,
tools,
stopWhen: stepCountIs(6)
stopWhen: isStepCount(6)
});

const toolsUsed = result.steps.flatMap((step) =>
Expand Down
2 changes: 1 addition & 1 deletion examples/chat-sdk-messenger/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -17,7 +17,7 @@
"@cloudflare/think": "*",
"@phosphor-icons/react": "^2.1.10",
"agents": "*",
"ai": "^6.0.202",
"ai": "^7.0.0",
"chat": "^4.31.0",
"react": "^19.2.7",
"react-dom": "^19.2.7"
Expand Down
2 changes: 1 addition & 1 deletion examples/codemode-browser/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -16,7 +16,7 @@
"@phosphor-icons/react": "^2.1.10",
"@streamdown/code": "^1.1.1",
"agents": "*",
"ai": "^6.0.202",
"ai": "^7.0.0",
"react": "^19.2.7",
"react-dom": "^19.2.7",
"streamdown": "^2.5.0",
Expand Down
6 changes: 3 additions & 3 deletions examples/codemode-browser/src/server.ts
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
import { routeAgentRequest } from "agents";
import { AIChatAgent, createToolsFromClientSchemas } from "@cloudflare/ai-chat";
import { convertToModelMessages, streamText, stepCountIs } from "ai";
import { convertToModelMessages, streamText, isStepCount } from "ai";
import { createWorkersAI } from "workers-ai-provider";

export class BrowserCodemode extends AIChatAgent<Env> {
Expand All @@ -16,13 +16,13 @@ export class BrowserCodemode extends AIChatAgent<Env> {
model: workersai("@cf/moonshotai/kimi-k2.7-code", {
sessionAffinity: this.sessionAffinity
}),
system:
instructions:
"You are a browser codemode assistant. " +
"Use the codemode tool to write JavaScript that calls functions on the `codemode` object. " +
"The generated code runs in an iframe sandbox in the user's browser and can call browser-provided tools.",
messages: await convertToModelMessages(this.messages),
tools: createToolsFromClientSchemas(options?.clientTools),
stopWhen: stepCountIs(10)
stopWhen: isStepCount(10)
});

return result.toUIMessageStreamResponse();
Expand Down
2 changes: 1 addition & 1 deletion examples/codemode-connectors/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -16,7 +16,7 @@
"@phosphor-icons/react": "^2.1.10",
"@streamdown/code": "^1.1.1",
"agents": "*",
"ai": "^6.0.202",
"ai": "^7.0.0",
"nanoid": "^5.1.16",
"react": "^19.2.7",
"react-dom": "^19.2.7",
Expand Down
6 changes: 3 additions & 3 deletions examples/codemode-connectors/src/server.ts
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@ import { McpAgent } from "agents/mcp";
import { z } from "zod";
import { AIChatAgent } from "@cloudflare/ai-chat";
import { createWorkersAI } from "workers-ai-provider";
import { streamText, convertToModelMessages, stepCountIs } from "ai";
import { streamText, convertToModelMessages, isStepCount } from "ai";
import { routeAgentRequest, callable } from "agents";
import {
createCodemodeRuntime,
Expand Down Expand Up @@ -147,7 +147,7 @@ export class Chat extends AIChatAgent<Env> {
model: workersai("@cf/moonshotai/kimi-k2.7-code", {
sessionAffinity: this.sessionAffinity
}),
system: [
instructions: [
"You are a helpful assistant with a `codemode` tool that runs TypeScript.",
"Inside the sandbox:",
' - await codemode.search("query") to discover connector methods and saved snippets',
Expand All @@ -163,7 +163,7 @@ export class Chat extends AIChatAgent<Env> {
tools: {
codemode: this.#runtime().tool()
},
stopWhen: stepCountIs(10)
stopWhen: isStepCount(10)
});

return result.toUIMessageStreamResponse();
Expand Down
2 changes: 1 addition & 1 deletion examples/codemode/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -16,7 +16,7 @@
"@phosphor-icons/react": "^2.1.10",
"@streamdown/code": "^1.1.1",
"agents": "*",
"ai": "^6.0.202",
"ai": "^7.0.0",
"react": "^19.2.7",
"react-dom": "^19.2.7",
"streamdown": "^2.5.0",
Expand Down
6 changes: 3 additions & 3 deletions examples/codemode/src/server.ts
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@ import { createCodeTool, generateTypes } from "@cloudflare/codemode/ai";
import { DynamicWorkerExecutor } from "@cloudflare/codemode";
import {
streamText,
stepCountIs,
isStepCount,
convertToModelMessages,
pruneMessages
} from "ai";
Expand Down Expand Up @@ -83,7 +83,7 @@ export class Codemode extends AIChatAgent<Env> {
model: workersai("@cf/moonshotai/kimi-k2.7-code", {
sessionAffinity: this.sessionAffinity
}),
system:
instructions:
"You are a helpful project management assistant. " +
"You can create and manage projects, tasks, sprints, and comments using the codemode tool. " +
"When you need to perform operations, use the codemode tool to write JavaScript " +
Expand All @@ -94,7 +94,7 @@ export class Codemode extends AIChatAgent<Env> {
reasoning: "before-last-message"
}),
tools: { codemode },
stopWhen: stepCountIs(10)
stopWhen: isStepCount(10)
});

return result.toUIMessageStreamResponse();
Expand Down
2 changes: 1 addition & 1 deletion examples/context-overflow-recovery/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,7 @@
"@cloudflare/think": "*",
"@phosphor-icons/react": "^2.1.10",
"agents": "*",
"ai": "^6.0.202",
"ai": "^7.0.0",
"react": "^19.2.7",
"react-dom": "^19.2.7"
},
Expand Down
4 changes: 2 additions & 2 deletions examples/deploy-churn/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -14,12 +14,12 @@
"types": "wrangler types env.d.ts --include-runtime false"
},
"dependencies": {
"@ai-sdk/anthropic": "^3.0.83",
"@ai-sdk/anthropic": "^4.0.0",
"@cloudflare/kumo": "^2.6.0",
"@cloudflare/think": "*",
"@phosphor-icons/react": "^2.1.10",
"agents": "*",
"ai": "^6.0.202",
"ai": "^7.0.0",
"react": "^19.2.7",
"react-dom": "^19.2.7",
"workers-ai-provider": "^3.3.0"
Expand Down
2 changes: 1 addition & 1 deletion examples/dynamic-tools/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,7 @@
"@phosphor-icons/react": "^2.1.10",
"@streamdown/code": "^1.1.1",
"agents": "*",
"ai": "^6.0.202",
"ai": "^7.0.0",
"react": "^19.2.7",
"react-dom": "^19.2.7",
"streamdown": "^2.5.0",
Expand Down
Loading
Loading