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