Examples
OpenClaw Integration
Overview
OpenClaw handles delivery and replies across messaging channels, while Loop Engine owns state transitions, actor constraints, and guard decisions.
Approval gates are runtime policy checks, not prompt conventions. Even if an agent asks to self-approve, a transition with allowedActors: ['human'] rejects non-human actors.
Architecture
1User (WhatsApp)2 |3 | "approve rpl-001"4 v5OpenClaw Gateway ------------------------------------.6 | |7 | engine.transition('approve', humanActor) |8 v |9Loop Engine |10 | |11 |- guard: approval_obtained ✅ |12 |- allowedActors: ['human'] ✅ |13 v |14PENDING_BUYER_APPROVAL -> PO_TRIGGERED |15 | |16 '--- loop.transitioned --------------------------'17 "✅ Approved. Loop closed."Using @loop-engine/adapter-openclaw
1import { createLoopSystem } from '@loop-engine/sdk'2import { OpenClawEventBus } from '@loop-engine/adapter-openclaw'3import { replenishmentLoop } from './loops/replenishment'4 5const eventBus = new OpenClawEventBus({6 channel: 'whatsapp',7 target: '+15551234567',8 events: ['loop.transition.executed', 'loop.completed', 'loop.guard.failed'],9 approvalStates: ['PENDING_BUYER_APPROVAL']10})11 12const system = await createLoopSystem({13 loops: [replenishmentLoop],14 eventBus15})The approval flow
- Demand spike detection starts the loop with
loop.started. - The AI analysis transition moves from
AI_ANALYSIStoPENDING_BUYER_APPROVAL. - OpenClaw receives forwarded loop events and sends:
⚠️ Approval required: rpl-dc-east-001 ... Reply: approve rpl-dc-east-001 | reject rpl-dc-east-001. - A buyer replies
approve rpl-dc-east-001from a phone. - The OpenClaw skill calls
engine.transitionwith a human actor. approval_obtainedpasses and the loop advances toPO_TRIGGERED.- OpenClaw sends
✅ Approved. Loop advanced to: PO_TRIGGERED.
Why guards beat prompts
allowedActors and guard evaluation happen in the runtime transition engine, not in the language model output path. That keeps approval logic deterministic and testable.
Prompt injection can change model text, but it cannot bypass transition authorization or guard failures. This is the security boundary for agentic operations.
Installing the OpenClaw skill
1git clone https:"cmt">//github.com/loopengine/loop-examples2cp -r loop-examples/openclaw-skill ~/.openclaw/skills/loop-engineThe skill supports:
start loop [loop-id]transition [instance-id] [transition-id]approve [instance-id]reject [instance-id]status [instance-id]list loops
Source: loop-examples/openclaw-skill