In-the-Loop vs On-the-Loop and Escalation
Human-in-the-loop blocks on approval; human-on-the-loop monitors and intervenes; both need escalation paths, SLAs and a defined fallback when nobody answers.
Builds on Guardrails & Security and Workflow Orchestration in the Agentic AI roadmap.
Key points
- HITL blocks before execution; HOTL monitors after execution and needs reversibility.
- Assign modes per risk class and shift them based on evidence.
- Escalation = ordered recipients + SLAs + context to decide.
- Define the no-human fallback per class before launch; default is do-not-execute.
- Parked runs are durable, resumable, and re-validated on resume.
Two oversight modes
In-the-loop (HITL): the agent stops and waits; nothing happens without a human decision. Maximum safety, maximum latency, and it needs a human to be available. Appropriate for class 2–3 actions from Approval Gates and Risk Classes.
On-the-loop (HOTL): the agent acts autonomously; humans watch dashboards, sample traces, and can pause, roll back or take over. Throughput is preserved; safety relies on detection speed and reversibility. Appropriate for class 0–1 actions, and for class 2 once evals and reversal rates justify it.
Most systems mix both by class, and shift actions from HITL to HOTL over time as evidence accumulates — the reverse shift after an incident should be a one-line config change, not a redeploy.
- HITL question: "May I do this?" — answered before execution.
- HOTL question: "Is this going well?" — answered by monitoring after execution (Logging, Metrics and Alerts).
- HOTL is only safe when the action is reversible within the detection window.
Escalation paths
An escalation is a routed request for a human with defined recipients, order and timers. First-line: the user who started the run (they have context and are usually online). Second-line: a team queue (support, ops, finance) with a rota. Third-line: an on-call owner for class 3 actions. Each hop has an SLA — for example 5 minutes, 30 minutes, 2 hours — after which the request moves on.
Escalations must carry enough context to decide without re-reading the transcript: the preview, the risk class, why the agent thinks the action is needed, and what happens if nobody approves. Route by class and domain, not by "whoever is free".
When no human is available
Define the fallback per risk class before launch. The safe default is almost always "do not execute; park the run; notify". For some actions a time-boxed alternative exists: hold the refund and email the customer that it is being reviewed; save the post as a draft; open a ticket instead of deploying. "Auto-approve after timeout" is only acceptable for class 1 and must be explicitly configured, never the default.
Parked runs need a durable store, a resume path and an expiry. A run that resumes three days later may be operating on stale data; re-run the preview and require fresh approval if it changed (Budgets, Limits and Termination).
1type Policy = { chain: { queue: string; slaMs: number }[]; onTimeout: 'reject' | 'park' | 'auto-approve' }2 3const POLICY: Record<number, Policy> = {4 1: { chain: [{ queue: 'requester', slaMs: 5 * 60_000 }], onTimeout: 'auto-approve' },5 2: { chain: [{ queue: 'requester', slaMs: 5 * 60_000 }, { queue: 'support', slaMs: 30 * 60_000 }], onTimeout: 'park' },6 3: { chain: [{ queue: 'requester', slaMs: 5 * 60_000 }, { queue: 'finance', slaMs: 30 * 60_000 }, { queue: 'oncall', slaMs: 2 * 3_600_000 }], onTimeout: 'reject' },7}When to use — and when not to
- Any gated agent that runs outside business hours or across time zones.
- Moving an action from approval to monitoring after evals justify it.
- Post-incident hardening: adding a hop or shortening an SLA.
- Do not use HOTL for irreversible actions — detection after the fact does not help.
- Do not escalate class 1 actions to on-call; that burns the rota's attention.
- Do not set auto-approve on timeout for anything above class 1.
Failure modes
Reference · showHide
- Approval requests to an empty queue; runs silently pile up.
- Auto-approve-on-timeout applied globally "to keep things moving".
- Escalation without context; approver re-reads a 20k-token transcript.
- HOTL dashboards nobody looks at; alerts without owners.
- Resumed run executes on stale preview.
Tradeoffs
Check yourself
Answer out loud or on paper first, then compare. These come from the interview questions linked to this lesson.
An agent works well in demos but fails unpredictably in production. How would you investigate it?
Show a strong answerHide the answer
First make failures observable: per-run traces with every LLM call, tool call, arguments, results, latencies, and token counts, tagged with a run id. Without that, "unpredictable" just means "unobserved". See Tracing Agents and Trace Inspection: Debugging from a Trace. Then sample failing runs and classify them: wrong tool or arguments, tool errors and timeouts, retrieval misses, context overflow, iteration cap hit, injected content, or a correct process with a wrong final judgement.
Demos use curated inputs; production has long messages, typos, multiple intents, unusual document formats, and adversarial content. I compare the input distribution and build a golden set from real failures. Production also introduces infrastructure differences: rate limits and 429s, slower tools causing timeouts, concurrency, stale caches, and different data (an empty result set the demo never hit). See Failure Scenarios: Detection and Runbooks.
Each failure class gets a targeted fix and an eval that would have caught it; I do not touch the prompt until I know which class dominates.
Full interview question, with follow-ups and red flags →How would you prevent an agent from calling a destructive tool incorrectly?
Show a strong answerHide the answer
The prompt is a suggestion, not a control. Controls live in code around the tool. First, schema and validation: the tool takes typed, narrow arguments (a specific resource id, not a free-form query), and the handler validates them against reality before acting, e.g. the id exists and belongs to the current user. See Argument Validation and Tool Schemas.
Second, least privilege: the agent gets a credential scoped to what the task needs; a "summarise tickets" agent has no delete permission at all. Third, an approval gate for irreversible actions: the tool returns a pending action that a human or a deterministic policy confirms, and the confirmation step is outside the model's control. See Tool Permissions and Least Privilege and Approval Gates and Risk Classes.
Fourth, safe execution: idempotency keys so retries cannot repeat the action, dry-run or soft-delete modes, and rate limits on destructive calls. Finally, tracing and alerting on every destructive call so misuse is visible within minutes.
Full interview question, with follow-ups and red flags →You have no tracing in production. What is the first step?
Show a strong answerHide the answer
Add it: run ids, spans per LLM and tool call with inputs, outputs, latency, tokens; sample-based if volume is high; then collect for a week.
Full interview question, with follow-ups and red flags →