dotsagent.io
ภาษา:ไทย
เฟรมเวิร์ก · Vercel

ภาพรวม Vercel AI SDK

ชุดเครื่องมือ TypeScript ที่ไม่ผูกกับ provider ของ Vercel โดย ToolLoopAgent เป็นคลาสเอเจนต์หลักตั้งแต่ AI SDK 7 ชุดเครื่องมือนี้เชื่อม tool loop เข้ากับตัวช่วยสร้าง UI แบบ streaming ส่วน WorkflowAgent เพิ่มการรันงานที่ทำต่อได้หลังรีสตาร์ต

เหมาะสำหรับ: นักพัฒนา Next.js และเว็บที่ต้องการเชื่อมเอเจนต์แบบ tool loop เข้ากับ UI แบบ streaming อย่างใกล้ชิด

ข้อมูลสำคัญ

ผู้ดูแล
Vercel
ภาษา
TypeScript
ไลเซนส์
Apache-2.0
เวอร์ชันล่าสุด
ai 7.0.126 · 30 กันยายน 2569
Repository
vercel/ai · 27,070 ดาว
ตัวเลือกแบบโฮสต์
Vercel Functions + Vercel Workflow
แพลตฟอร์มโฮสต์ทั่วไป ไม่ใช่ runtime ที่ออกแบบมาสำหรับ agent โดยเฉพาะ

Quickstart

ติดตั้งแพ็กเกจ ตั้งค่าข้อมูลรับรอง แล้วเรียกใช้ agent ตัวอย่างที่เล็กที่สุดจากเอกสารทางการ Model 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

แหล่งข้อมูล Quickstart

ฟีเจอร์

ใช้ได้กับทุกโมเดลใช่ใช้แพ็กเกจของ provider ใดก็ได้ หรือระบุ string ของ AI Gateway เช่น anthropic/claude-sonnet-5.5
MCP clientใช่ไคลเอนต์ @ai-sdk/mcp
MCP serverยังไม่ยืนยัน
หลาย agentใช่Subagent; HarnessAgent เรียกใช้ Claude Code, Codex หรือ Pi
การทำงานต่อเนื่องแบบทนทานใช่WorkflowAgent ซึ่งต้องใช้ Workflow 5 beta
การอนุมัติโดยมนุษย์ใช่toolApproval พร้อมการอนุมัติที่ลงนามด้วย HMAC และนโยบาย OPA
Tracingยังไม่ยืนยัน
Evalsยังไม่ยืนยัน

การเปลี่ยนแปลงล่าสุด

  • AI SDK 7 กำหนดให้ ToolLoopAgent เป็นคลาส agent ที่แนะนำ
  • HarnessAgent ใช้ Claude Code, Codex หรือ Pi เป็น agent
  • WorkflowAgent (@ai-sdk/workflow) มาแทน DurableAgent ของ Workflow DevKit
  • 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