ACAgentic Craft

Part 4 of 8 · Design a Production Agent Runtime

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

You will leave with

  • 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):

bash
# 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:

  1. Set AGENT_OS_HITL=1 in .env, restart npm run dev.
  2. Send the refund curl again — expect a pending approval / suspended run.
  3. Approve:
bash
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)

PathWhat it is
hazel agent run / demo:smoke-cliDNA bootstrap + stub tools
POST /api/support/chatReal @Tool handlers + commerce store
platform:syncDesired state files — not execute
bash
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 READMEhazeljs-meridian-ops/README.md — mental model + quick start
  • Meridian TOUR.mdF1–F22 curl walkthrough
  • Flagship project plan (21)docs/agent-os/21-flagship-project-plan.md
  • HazelJS Agent OS guide
  • HazelJS Agent package

Continue