AI Engineer Europe 2026
AI SDK v6
Loading slides…
Read the talk
AI SDK v6: From a Chat Interface to an Agent with a Persistent Computer
Build a streaming TypeScript agent, add typed tools and a persistent filesystem, then follow the live debugging that turns stored memories and scripts into reusable capabilities.
From a talk by Nico Albanese
Before you start: Familiarity with TypeScript, React hooks, Next.js route handlers, and basic command-line development will help you follow the implementation.
Bring the deployed project into local development
The application is already live on Vercel when the recording begins. Its dashboard shows one completed production-checklist item, but the immediate task is to get that deployed project running locally. Nico Albanese opens the linked GitHub repository, copies its clone address from the Code button, and clones aie-london-demo. The workshop’s Project Setup page supplies the accompanying instructions.
Install the Vercel CLI if needed, authorize its browser login, and check which account it is using:
bash
npm i -g vercel
vercel whoami
Inside the cloned repository, run vercel link, select the matching project, and pull its environment variables. The resulting OIDC token authenticates both AI Gateway inference and Vercel Sandbox access in this workshop.
Two setup failures are easy to confuse. Account selection determines which projects and teams are visible: vercel logout followed by vercel login corrects a personal-versus-work account mismatch. Executable selection determines which CLI actually runs. Albanese reports that an older authentication method had been invalidated, prompting an update with npm install -g vercel@latest; which vercel then reveals whether the executable belongs to that npm installation or, as on his machine, to pnpm. Updating one installation does not update the other.
Suggest correction
This note stays in this page until you copy or download it. Nothing is submitted; reloading clears the draft.
Separate the agent from its HTTP endpoint
While setup finishes, Albanese shows the redesigned AI SDK landing page, including live download figures, and points to OpenCode as an application built on the SDK. Back in the project, the first check is deliberately ordinary: install dependencies, start the fresh Next.js app, and confirm that its starter page appears at localhost:3000. Then add the agent dependencies:
bash
pnpm install
pnpm run dev
After stopping the development server:
bash
pnpm add ai @ai-sdk/react zod
ai supplies the core SDK, @ai-sdk/react supplies the React integration, and Zod supplies schema definitions.
AI SDK 4 centered on generateText, streamText, generateObject, and streamObject. In the v6 workshop, structured output is also available through the text-generation functions. The architectural change is a reusable agent definition: Albanese’s motivating example is an api/chat/route.ts swollen with inline tools and system prompts. Moving that configuration into lib/agent.ts lets a Next.js endpoint, a Bun server, or another application in a monorepo reuse the same plain JavaScript agent.
ToolLoopAgent names the behavior it packages: an agent that can repeatedly call tools. Its smallest definition needs a model. An explicit provider instance, such as one created with openai from @ai-sdk/openai, remains an option. The demonstrated v6 global provider defaults to AI Gateway, so a plain model string can select a gateway model; applications can override that global provider.
The initial model is GPT-5.4 mini, chosen for inexpensive, fast experimentation. Albanese notes that he has used the larger model extensively but has less experience with mini. The reusable definition is correspondingly small:
typescript
// lib/agent.ts
import { ToolLoopAgent } from 'ai';
export const myAgent = new ToolLoopAgent({
model: 'openai/gpt-5.4-mini',
});
This defines the agent; it does not yet expose a way for the browser to call it.
Suggest correction
This note stays in this page until you copy or download it. Nothing is submitted; reloading clears the draft.
Connect the route, stream, and message parts
The HTTP boundary lives in app/api/chat/route.ts. Its job is to receive messages and return the agent’s UI stream:
typescript
// app/api/chat/route.ts
import { createAgentUIStreamResponse } from 'ai';
import { myAgent } from '@/lib/agent';
export async function POST(request: Request) {
const { messages } = await request.json();
return createAgentUIStreamResponse({
agent: myAgent,
uiMessages: messages,
});
}
createAgentUIStreamResponse bundles the streaming work that otherwise surrounds a streamText call and conversion to a UI-message response. The agent also exposes myAgent.stream for direct streaming. The agent owns behavior; the endpoint owns HTTP delivery.
On the client, useChat owns message state and provides sendMessage. Each message contains parts, so rendering traverses both levels. This first client handles text; tool-specific parts come later.
tsx
// app/page.tsx
'use client';
import { useState } from 'react';
import { useChat } from '@ai-sdk/react';
export default function Page() {
const [input, setInput] = useState('');
const { messages, error, sendMessage } = useChat();
return (
<main>
{messages.map(message => (
<div key={message.id}>
<strong>{message.role}</strong>
{message.parts.map((part, index) =>
part.type === 'text' ? (
<p key={index}>{part.text}</p>
) : null,
)}
</div>
))}
{error && <p role="alert">{error.message}</p>}
<form onSubmit={event => {
event.preventDefault();
if (!input.trim()) return;
void sendMessage({ text: input });
setInput('');
}}>
<input
aria-label="Message"
value={input}
onChange={event => setInput(event.target.value)}
/>
<button type="submit">Send</button>
</form>
</main>
);
}
All conversation state remains on the client in this workshop. With the development server running, a greeting and a returned response establish the complete browser-to-agent path.
Suggest correction
This note stays in this page until you copy or download it. Nothing is submitted; reloading clears the draft.
Instructions connect capabilities to behavior
The first behavioral change is one line in the agent definition: instructions: 'Respond like a cowboy.' A new greeting produces “Howdy, partner” and a cowboy emoji. The demonstration is small, but it establishes that the reusable definition controls behavior without changing the route or client.
The workshop builds toward three cooperating components:
- Runtime: manages the tool loop and the context passed between steps.
- Tools: give the agent operations it can request.
- Computer: supplies a filesystem and an environment for executing code and retaining state during work sessions.
Instructions tell the agent how to use those capabilities together. They remain consequential even when the application has moved far beyond a single prompt and response.
Suggest correction
This note stays in this page until you copy or download it. Nothing is submitted; reloading clears the draft.
Add context with a provider-executed tool
Web search is the first tool because it gives the agent access to information outside its existing conversation. Installing @ai-sdk/openai supplies the provider’s tool definition even though inference still goes through AI Gateway. The distinction between tool categories is who defines the interface and who executes the operation.
| Tool category | Interface supplied by | Execution supplied by |
|---|---|---|
| Custom | Application developer | Application code |
| Provider-defined | Model provider | Application code |
| Provider-executed | Model provider | Provider infrastructure |
A custom tool needs a description, input schema, and execution function. Provider-defined tools, such as Anthropic’s Bash and computer-use tools, have interfaces designed for the provider’s models, but the application still supplies the operation. Provider-executed tools, such as hosted web search, run on the provider’s servers and return their results in the message state. That saves implementation work while tying the capability to the provider.
Remove the cowboy instructions and register the hosted search tool:
typescript
// lib/agent.ts
import { ToolLoopAgent } from 'ai';
import { openai } from '@ai-sdk/openai';
export const myAgent = new ToolLoopAgent({
model: 'openai/gpt-5.4-mini',
tools: {
webSearch: openai.tools.webSearch({}),
},
});
The provider helper augments the outgoing request to enable search. Asking when AI Engineer Summit London takes place now produces an answer with retrieved context, although the interface remains blank during the wait. Albanese then configures London as the search tool’s user location. Asking the question again without naming the city produces a London-oriented answer: that extra location context travels as a provider-tool parameter.
Suggest correction
This note stays in this page until you copy or download it. Nothing is submitted; reloading clears the draft.
Make tool activity visible and typed
The search works, but the user cannot tell that anything is happening. The agent may be taking multiple steps while the text-only interface renders nothing. Tool parts use a tool- prefix followed by the registered tool name, so webSearch appears as tool-webSearch. Adding a rendering case makes the activity visible, but the first attempt exposes another problem: its input is typed as unknown.
The agent definition becomes the source of truth for UI types. Export a message type derived from that definition:
typescript
// Add to lib/agent.ts
import type { InferAgentUIMessage } from 'ai';
export type MyAgentUIMessage = InferAgentUIMessage<typeof myAgent>;
Use MyAgentUIMessage[] for the route’s incoming messages, then pass the type to useChat<MyAgentUIMessage>(). Discriminating a part by tool-webSearch now exposes the corresponding tool input and output types. The type relationship flows from the server-side tool definition into the client renderer.
With the typed search component installed, the next request—asking who Nico Albanese is—shows an inline pending state before the result. Tool rendering makes the work observable while it is happening, rather than waiting for the final prose to reveal that a search occurred.
Suggest correction
This note stays in this page until you copy or download it. Nothing is submitted; reloading clears the draft.
Give long tasks a plan outside the conversation
The next capability is a computer. Albanese motivates it with Vercel’s internal d0 analytics agent, which accesses backend and administrative data, including Salesforce, through a Slack interface. It began as a way to reduce repeated requests to the data team. In his account, an agent with many tools could call several of them and still return a partly hallucinated answer. Adding a filesystem changed how it organized its work.
Each session received a scratchpad with the objective at the top, an initial plan beneath it, and steps to check off as work progressed. A separate directory held the research. Instructions required the agent to consult the plan and follow it, repeatedly bringing the original objective back into focus instead of leaving it buried in an expanding conversation. At completion, the same files provided an inspectable record of the work. Albanese reports better follow-through from this pattern with either a full computer or a virtual filesystem.
He describes the pattern as common to internal data, go-to-market, and customer-support agents. Albanese reports roughly 90% fewer customer-support tickets, without specifying the measurement period or denominator. His accompanying qualitative observation is that users were thanking the support agent for its help.
Suggest correction
This note stays in this page until you copy or download it. Nothing is submitted; reloading clears the draft.
Keep filesystem state while compute comes and goes
A remote sandbox is fundamentally ephemeral: however long its process can run, eventually that instance ends. The workshop uses Vercel’s named, persistent sandboxes, described at the time as a beta feature. A stable name identifies the sandbox, while sessions represent its running instances. A request for that name reaches an active instance if one exists or starts a new one if necessary.
This replaces lifecycle code Albanese had previously written himself: archive the filesystem after each request, store the archive in blob storage, and restore it into a new machine later. In the named-sandbox design he demonstrates, inactivity shutdown snapshots the filesystem and a subsequent request restores it. Filesystem continuity does not require a continuously running process. The application can keep referring to the same named workspace across requests.
Suggest correction
This note stays in this page until you copy or download it. Nothing is submitted; reloading clears the draft.
Separate network history from model context
An audience question interrupts the sandbox implementation: if the agent can store things elsewhere, must each request still send the entire conversation? There are two different decisions here. In the demonstrated useChat setup, sendMessage sends the full message history to the route. A production application can instead transmit only the newest message and reconstruct the conversation from server-side storage. That reduces the client request payload without necessarily changing what the model receives.
Selecting the model’s context is a separate policy decision. The SDK does not decide which older information is irrelevant. convertToModelMessages converts UI messages into model messages, removing UI-specific information such as IDs and timestamps; data-part conversion can also shape what reaches the model. Because the application owns the messages, it can inspect and transform them, including removing selected tool-call content. Those transformations require application-specific judgments about what to preserve.
prepareStep provides a more granular intervention point. It runs before each model step in the tool loop, with access to messages and information about the run so far. Returning parameters changes the inputs for that next step. The workshop’s example starts selecting only the latest five messages once the step number reaches 20:
typescript
import { ToolLoopAgent } from 'ai';
export const filteredAgent = new ToolLoopAgent({
model: 'openai/gpt-5.4-mini',
prepareStep: ({ stepNumber, messages }) => {
if (stepNumber >= 20) {
return { messages: messages.slice(-5) };
}
return {};
},
});
The example shows where to implement a sliding context window. Choosing an appropriate window—and preserving the information required by the task—remains the developer’s responsibility.
Suggest correction
This note stays in this page until you copy or download it. Nothing is submitted; reloading clears the draft.
Pruning trades context space against cache reuse
Albanese then opens an example from his own coding agent using GPT-5.4. Albanese reports a single turn lasting 104 minutes, making 316 tool calls, changing 29 files, and occupying 32% of GPT-5.4’s context window without compaction. This is an observation from his system, rather than a controlled comparison of context-management strategies.
His earlier strategy removed old tool calls to keep context occupancy around 40–60%. The cost was that changing earlier input invalidated cached input, undermining reuse on later calls. He contrasts his recollection of roughly 400K-token windows when using Opus and GPT-5.3-Codex with the million-token windows he was using more recently; the specific Opus version and configuration are not identified. With more room available, aggressive pruning had become less attractive for his workload.
Two alternatives keep detailed work out of the main conversation:
- Sub-agents: assign a sufficiently independent task to another context, then bring back a compact result—roughly a thousand tokens in his example—instead of every intermediate tool result.
- Handoff: let the agent prepare relevant context and start a new main thread. Albanese points to Amp’s handoff tool as an example.
He favors delegation where possible because LLM-generated summaries are lossy.
The failure mode he worries about is losing a user constraint during compaction. He recounts an OpenClaw email-deletion incident and attributes it to oversized email results triggering a summary that dropped an instruction against the action. That causal account is his interpretation, not an established diagnosis here. He does not offer a settled rule for preserving every constraint, such as retaining user messages while stripping everything else.
Describing personal use for roughly 14 hours a day over four months, Albanese says compaction had not been a practical problem for him. Albanese reports a 95% cache-token read ratio for that personal coding-agent usage. He values that reuse for speed and cost.
The API distinction at the end of the discussion is important: prepareStep changes a step’s input without destructively replacing the accumulated history. Each invocation starts with the aggregated messages again. Returning a filtered array affects that step, while final persistence can still retain the complete message record. A transient context policy and the durable conversation record can therefore serve different purposes.
Suggest correction
This note stays in this page until you copy or download it. Nothing is submitted; reloading clears the draft.
Pass a sandbox into each agent invocation
Returning to the implementation, install the workshop’s sandbox beta:
bash
pnpm add @vercel/sandbox@beta
A helper in lib/sandbox.ts accepts a sandbox name, returns the existing sandbox if found, or creates it otherwise. The agent now needs more than conversation messages at call time: it needs that sandbox instance.
This is a general requirement. A support agent might receive a customer ID and account tier; a hypothetical airline assistant might route a blue-tier customer to GPT-5.4 mini and a gold-tier customer to GPT-5.4 pro. These structured inputs change agent behavior without belonging in the conversation itself. Instead of wrapping agent creation in an ad hoc factory, callOptionsSchema declares those call-time inputs explicitly.
For the computer-backed agent, the schema requires an actual Sandbox instance:
typescript
import { ToolLoopAgent } from 'ai';
import { Sandbox } from '@vercel/sandbox';
import { z } from 'zod';
const callOptionsSchema = z.object({
sandbox: z.instanceof(Sandbox),
});
export const myAgent = new ToolLoopAgent({
model: 'openai/gpt-5.4-mini',
callOptionsSchema,
});
The corresponding options argument to createAgentUIStreamResponse is now typed to require a sandbox. Omitting it produces a type error at the call site.
The sandbox must then reach the tools that will use it. The runtime’s context serves this purpose: like React context, it carries arbitrary objects, values, and functions to downstream code. It is distinct from the conversation context sent to the model. prepareCall runs once before each agent run and copies the sandbox from call options into runtime context. Albanese explicitly corrects its lifetime: that context spans the steps of one run, not separate invocations.
Suggest correction
This note stays in this page until you copy or download it. Nothing is submitted; reloading clears the draft.
Wire Bash from the agent to the computer
tools.ts introduces Bash as the general-purpose interface to the computer. Rather than defining separate operations for listing files, writing files, and running scripts, the agent can express them as shell commands. The tool still has the same three components as any custom tool: a description that guides selection and use, an input schema that describes the command, and an execute function that performs it. Runtime context arrives through the execution function’s second argument, allowing the tool to access the supplied sandbox without being tied to a particular agent definition.
At this point in the v6 workshop, stronger typing between a tool’s required runtime context and its enclosing agent is described as forthcoming in AI SDK 7. The demonstrated tool retrieves the sandbox, runs the generated Bash command, and returns standard output, error output, and the exit code. Those results give the next model step evidence about what actually happened.
The first ls -la request fails because the implementation has not yet connected the parts. The repair is a useful wiring checklist:
- Register the Bash tool in the agent’s
toolsobject. - In the route, call
createOrGetSandboxwith a stable name. - Pass the returned instance through the agent’s call options.
- Add a
tool-bashrendering case alongside text andtool-webSearch.
The demo’s name is an arbitrary ID; an application would associate it with a user or session. After the missing connections are added, ls -la runs and an inline terminal displays the result from Vercel Sandbox.
Suggest correction
This note stays in this page until you copy or download it. Nothing is submitted; reloading clears the draft.
Load memory deterministically, then debug what gets saved
A working tool does not automatically tell the agent when to use it. Asking what it can see initially produces little useful computer interaction. Instructions that explain its access to a computer—and connect that question to ls—make the intended behavior explicit. The next step is to store useful information in that filesystem.
Albanese’s starting memory design is a core memories.md file loaded into the instructions on every run. It can point to other sources, such as a searchable conversations.jsonl, while the agent uses find, ls, grep, and glob-style matching to retrieve details as needed. In prepareCall, deterministic application code reads memories.md and inserts its contents into the instructions, or indicates that there are no memories yet. The agent’s instructions then tell it that it can read and write the file and should save facts the user shares. Retrieval of core memory is guaranteed by code; selection of new memories is delegated to the agent.
The first test saves Nico’s name. After a browser refresh, the name is still available—but the agent also records the subsequent greeting as a fact. Changing the wording from saving any facts to saving important facts does not immediately fix the behavior. By this point, Albanese confirms that the model has been changed to GPT-5.4.
He tries excluding greetings and voices a concern that naming unwanted behavior might reinforce it. The more concrete problem comes from the audience: the old memories are still being fed back into the prompt. Updating instructions has not removed the examples already stored in memories.md. The demo deletes those memories before trying again, making the persistent file part of the debugging process rather than treating the prompt as the only source of behavior.
The prepared revision excludes greetings, small talk, and information derivable from the codebase. It also makes the agent more inquisitive, asking for a name and occupation. Nico supplies his name, then says that he works on AI SDK at Vercel. Those details are saved, and a new chat retains them. The refreshed browser conversation and the persistent sandbox now have visibly different lifetimes.
Suggest correction
This note stays in this page until you copy or download it. Nothing is submitted; reloading clears the draft.
Let the workspace accumulate executable capabilities
A persistent computer also lets the agent save code it can use again. The useful loop is to build something, execute it, inspect the result, and revise it. Compilers and typecheckers make coding especially suitable for this feedback cycle. The workshop extends the instructions so that repeatable tasks become Python scripts, with descriptions added to memories.md so later runs can discover them. A future weather request should reuse the existing weather script instead of rebuilding it.
For the live test, Albanese explicitly asks for London’s weather using Python. Within one assistant turn, the agent uses Bash to write and execute Python, obtains a weather result, and adds the capability to its memory file. The new reusable operation is a file in the workspace, reached through the existing Bash tool; no new SDK tool registration is necessary.
The next request asks for weather in SF. The agent reuses its script, but the location resolves to Quebec, Canada. The SF request initially returns −11 for the wrong location; after correction, the demo returns 12 °C. The failure exposes the distinction between successful code execution and a correct interpretation of the user’s request. The workspace can retain the script, its corrections, and user preferences, so subsequent work starts from something more useful than an empty machine.
Suggest correction
This note stays in this page until you copy or download it. Nothing is submitted; reloading clears the draft.
Carry the same pattern into background execution
The closing demonstration shows a larger coding-agent system Albanese uses for his own work, comparable in purpose to a Cursor background agent. It keeps the workshop’s division of responsibilities: AI SDK supplies the agent, AI Gateway supplies inference, and Workflow supplies durable execution. He describes mapping each LLM step to a durable workflow step, with failed steps retried until they produce a result. That is how his system is designed to support long-running work beyond a single foreground request.
He starts a new session and asks a sub-agent to explore the project. The interface shows background activity while the request runs; hotspot latency and the room’s time limit constrain how much of the system he can show. The important extension is that delegated work has its own execution and context while remaining connected to the parent session.
For the larger system, Albanese reports 23 Vercel users, approximately 3.8 billion tokens over the preceding month or two, and a cache-read ratio of roughly 90–91%. He also reports close to 350 pull requests, noting that the count omits some closed PRs. These closing system-level figures are distinct from the earlier personal-use cache ratio.
Returning to the session demonstrates resumable streams and the result of off-thread exploration. In the closing example, Albanese reports that the sub-agent used about 30,000 tokens and returned roughly 500, leaving the main agent thread at approximately 7,000 tokens. The parent receives a compact result while the exploratory work stays outside its main context. He hopes to release the system later that day; the recording ends with that release still prospective.
Suggest correction
This note stays in this page until you copy or download it. Nothing is submitted; reloading clears the draft.
Resources
From the talk
Explains how asking an agent to hand off starts a new thread with relevant context.
Further reading
An open-source template for cloud agents, with instructions for deploying your own instance on Vercel.
Vercel’s account of simplifying its internal analytics agent around Bash and a documented filesystem.
Describes how d0 combines Slack, permission-aware data access, Sandbox, model calls, and durable workflow steps.
Full transcript
Loading transcript…