AI SDK 7:Agent 應用先要設計執行契約
Vercel AI SDK 7 增加 reasoning control、scoped context、tool approvals、WorkflowAgent、MCP Apps、sandbox 與 telemetry。
Execution contract read
風險:provider 差異仍然存在。簡單 chatbot 可能不需要,但有檔案、外部 API 和審批的產品需要清楚執行契約。
What happened
AI SDK 7 於 2026 年 6 月 25 日發布,擴展了 agent 開發、執行、harness integration 與可觀測性。
Why it matters
實務重點是分離 prompt、runtime context 與 tool context。憑證、tenant data 與 access token 不應進入 prompt。
Community signal
社群問題集中在 cost、streaming tool output、BYOK、reasoning traces、Guardrails 與 multi-agent workflows。
Checklist
Checklist:每個 tool 設定 contextSchema,高風險 action 要 approval,使用 durable execution,拆分 timeout,設置 MCP Apps sandbox 與完整 tracing。
Risks
風險:provider 差異仍然存在。簡單 chatbot 可能不需要,但有檔案、外部 API 和審批的產品需要清楚執行契約。
Runtime contract map
| Area | AI SDK 7 surface | Operational question |
|---|---|---|
| Context | runtimeContext, toolsContext, contextSchema | Keep tenant state and credentials out of prompt text. |
| Approval | Tool-level policy and human gates | Revalidate risky tool calls before execution continues. |
| Durability | WorkflowAgent or workflow layer | Survive deploys, restarts, and delayed approvals. |
| UI boundary | MCP Apps plus sandboxed iframe | Separate user review surfaces from model-visible tools. |
| Observability | OpenTelemetry, lifecycle events, usage | Trace steps, tool calls, approvals, errors, and cost together. |
Checklist:每個 tool 設定 `contextSchema`,高風險 action 要 approval,使用 durable execution,拆分 timeout,設置 MCP Apps sandbox 與完整 tracing。
• Checklist:每個 tool 設定 contextSchema,高風險 action 要 approval,使用 durable execution,拆分 timeout,設置 MCP Apps sandbox 與完整 tracing。
來源
- Vercel Blog: AI SDK 7
- Vercel Changelog: AI SDK 7 is now available
- AI SDK Docs: Migrate AI SDK 6.x to 7.0
- Vercel KB: Pass state to AI SDK tools and agents with context
- AI SDK Docs: Model Context Protocol tools
- AI SDK Docs: MCP Apps
- AI SDK Docs: Getting started with coding agents
- Vercel Community: AI SDK topics