0Pricing
AI Engineering Academy · Lesson

Human-in-the-Loop Escalation

Define escalation triggers that pause the agent and request human guidance when confidence is low, when a destructive action is about to occur, or when retry budget is exhausted.

When Agents Need Human Guidance

Fully autonomous agents are appropriate for well-defined, low-risk tasks. But some situations require human judgment: ambiguous instructions, low model confidence, destructive actions that cannot be undone, or tasks where failure has serious consequences. Human-in-the-loop (HITL) escalation pauses the agent at these decision points and requests human input before proceeding, combining the efficiency of automation with the judgment of humans.

Defining Escalation Triggers

Escalation should be triggered by specific, measurable conditions rather than vague intuition. Define explicit escalation triggers for your application. Common triggers include: model confidence below a threshold, a destructive action about to be taken, a policy boundary being approached, the retry budget exhausted, or the task exceeding its time limit. Document triggers in code as named constants so they can be tuned without changing control flow logic.

from enum import Enum

class EscalationReason(Enum):
    LOW_CONFIDENCE = 'low_confidence'           # model uncertainty
    DESTRUCTIVE_ACTION = 'destructive_action'   # irreversible change
    AMBIGUOUS_TASK = 'ambiguous_task'           # unclear instructions
    RETRY_BUDGET_EXHAUSTED = 'retry_exhausted'  # too many failures
    POLICY_BOUNDARY = 'policy_boundary'         # approaching limit
    HUMAN_REQUESTED = 'human_requested'         # explicit request
    TIMEOUT = 'timeout'                         # took too long

ESCALATION_THRESHOLDS = {
    'min_confidence': 0.6,
    'max_retries': 5,
    'max_runtime_minutes': 30,
}

All lessons in this course

  1. Classifying Agent Failure Modes
  2. Self-Correction and Reflective Prompting
  3. Checkpointing and Task Resumption
  4. Human-in-the-Loop Escalation
← Back to AI Engineering Academy