Human Escalation
Human escalation is the safety net for situations the agent cannot handle autonomously. A well-designed escalation path ensures humans can take over quickly and with full context.
8 min•By Priygop Team•Updated 2026
When to Escalate
- Max retries exceeded: the tool failed too many times to continue
- All fallbacks exhausted: no alternative approach worked
- High-risk action: the agent proposes an action above an approved threshold
- Low confidence: the agent is uncertain about the correct course of action
- Contradictory information: different tools or sources returned conflicting data
- Loop detected: the agent is stuck in a repeated pattern
- Permission denied: the agent attempted an action it is not authorised to take
Escalation Package
Escalation Package
# Create a complete escalation package for human review
from datetime import datetime
def create_escalation(
task_id: str,
goal: str,
reason: str,
agent_state: dict,
recommended_action: str = None
) -> dict:
"""
Create a complete escalation package for human review.
Includes everything the human needs to understand and continue the task.
"""
history = agent_state.get("history", [])
return {
"escalation_id": f"ESC-{datetime.now().strftime('%Y%m%d-%H%M%S')}",
"created_at": datetime.now().isoformat(),
"task_id": task_id,
"priority": "high" if "permission" in reason.lower() else "normal",
# What was being attempted
"goal": goal,
"escalation_reason": reason,
# How far the agent got
"steps_completed": len(history),
"last_action": history[-1] if history else None,
"last_error": agent_state.get("last_error"),
# What the human needs to decide
"recommended_action": recommended_action or "Review the error and decide next steps",
# Context for the human
"data_collected": agent_state.get("data", {}),
"errors_encountered": agent_state.get("errors", []),
# Contact
"notify_channel": "slack:#ai-agent-alerts",
"assigned_to": "on_call_engineer@example.com",
}
state = {
"history": [{"action": "get_order"}, {"action": "issue_refund"}],
"last_error": {"error_type": "permission", "error": "Refund limit exceeded"},
"data": {"order_id": "ORD-123", "order_total": 1500.00},
"errors": [{"step": 2, "error": "Refund limit exceeded"}]
}
pkg = create_escalation(
task_id="TASK-001",
goal="Issue refund for ORD-123",
reason="Refund amount ($1500) exceeds agent limit ($500) — manager approval needed",
agent_state=state,
recommended_action="Approve or reject the refund for ORD-123 ($1500)"
)
print(f"Escalation ID: {pkg['escalation_id']}")
print(f"Priority: {pkg['priority']}")
print(f"Reason: {pkg['escalation_reason']}")
print(f"Recommended action: {pkg['recommended_action']}")Key Takeaways
- Human escalation is the safety net for situations the agent cannot handle autonomously.
- Max retries exceeded: the tool failed too many times to continue
- All fallbacks exhausted: no alternative approach worked
- High-risk action: the agent proposes an action above an approved threshold