Walkthrough
1. Define a narrow tool
Accept a validated SKU and return only what the agent needs.
2. Put an approval gate before writes
Have the user confirm the intent and let the server recheck authorization and inventory.
3. Evaluate the workflow
Test ambiguous requests, stale data, missing permissions and injected instructions.
Worked example
An inventory agent may read stock. Creating an order goes through a different endpoint that checks confirmation and the customer’s permissions.
type LookupStock = { sku: string };
type StockResult = { sku: string; available: boolean };
// Validate the SKU and caller before querying inventory.Show another code example
if (!confirmation || !canCreateOrder(session, cart)) {
throw new Error("Confirmation or permission missing");
}
return createOrder(cart, idempotencyKey);