AI SDK 6 is SWEET
The Vercel team just announced AI SDK version 6 beta, featuring tool execution approval and a new agent abstraction. Tool execution approval implements the "human in the loop" pattern, letting you approve or deny LLM tool calls before they execute - critical for giving LLMs powerful capabilities like file writing without risking accidental damage. The new agent abstraction splits agent declaration from usage, making agents easier to package and share through registries like ShadCN. Despite being a major version bump, V6 has minimal breaking changes since it's mainly updating the internal langu
Watch on YouTube →Transcript
00:00On stage in San Francisco yesterday, the Vel team announced the ASDK version 6 beta. It comes with a really nice couple of features that I've personally been wanting for a while and it builds on an SDK that is taking the TypeScript world by storm.
00:12If we look at its mpm downloads, a year ago it was at 400,000 and just now it's nearly at 4 million. That is like VIT level growth. Absolutely crazy. I'm pretty invested in it and I've also personally given talks in it. Here I am on stage in Poland and I personally think it's the perfect on-ramp for anyone looking to learn AI if you're a Typescript developer.
00:30The timing is basically ridiculous though because I this week released a version 5 crash course. I genuinely put this out last Wednesday and the following Thursday like what 8 days later they announced V6. Fortunately, it looks like there aren't actually that many breaking changes.
00:48Most of the stuff is additive. So, I am able to pretty safely guarantee that anyone who buys the V5 crash course will get the V6 version for free. And it is only $99 and it really does. It's literally today that it ends. Wow. Yeah. Price goes up in 21 hours.
01:02If you're new here and you don't really know what the ASDK is, let me quickly enlighten you. It basically solves two problems. You've got the LLM here and your backend code, and it builds a bridge between those. And it also builds a bridge between your backend and your front end.
01:15to contact the LLM. You've got a bunch of these different providers here like ASK OpenAI, ASK Google, ASK Anthropic. Then to link your backend to your front end, you've got a bunch of hooks for different frameworks. ASK React, ASK Spelt, ASK View.
01:28This handles the streaming from the back end to the front end. So it's great because you can use any full stack front-end framework and any AI provider just with a single library. So it really cuts down the amount you have to learn. Instead of learning all of these different providers SDKs, you just learn one SDK and you get the whole thing.
01:45Now, I think maintaining the ASDK must be an impossible job because things in these providers change super super quickly. The ADK needs to keep an internal language model specification that basically acts like a compatibility layer with all of these different LLMs.
02:01And so, whenever a provider comes out with a new ability or those LLMs learn to do something new, then the ASDK needs to adapt. And so it seems like version six is not actually that big a version. It's just they've had to update the internal language model specification which changes a couple of very subtle behaviors.
02:18This means then that this release is not expected to have major breaking changes. That's really good. It feels like a small major, not a big major, you know, but let's actually get out of the article and look at some code. The thing I'm really really excited about is a new feature called tool execution approval.
02:32I've got an agent set up with a calculator tool in the back end and I'm going to tell it to divide this big number by 7 using its calculator. So, I'm going to send this off and the agent is going to decide what to do, but it's going to ask me for approval before calling the calculator tool.
02:47We can see I've got a deny or approve button here. Let's hit approve. And then it streamed back for me the answer for what was returned from the tool. This is a pattern called human in the loop and it's absolutely critical for building powerful LLM apps.
03:00You remember when Cursor came out and everyone was running Cursor on YOLO mode, which basically automatically approved every single tool call no matter what it was. Except then, of course, they would get entire directories deleted. They'd lose a ton of work.
03:13Giving the LLM too much power is bad, but giving the LLM not enough power is also bad. An LLM that can't write files or run bash commands is kind of useless as a coding agent. So, what you want is to be able to give the LLM the option to do these things, but to check it before it does it.
03:29The way this looks then is we use this tool call from the AA. You pass it a description and an input schema. In this case, I have add, subtract, multiply, divide in an enum that I'm passing via ZOD. To call the tool, the LLM basically creates an object that matches this schema here and then passes it to an execute function which we have on our back end.
03:48But we've added this needs approval true. And what this does is it prevents executing the tool and until we've given our approval on the front end. This tool is then of course just normally passed to this stream text function down here. And I've added this super small system prompt saying you're an AI assistant that helps with arithmetic calculations.
04:07And I'm using anthropics claude haiku 4.5 on the front end. This is just like a tiny vit application. And I'm using react. We have an approval toolbar component inside here. This grabs all of the messages that have been streamed down so far and checks if they have a state of approval requested.
04:23Then if there are any approvals, then it just renders them as a little toolbar. When we press the approve or deny button here, we can just add approved true or approved false based on deny or approve. And this then goes up and calls a function.
04:36If we go back to root.tsx just up here from use chat and use chat is the primitive exposed by the ak react package up here to allow communicating from the front end to the back end. So we call that add tool approval response function and we also add a property to use chat saying send automatically when I really really like this function.
04:58I have a real soft spot for very very long function names and this one comes from the AI package up here. God look at that thing and it says last assistant message is complete with approval responses. In other words, the last step of the message must have at least one tool approval response and all tool approvals must have a response.
05:14In other words, when we call this function with a response, it will then send automatically. Now you might be thinking this looks like a fair amount of code in order to do something relatively simple but please believe me I have been down the road before of implementing this myself and it is so so painful and complicated.
05:30So having it baked into the framework is really really exciting to me and as a teacher of this stuff it means I can teach it in a freaking beginners's course instead of an advanced course. Now the next big change here is a new agent abstraction which they're kind of triing kind of messing about with the code for it kind of looks like this where you declare let's say a weather agent or we might declare a calculator agent and we say this is a new tool loop agent passing it the model some instructions which I think goes in the system prompt and then some tools.
05:59You can then just call a method on the weather agent to either generate some text or stream some text. Now folks who are familiar with this stuff might go why do we need an extra agent abstraction here? We already have a stream text call which takes in some tools, a system prompt, the initial messages.
06:14And by default, this won't behave like an agent. But if you add a stop when attribute, then you can get it to take multiple steps. In other words, it will call a tool, then react to those tools results. This is exactly what an agent is defined as as well.
06:27You have an LLM call that calls some tools. Those feed back to the LLM call, and you enter a loop. Eventually, the agent decides when to stop. At that point, you stop the program. Or to stop the agent running infinitely, you have a deterministic backs stop like I literally just showed you.
06:42This stop when means that the agent will run until it's reached 10 steps. Or if the agent decides to stop before that, that's fine. So, we've already got this functionality. Why do we need a new agent abstraction when we can just call stream text?
06:54Well, I think there's two theories here. I think the first is to split the agent into two function calls. First, you declare the agent and then you use the agent. This means that it's more natural to have these in separate files. In other words, you have one file for your weather agent and another for your API route where you use the weather agent.
07:12This makes agents easier to package if you're Versel and you have a shad CN registry that you're looking to use and promote. I think the theory in the future is you just be able to grab agents off a registry just like you can grab pre-made components off a registry.
07:27So it totally makes sense that you would want an abstraction where you have separate files for the declaration which is the declaration of the component and the usage of the component. However, what this also lets you do is declare custom agent implementations.
07:39In other words, you can declare a class which implements the agent interface which potentially lets you build really complicated things that just implement a relatively simple interface which means again easier sharability, easier portability.
07:53Now, I was really interested in testing this out, but when I tried this locally, it just sort of didn't work. For instance, here I have a class custom agent implements agent. But when I go to add a method here, like uh for instance, stream like this, I end up with this really gnarly type because I don't think the underlying type is exported.
08:10And the migration guide doesn't really give you that many details on how to do this yourself. So, a bit of a let down for me because I was really looking forward to experimenting with this. And honestly, that's basically it. You know, like the migration from V5 is expected to have minimal breaking changes.
08:23So, despite the big announcement and all the fanfare, this is a pretty small addition except for the fact it adds something I've wanted for so long, which is this tool execution approval. So, for me, I give this release a 6 out of 10. How about that?
08:37Ak 6. I'm looking forward to seeing how the custom agent implementations develop, but needs approval gets the approval from me. Now, if you want to go deeper into the AADK, if what I have mentioned here has wetted your appetite, then the first two sections of my crash course are totally free.
08:50That is 15 lessons on the ASDK and how it ties into LLM fundamentals like tokens and context window and caching. And if you like that and you want the whole thing, then it is $99 for I don't know another 20 hours or so. Thank you so much for following along.
09:03Happy V6 beta day and I will see you very soon.