AI SDK 7.1 for TypeScript agents: what to adopt first
Which AI SDK 7.1 features belong in your agent? Start with tool ordering and steering, check your 7.0 patch, then choose batch, audio or durable execution.
Published

If your TypeScript agent can update a file and read it back, start with tool-call ordering. If a user can correct the agent while it works, add steering next. Vercel’s AI SDK 7.1.0 release on December 3, 2026 gives a TypeScript app control over when a tool runs, when a correction takes effect and which jobs can finish after the request ends. Vercel’s release notes
What changes on the way from 7.0?
Check the exact version in your lockfile. The 7.1.0 notes collect features that landed across the 7.0 series. A team upgrading from 7.0.189 has a different migration from one still on an early 7.0 patch. Vercel labels 7.1.0 a minor release. As of December 2026, these are the changes I would check against an existing application. Tagged package changelog
Adopt first for a small team
First, order dependent tool calls. Imagine a user asking an agent to update a file and then read it back. The model can ask for both operations in the same step. By default the SDK can execute them concurrently, so a successful read could still see the old file. On the call that needs ordering, use the setting from Vercel’s example. Here tools is the app’s configured tool set. Tool-call concurrency
const result = await generateText({
model: "anthropic/claude-sonnet-5.5",
tools,
prompt: 'Update the file, then read it.',
toolCallConcurrency: 1,
});prompt: 'Update the file, then read it.'
toolCallConcurrency: 1
Start SDK-executed calls in the order the model generated them.
Finish the write before starting the read.
This is my first pick because you can apply it to one known dependency and check the returned file contents. The limit governs calls the SDK executes locally. Provider-executed and client-side tools keep their own scheduling. Independent lookups can keep their existing concurrency. If the model requested the operations in the wrong order, serialization alone will preserve that mistake.
Second, let a user correct a running loop. In Vercel’s weather example, the user meant Paris, Texas. A correction belongs in the run that is already looking up the weather. A request to do another job belongs after the current task. The experimental steering object exposes both choices on generateText, streamText and ToolLoopAgent. A durable WorkflowAgent has a different interface and does not take experimental_steering. Loop control and steering
const steering = experimental_createSteering();
const run = agent.generate({
prompt: 'What is the weather in Paris?',
experimental_steering: steering,
});
await steering.steer('I meant Paris, Texas.');
const result = await run;steering.steer('I meant Paris, Texas.')
steering.queue('Then add tests for it.')
Next step boundary, after the current tool calls finish.
After the current task finishes, if the loop can continue.
This is my second pick for an interactive agent because users can recover from a mistaken instruction without starting the task over. Check the delivery outcome before showing a correction as applied. A stop condition can end the loop first, and prepareStep can remove the message. A running tool completes even if the user corrects its input. When saving a chat, include each step’s experimental_steeringMessages in order with its response messages. Saving only the final response can lose the correction.
As of Dec 5, 2026 · Source: Vercel AI SDK, Loop Control
When another runtime should own the coding session
A model provider answers a model call. A harness adapter connects your app to a whole agent runtime with its own tools, permissions and session state. The release names Cline, Cursor, fx, GitHub Copilot and Grok Build. The Codex adapter now talks to its app server and supports mid-turn steering. The harness packages are experimental. Runtime placement matters when choosing one. For example, fx runs on the host while its built-in shell and filesystem tools work in the sandbox. Cursor, GitHub Copilot and Grok Build use a sandbox via ACP. Harness adapter comparison
new HarnessAgent({ harness: fx, model: 'openai/gpt-5.6-luna' })
await agent.createSession({ sandboxSession })
await session.destroy()
await sandboxSession.destroy()
await agent.getSandboxTemplate()
await agent.stream({ session, prompt: 'Check the test failures and fix the production code.' })
In that example the app imports HarnessAgent from @ai-sdk/harness/agent and fx from @ai-sdk/harness-fx. It passes the template to createVercelNetworkSandboxSession, reads text-delta events from the result and releases both sessions in a finally block. Pick a harness when you want that runtime’s session behavior. If an existing tool loop only needs shell or web access, Vercel ships createBashTool() and createWebFetchTool() separately. Bash uses the session passed as experimental_sandbox. Vercel’s fx example · First-party tools
For the deployment decision, see the fx adapter walkthrough, the ACP adapter guide and the Grok Build adapter walkthrough.
When the app needs a decision it can act on
For a support queue, the return value you need might be a department name drawn from a fixed set. With experimental_decide, you submit shared state and named questions. A choice returns a typed option key. A score uses ordered levels. A boolean gives the estimated probability of true. A box returns normalized edges for an image region on a supporting model. State can hold text, JSON or ordered multimodal parts. Both the API and its model specification are experimental and may change in a patch. Typed decisions
state: 'I was charged twice.'
instructions: 'Which team should handle this?'
criteria: { billing: 'Charges and refunds', support: 'Other requests' }
result.answers.department.choice
TypeScript permits 'billing' or 'support'.
With the registry configured as in Vercel’s example, the call and its return type fit together like this.
const result = await experimental_decide({
model: registry.decisionModel('triage:native'),
state: 'I was charged twice.',
questions: {
department: {
type: 'choice',
instructions: 'Which team should handle this?',
criteria: { billing: 'Charges and refunds', support: 'Other requests' },
},
},
});
result.answers.department.choice; // 'billing' | 'support'The union tells you which values your router must handle. It says nothing about whether the model picked the right queue. Native providers can return a distribution for choices and scores. The documented Anthropic adapter uses structured output and omits those distributions. For a refund request, try the routing rule on tickets with known labels before choosing a cutoff. Keep an explicit review path for ambiguous cases.
When requests can wait for a background job
An overnight ticket-classification job can give every ticket its own request ID, submit the group and exit. The experimental batch API accepts independent text or image requests on supporting providers. Text requests can carry tool definitions and, where supported, different model IDs within one batch. The app still executes client tools. Choose batches when the user can come back for a result and you can store a reference. Batch processing
import { experimental_startBatch as startBatch } from 'ai'
const batch = await startBatch({ provider, requests })
console.log(batch.id, batch.status)
await getBatchStatus({ provider: anthropic, batch })
for await (const item of getBatchResults({ provider: anthropic, batch }))
Here provider is anthropic, and getBatchStatus and getBatchResults alias the corresponding experimental_ exports. Each request includes an ID, a type, a model and a prompt or messages. Persist the serializable batch reference. When the status reaches completed, iterate through the items, check each status and join successes to inputs by ID. Results can arrive out of order, and completion of the batch says nothing about the success of an individual ticket. Check provider support before building a cancel button, a jobs listing or a completion webhook.
When a voice interface needs live audio
Choose the interface from the direction the audio travels. A listener hearing an agent read a story needs speech synthesis. A call taker reading captions needs transcription. An interpreter needs translated audio and text. A conversation with a live model needs a session that can receive and send events throughout the call.
const { textStream } = streamText({ model: 'openai/gpt-5-mini', prompt: 'Tell me a short story.' })
model: elevenLabs.speech('eleven_flash_v2_5')
text: textStream
for await (const chunk of result.audioStream)
The right column shows the model and text arguments to experimental_streamSpeech, imported as streamSpeech in Vercel’s example. For captions, the documented streamTranscription call uses the following input. Here audioStream carries raw PCM at the specified sample rate.
const result = streamTranscription({
model: openai.transcription('gpt-realtime-whisper'),
audio: audioStream,
inputAudioFormat: { type: 'audio/pcm', rate: 24000 },
providerOptions: {
openai: { language: 'en', streaming: { delay: 'low' } },
},
});A transcript UI can update on transcript-partial and commit on transcript-final. For translation, Vercel’s OpenAI example uses the following call with raw PCM input. Read the single-consumer fullStream before awaiting the final translation if you need both. Streaming speech · Transcription · Translation
const result = streamSpeechTranslation({
model: openai.speechTranslation('gpt-realtime-translate'),
audio: audioStream,
inputAudioFormat: { type: 'audio/pcm', rate: 24000 },
targetLanguage: 'es',
});const model = openai.experimental_realtime('gpt-live-1')
api: { websocket: 'wss://your-app.example/live' }
<button onClick={realtime.connect}>Connect microphone</button>
<button onClick={() => realtime.close()}>End conversation</button>
The relay in the hook example authenticates the browser and keeps provider credentials on the server. OpenAI Live also supports browser WebRTC through api.session. For a server-owned WebSocket, the app owns the connection lifetime and reconnect policy. Providers can also supply a managed transport. For a text chat that simply needs a persistent connection, new WebSocketChatTransport({ url: '/api/chat' }) works with useChat and supports cancellation and sequence-based resume. Vercel documents that transport without an experimental label. Realtime sessions · Continuous conversation example · Chat transport
When tool results are larger than the answer
An inventory assistant might need availability and demand for the same product. The person asking needs the comparison. With experimental code mode, the model can write JavaScript or TypeScript that calls both tools and returns a small JSON result. The program runs inside QuickJS. The package requires Node.js 22 or newer and does not run in a browser or edge runtime. Its TypeScript support strips types. Code mode
code_mode: codeModeTool({ executionPolicy: { timeoutMs: 30_000 } })
experimental_toolCallers: { getInventory: ['code_mode'], getDemand: ['code_mode'] }
await tools.getInventory({ productId: 'sku_123' })
inventory.availableUnits > 0
The app imports experimental_codeModeTool as codeModeTool from @ai-sdk/code-mode. The keys in experimental_toolCallers name the governed tools. Each value lists who may call that tool. In this example only the code-mode tool can call the inventory and demand tools. Keep actions that require user approval directly callable. A nested call inside the generated program cannot pause to collect approval.
For a concrete tool catalog, see the Vercel MCP and AI Gateway tools guide.
If finding the right tool is the problem, start with toolSearch(), which Vercel documents without an experimental label. Register a tool with deferLoading: true, add search: toolSearch() to the tool set and allow another model step. Matches become available on that next step. With code mode, toolDiscovery: 'conversation' sends discovered definitions in messages so the provider-visible tool definition stays unchanged. Actual prompt-cache reuse depends on the provider. Tool search
When video generation outlives the request
A product team rendering a clip can acknowledge submission immediately and let a worker fetch the finished video later. The experimental start call returns an opaque, JSON-serializable operation. Save the entire value. The status call takes the model as its first argument and an options object containing that operation as its second. It performs one check. Vercel’s tagged MiniMax example
const model = minimax.video('MiniMax-H3')
experimental_startVideo as startVideo
console.log(JSON.stringify(operation))
await parseJSON({ text: serializedOperation })
await getVideoStatus(model, { operation, maxRetries: 0 })
The example aliases experimental_startVideo and experimental_getVideoStatus from ai. A pending operation needs a later check. The start invocation in Vercel’s example looks like this.
const { operation, warnings } = await startVideo({
model,
prompt: 'A white kitten chases a butterfly across a sunlit garden.',
aspectRatio: '16:9',
duration: 5,
maxRetries: 0,
providerOptions: { minimax: { resolution: '768P' } },
});A provider with completion webhooks can notify your receiver so it fetches the terminal result. If art direction requires a particular opening or closing image, use frameImages on a supporting model. For source material such as a reference clip, use inputReferences and inspect the provider warnings for unsupported media. Video generation
When a stream stalls or a job needs to survive suspension
A stream can open successfully and still leave a user staring at an empty answer. Set timeout.firstChunkMs for the wait until content. Use onStepError to identify a failed step, and prepareStep to change call settings such as the output token limit for a particular step. The release documents these controls without an experimental label. Timeouts · Lifecycle callbacks · Per-step settings
timeout: { firstChunkMs: 10000 }
streamRetries: 2
Limit the wait for the first content in each step.
Retry an eligible provider failure in the current model step.
Completed steps stay complete. Already emitted partial text stays visible.
Enable streamRetries deliberately. A UI that blindly appends every chunk can display a partial answer followed by the retry’s answer. For a long stream with a single consumer, experimental_streamTextLowMemory skips replay buffering and retained final content. Choose it where you consume deltas once and have no need to retrieve the whole answer afterward. Streaming retries · Low-memory streaming
A durable job has a different completion condition. A summarizer might need a final value that survives a workflow suspension, with no live UI. The documented WorkflowAgent.generate() method from @ai-sdk/workflow has no experimental label. Its default maximum is 20 steps. Return selected serializable fields from the workflow. With the durable OpenTelemetry bridge configured, model and tool spans belong to one agent operation across suspension and resumption, retaining their original timestamps. WorkflowAgent · Durable tracing
'use workflow'
const result = await agent.generate({ prompt: text })
return { text: result.text, usage: result.usage }
For a small team, the acceptance checks can be concrete. A dependent read should see the completed write. A user correction should either reach the next eligible step or produce an outcome the UI can act on. Once those work, pick the next feature by the job you actually have to run. For background media or batches, check the selected provider’s model support, billing and webhook behavior before committing to a route.
Vercel AI SDK fundamentals
Follow a model call and a tool loop through a TypeScript app.
OpenRouter alternatives for multi-model routing
Compare routing options when your app needs more than one provider.
- Published
- Category
- Build







