Tools and Human Approval
A model can ask your code to do things: look up an order, cancel it. Show every step, ask the person before anything that cannot be undone, and never trust the browser.
Until now Mitra only talked. In this phase it starts to act. A model cannot look at your orders table or cancel an order by itself. What it can do is write a small request, "please run lookupOrder with ORD-1042", and your code decides whether to run it. That request-and-answer cycle is called tool calling. This phase is about the frontend half of it: what the screen shows while a tool runs, how a tool call arrives in the browser, and how to put a person in charge of anything that matters.
You will learn the real shapes the Vercel AI SDK uses: how to define a tool, the states a tool call moves through (input-streaming, input-available, output-available, output-error, and the approval states), tools that run in the browser, and human approval, where the server pauses a tool until the person says yes. You will also see what goes wrong: bad input from the model, a tool that throws, a loop that never ends, an approval nobody answers, a browser that lies.
Everything runs live against a scripted stand-in model, with the real AI SDK. By the end, Mitra can look up an order for anyone, and cancel one only after the customer has read exactly what will happen and pressed Yes. How a model decides which tool to call is taught in /llm-engineering. Hostile text that tries to steer the model is the subject of Phase 9, and Phase 8 already shows the defence that does not depend on the model behaving: the approval gate.
Practise this phase
Hands-on exercises: write the code, see your page live, and press Check to have it tested automatically.