dotsagent.io
语言:简体中文
框架 · Vercel

快速了解 Vercel AI SDK

Vercel 推出的、与模型提供商无关的 TypeScript 工具包。在 AI SDK 7 中,ToolLoopAgent 是主要的 agent 类。它将工具调用循环与流式 UI 辅助工具结合起来,而 WorkflowAgent 支持可在重启后继续运行的任务。

适用于: 希望将工具调用循环 agent 与流式 UI 紧密集成的 Next.js 和 Web 开发者。

关键信息

维护者
Vercel
语言
TypeScript
许可证
Apache-2.0
最新版本
ai 7.0.126 · 2026年9月30日
代码仓库
vercel/ai · 27,070 个 stars
托管选项
Vercel Functions + Vercel Workflow
通用托管平台,而非专为代理设计的运行时。

快速入门

安装软件包、设置凭据,然后运行官方文档中的最简 agent。这里使用的模型 ID 与文档一致,但你的账户可能尚未启用这些模型。

安装
npm install ai zod  (inferred; not copied from docs)

需要 AI Gateway or provider key

TypeScript
import { ToolLoopAgent, tool } from 'ai';
import { z } from 'zod';

const weatherAgent = new ToolLoopAgent({
  model: "anthropic/claude-sonnet-5.5",
  tools: {
    weather: tool({
      description: 'Get the weather in a location (in Fahrenheit)',
      inputSchema: z.object({
        location: z.string().describe('The location to get the weather for'),
      }),
      execute: async ({ location }) => ({
        location,
        temperature: 72 + Math.floor(Math.random() * 21) - 10,
      }),
    }),
    convertFahrenheitToCelsius: tool({
      description: 'Convert temperature from Fahrenheit to Celsius',
      inputSchema: z.object({
        temperature: z.number().describe('Temperature in Fahrenheit'),
      }),
      execute: async ({ temperature }) => {
        const celsius = Math.round((temperature - 32) * (5 / 9));
        return { celsius };
      },
    }),
  },
});

const result = await weatherAgent.generate({
  prompt: 'What is the weather in San Francisco in celsius?',
});

console.log(result.text); // agent's final answer
console.log(result.steps); // steps taken by the agent

快速入门来源

功能

支持任意模型是可使用任意提供商的包,也可使用 anthropic/claude-sonnet-5.5 等 AI Gateway 字符串
MCP 客户端是@ai-sdk/mcp 客户端
MCP 服务器尚未确认
多 agent是子代理;HarnessAgent 可运行 Claude Code、Codex 或 Pi
持久化运行是需要 Workflow 5 beta 的 WorkflowAgent
人工审批是toolApproval,支持 HMAC 签名审批和 OPA 策略
追踪尚未确认
评测尚未确认

近期更新

  • AI SDK 7 将 ToolLoopAgent 列为推荐的代理类。
  • HarnessAgent 可将 Claude Code、Codex 或 Pi 作为代理运行。
  • WorkflowAgent (@ai-sdk/workflow) 取代 Workflow DevKit 的 DurableAgent。
  • runtimeContext 和 toolsContext 取代 experimental_context。

同一语言的替代方案

来源

  1. ai-sdk.dev/docs/agents/overview
  2. ai-sdk.dev/docs/agents/tool-approvals
  3. ai-sdk.dev/docs/agents/workflow-agent
  4. ai-sdk.dev/docs/ai-sdk-core/mcp-tools
  5. vercel.com/kb/guide/durableagent-to-workflowagent
  6. registry.npmjs.org/ai
  7. api.github.com/repos/vercel/ai

为 AI agent 开发者提供的独立参考资料。与此处提及的任何厂商均无关联。

© 2026 DotsAgent · 事实核查日期:2026年10月1日