Loading...
Loading...
A hybrid pattern where the system pauses execution to request human approval, input, or disambiguation before proceeding with critical actions. Use when user asks to "add human approval", "require human review", "human-in-the-loop", or mentions approval workflows, human oversight, or escalation.
npx skill4agent add lauraflorentin/skills-marketplace human-in-the-loopdef hitl_workflow(user_request):
# Step 1: Plan/Draft
plan = agent.create_plan(user_request)
# Step 2: Risk Assessment
if is_high_risk(plan):
# Step 3: Pause for Approval
# Send notification to user UI
approval = notify_user(
message="Agent wants to execute the following plan:",
payload=plan
)
if approval.status == "REJECTED":
return "Action cancelled by user."
elif approval.status == "EDITED":
plan = approval.new_plan
# Step 4: Execute
return agent.execute(plan)def send_email_with_approval(draft):
# Present draft to human
approval = review_queue.submit({
"type": "email_approval",
"content": draft,
"timeout_hours": 4
})
if approval.status == "approved":
email_client.send(draft)
elif approval.status == "rejected":
agent.revise(draft, feedback=approval.comment)
else: # timeout
escalate_to_manager(draft)| Problem | Cause | Fix |
|---|---|---|
| Humans are a bottleneck | Too many approval requests | Raise the automation threshold; only require approval above risk score 0.8 |
| Agent waits indefinitely | No timeout configured | Set approval timeout; define auto-escalation path on timeout |
| Reviewer lacks context | UI shows only the action | Include full context: why the agent wants to take this action |
| Feedback loop never closes | No mechanism to learn from rejections | Log rejection reasons; update agent guidelines after 10+ similar rejections |