Advanced~20 minHazelJS
HITL, Policies, and Contracts
Journey B: requiresApproval, durableSuspend, AGENT_OS_HITL=1, approvals API, and stub vs real anti-confusion.
- Authors
- editorial-team
- Published
- Last reviewed
- Turn HITL on and approve a refund
- Name PolicyEngine vs prompt-only safety
- Explain why CLI smoke cannot prove a refund
On this page
Journey B — Safety
Write tools need approval (F7–F8)
Meridian marks irreversible tools with requiresApproval: true (e.g. processRefund, freezeAccount) and runs with durableSuspend so the worker can pause without holding the HTTP request open forever.
Deep-dive: /guides/add-human-approval-without-breaking-the-run, /patterns/human-approval-gate.
Lab — refund with HITL off, then on
Default (auto-approve):
# AGENT_OS_HITL=0 (default)
curl -s localhost:3060/api/support/chat \
-H 'content-type: application/json' \
-d '{"message":"I want a refund for ORD-1002"}' | jq .
Real HITL:
- Set
AGENT_OS_HITL=1in.env, restartnpm run dev. - Send the refund curl again — expect a pending approval / suspended run.
- Approve:
curl -s -X POST localhost:3060/api/approvals/<requestId>/approve | jq .
Policies and contracts (F8–F9)
PolicyEngine encodes require_approval / deny beyond prompt hope (src/agents/agents.module.ts). Support paths can fall back to safe-desk under contract/recovery options when the primary path fails — degrade safely.
Digital twin / canary (F10) exists for shadow compare before cutover — overview only here; use when promoting risky prompt/DNA changes.
Anti-confusion (repeat until boring)
| Path | What it is |
|---|---|
hazel agent run / demo:smoke-cli | DNA bootstrap + stub tools |
POST /api/support/chat | Real @Tool handlers + commerce store |
platform:sync | Desired state files — not execute |
npm run demo:smoke-cli # F6 — see the contrast explicitly
Checkpoint D
You can explain why CLI smoke must never be used to “prove” a refund worked.
Artifact: Checkpoint D: HITL refund pause/resume + anti-confusion table
Sources
- Meridian Ops README — hazeljs-meridian-ops/README.md — mental model + quick start
- Meridian TOUR.md — F1–F22 curl walkthrough
- Flagship project plan (21) — docs/agent-os/21-flagship-project-plan.md
- HazelJS Agent OS guide
- HazelJS Agent package