Stop an AI agent from writing bad inventory data
An AI agent receives a supplier payload. Before it updates inventory, validate the shape and business constraints. Try an invalid quantity, then correct it to see the difference.
1. Incoming agent payload
Contract: object with a nonempty SKU and a finite, nonnegative integer quantity. Unexpected fields are rejected.
2. Validation outcome
3. Simulated destination
Blocked payloads never reach the simulated write function. This is a teaching example, not a guarantee of real-world safety.
How the guarded workflow works
Reject missing fields, unexpected keys, incorrect types and malformed JSON.
Require a nonnegative integer quantity before an inventory update is considered.
In production, validate and authorize on the server, then apply a durable idempotency key at the destination.
Minimal JavaScript validation example
This self-contained illustration shows the local validation logic. It is not a substitute for Zorqelio's server-side guarded handoff API.
function validateInventory(data) {
if (!data || typeof data !== "object" || Array.isArray(data))
return "Expected an object";
if (Object.keys(data).sort().join(",") !== "quantity,sku")
return "Expected only sku and quantity";
if (typeof data.sku !== "string" || !data.sku.trim())
return "SKU must be a nonempty string";
if (!Number.isSafeInteger(data.quantity) || data.quantity < 0)
return "Quantity must be a nonnegative safe integer";
return null;
}
const error = validateInventory(agentPayload);
if (error) throw new Error("Blocked: " + error);
// Production: obtain server-side authorization before writing.
Use this in a real integration
The production Zorqelio flow adds versioned data contracts, quality policies, authenticated authorization, short-lived handoffs and an idempotent destination callback. It cannot guarantee the truth of external data or stop writes that bypass your enforcement point.
Read guarded handoffs documentation · Inventory integration guide · Connect an MCP client · JSON validation playground
Building a tutorial or teaching agent safety? You may link to this interactive example and describe its limitations accurately.