> ## Documentation Index
> Fetch the complete documentation index at: https://docs.cruq.ai/llms.txt
> Use this file to discover all available pages before exploring further.

# Demo: cold-chain operations

> An agent that watches fridges and reefer trucks, follows the SOPs, fixes what it can, and asks a person before it touches anything physical.

<iframe width="100%" height="420" src="https://www.youtube.com/embed/-G2IpXQDOPA" title="Cruq cold-chain demo" frameborder="0" allow="accelerometer; autoplay; clipboard-write; encrypted-media; gyroscope; picture-in-picture" allowfullscreen />

Meridian Foods is a fictional food distributor in the UAE with two chilled
warehouses, 20 fridge units, six reefer trucks and a day's worth of deliveries.
In the demo a compressor fails on a frozen unit. Within one cycle the agent
opens a maintenance ticket, pages the site engineer, tries to hold the orders
whose stock is in that unit, and then stops to ask the duty manager whether it
may quarantine the unit. The manager answers from Monitoring, the run resumes,
and the fridge locks.

Nothing in the loop is special-cased. It is a normal Cruq agent with a
knowledge base, an MCP tool and a pause tool, running on a schedule.

## What is in it

| Piece            | What it does                                                                                                                                                                                                                    |
| ---------------- | ------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------- |
| Simulator        | A small service with the warehouses, fridges, trucks, forklifts, orders and engineers. It ticks once a simulated minute, derives alerts from the sensors, and exposes actuators. A status page shows the map and the units.     |
| MCP tool         | The simulator as an MCP server: 17 tools such as `get_overview`, `list_alerts`, `get_fridge`, `hold_order`, `lock_fridge`, `reroute_truck`, `create_ticket`, `page_engineer`. Every write is logged with the agent's thread id. |
| Knowledge base   | Six SOPs: temperature bands and excursion limits, the escalation ladder, quarantine, truck delays, doors and power cuts, and the monitoring cycle.                                                                              |
| Cold-Chain Watch | The operations agent. Reads the overview and alerts, takes the safe actions itself, and calls `ask_human` before anything physical. Runs hourly on a schedule and on demand.                                                    |
| Dispatch         | Trucks, delays, reroute proposals that serve chilled and frozen stops first, and customer delay notices.                                                                                                                        |
| Field Assistant  | For staff and drivers. Checks the live reading, explains the procedure, logs a ticket. Published as a hosted app.                                                                                                               |
| Evals            | Eight tabletop situations scored on whether the agent follows the escalation ladder, run across three models.                                                                                                                   |

## The escalation ladder

The rules live in the knowledge base and, in short form, in the agent's
instructions.

* **Level 1, the agent acts:** acknowledge an alert, open one ticket per
  incident, correct a wrong setpoint, hold an order that has not left the
  warehouse, page an engineer during working hours.
* **Level 2, the agent asks first:** lock a fridge (quarantine), reroute a
  truck, page an engineer at night. The question carries the unit, the reading
  and how long it has been out of band, the stock at risk and its value, what
  the agent will do, and what happens if nothing is done.
* **Level 3, the agent only recommends:** destroy stock, recall a loaded truck,
  stop a site.

The pause is the `ask_human` tool. The run checkpoints, shows as paused in
Monitoring with the question, and continues from the same state when someone
answers. See [long-running agents](/docs/concepts/long-running-agents).

## Eval results

The suite gives the agent situations like "compressor stopped 20 minutes ago,
now -12 C and rising, two orders still picking" and scores the answer against
the ladder. Same prompt, same tools, three models:

| Model            | Score | Latency | Cost for the suite |
| ---------------- | ----- | ------- | ------------------ |
| claude-haiku-4.5 | 0.97  | 4.1 s   | \$0.037            |
| gpt-4.1-mini     | 0.94  | 3.2 s   | \$0.005            |
| gpt-4o-mini      | 0.75  | 2.3 s   | \$0.002            |

The cheapest model skipped escalations it should have made, so the agent runs
on gpt-4.1-mini. That is the decision evals are for: see
[Evals](/docs/concepts/evals).

## Run it yourself

The simulator has a director endpoint for scripting incidents. With its API
key:

```bash theme={null}
IOT_URL=https://iot.cruq.ai
curl -X POST $IOT_URL/api/director/incident \
  -H "Authorization: Bearer $IOT_API_KEY" -H "Content-Type: application/json" \
  -d '{"type":"compressor_failure","target":"DIP-F03"}'
curl -X POST $IOT_URL/api/director/tick \
  -H "Authorization: Bearer $IOT_API_KEY" -H "Content-Type: application/json" \
  -d '{"minutes":25}'
```

Then run Cold-Chain Watch with "Check the cold chain now.", answer its question
in Monitoring, and watch the status page at `$IOT_URL` flip the unit to locked.
Other incidents: `door_left_open`, `truck_traffic` (with `minutes`),
`reefer_fault`, `power_cut` (target `dip` or `mussafah`), `forklift_low`.
`POST /api/director/reset` starts a fresh day.

## Build your own

The pattern transfers to anything with sensors and actuators: a plant, a fleet,
a building, a lab. Expose the world as an MCP server, write the procedures as
knowledge, give the agent an `ask_human` tool, and put the physical actions
behind it. The simulator's source is in `apps/iot-sim` of the Cruq repository
and is a reasonable template for a stand-in world while the real integration is
being built.
