Zorqelio
FREE INTERACTIVE DEVELOPER EXAMPLE

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.

Browser-only simulation: This example runs locally in your browser. It does not call Zorqelio APIs, change a real inventory system, or demonstrate production authorization. For real guarded handoffs, use the authenticated server-side workflow described in the documentation.

1. Incoming agent payload

Contract: object with a nonempty SKU and a finite, nonnegative integer quantity. Unexpected fields are rejected.

2. Validation outcome

Run the example to see whether the write is blocked.

3. Simulated destination

Inventory: empty (no write performed)

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

1. Check the contract

Reject missing fields, unexpected keys, incorrect types and malformed JSON.

2. Enforce policy

Require a nonnegative integer quantity before an inventory update is considered.

3. Authorize the write

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.