Cookbook · background run
Monitor an incubator overnight
Log temperature and CO₂ every minute for twelve hours, alert if either leaves its band, and hand over a CSV in the morning. The agent starts it and leaves; the run continues on its own.
Instruments
| Role | Simulated twin | Real |
|---|---|---|
| Anything with readable signals | thermocycler-01 (bundled), reading block_temperature | an incubator via PyLabRobot (Cytomat) or OPC UA, a chamber via a PLC, a hotplate via serial, a freezer via a serial thermometer |
What you say
"Watch the incubator overnight. Log temperature and CO₂ every minute and tell me if temperature leaves 36.5 to 37.5 or CO₂ leaves 4.8 to 5.2."
What the agent does
- Finds the recipe
periodic-readingsand the incubator bymhp_find. - Starts it in the background:
mhp_run recipe="periodic-readings" background=true params={"device": "incubator-02", "signals": ["temperature", "co2"], "every_s": 60, "hours": 12, "alert": {"temperature": [36.5, 37.5], "co2": [4.8, 5.2]}} - Tells you the run id and stops. Nothing else is in the agent's context all night.
In the morning
"What happened with the incubator?"
The agent calls mhp_data op="runs", sees the run finished, reads stdout.txt:
ALERT t=14220s co2=4.7 outside 4.8..5.2
720 rows in readings.csv; 1 alert(s)
Then mhp_data op="read" path="readings.csv" for the numbers around the alert, and reports: "CO₂ dipped to 4.7% for about two minutes at 03:57 and recovered; temperature stayed within 36.9 to 37.2 all night. The full log is readings.csv in run 20260910-2201-9f3c."
While it runs
Anything notable also lands in the lab's run log, and if your harness accepts MCP logging messages the events arrive as they happen. mhp_lab op="events" since=0 returns them on demand. You can stop the run early with mhp_job op="cancel" on its job, or pause it to open the door.
Variations
- Multiple devices. Start one run per device; each has its own folder and CSV.
- Act on an alert. Copy the recipe to
~/.openmhp/recipes/and add a write inside the alert branch, for example nudging a setpoint; the write still passes the device's limits. - Longer than a night. Runs are not limited; set
hoursto 72. The CSV is flushed after every row.