Step 3 · Page tools
Let the agent call your page.
Page tools run in the browser with no round trip. The model chooses the arguments, so validate every one and authorize on your backend.
agent.setPageTools([
{
name: "open_invoice",
description: "Open one of the user's invoices.",
jsonSchema: {
type: "object",
properties: { invoiceId: { type: "string" } },
required: ["invoiceId"],
},
execute: async ({ invoiceId }) => {
if (!/^inv_[a-z0-9]+$/.test(invoiceId)) return "Invalid ID.";
const r = await fetch(`/api/invoices/${invoiceId}`);
if (!r.ok) throw new Error("Can't open that invoice.");
location.hash = `#/invoices/${invoiceId}`;
return { opened: invoiceId };
},
},
]);
agent.setSituationalAwareness({ invoiceId: "inv_4471" });Speaker notes
setPageTools, setSituationalAwareness and setPassthroughParams each replace their whole set and are read fresh every turn. Passthrough params reach a tool without the model ever seeing them. The SDK only checks required arguments are present; types and formats are yours to validate. Mindset can’t re-authorize a page tool, because it runs in your page: put nothing behind one unless your backend checks the user’s permission.