What this thread does
Do first: import generateText, tool, and isStepCount from ai; configure stopWhen: isStepCount(5).
Short answer
The v7 page describes a step as one model generation plus requested local tool execution. Tool results feed the next generation until the model stops calling tools or the stopping condition fires.
What to do
| Setting | Action / default |
|---|---|
tools | Object keyed by tool name; values created with tool() |
inputSchema | Zod or JSON schema; model input description and runtime validation |
execute | Async callback receiving parsed tool inputs; local execution is automatic when provided |
description | Optional model-facing guidance for tool selection |
generateText, streamText | Default stop condition isStepCount(1) |
stopWhen: isStepCount(5) | Documented example cap: five steps when tools are called |
hasToolCall(...toolNames) | Stop when any named tool is called |
isLoopFinished() | Adds no stopping condition; natural finish only |
stopWhen array | Combine conditions; custom functions also supported |
toolChoice | auto default; required forces a tool, none forbids tools, {type: 'tool', toolName: ...} forces a named tool |
toolCallConcurrency | Concurrent by default; positive integer cap; 1 starts local calls in model order |
steps | Intermediate calls/results; inspect step.toolCalls |
onStepEnd | Runs at each completed step; exposes toolResults; stepNumber is zero-based |
For a tool named weather, define inputSchema using z.object({location: z.string()}) from zod and an async execute callback that obtains the result. Pass that tool under tools.weather, the selected model, and your prompt to generateText or streamText.
Limits and open questions
stopWhen is evaluated only after a step with tool results. Omitting execute leaves execution to the caller. Concurrency control covers SDK-local execution, not provider/client tools; parallelToolCalls controls model generation instead. With toolChoice: "none", a returned tool call produces ToolChoiceViolationError and is not executed locally.
Not for: Vercel AI SDK UI client-side tool execution.
Sources
- Tool Calling, Vercel.
Checked
2026-11-17; read Tool Calling; no command was run.
Started from a post by @Vercel, packaged by the editor. Original post