UI はローカライズ済みです。スキルの紹介と説明文書は選択した言語へ AI が自動翻訳し、コード・コマンド・パス・専門用語は原文のままです。原作者の文書が優先されます。
スキルを探す
デザイン · SKILL.md

human-in-the-loop-ai

human-in-the-loop-ai

Design AI systems with human oversight checkpoints, approval workflows, and escalation mechanisms. Covers when to require human intervention, how to build approval queues, confidence thresholds, and compliance-aware AI decision making.

Independent GitHub snapshot · Automated classification · Original documentation governs

スキルの説明

GitHub

name: human-in-the-loop-ai description: "Design AI systems with human oversight checkpoints, approval workflows, and escalation mechanisms. Covers when to require human intervention, how to build approval queues, confidence thresholds, and compliance-aware AI decision making." license: Apache 2.0 tags: ["hitl", "human-oversight", "ai-safety", "approval-workflows", "compliance", "agentic-ai"] difficulty: advanced time_to_master: "8-14 weeks" version: "1.0.0"

Human-in-the-Loop AI

Overview

Human-in-the-Loop (HITL) AI systems incorporate human judgment at critical decision points within automated workflows. As AI agents gain the ability to take real-world actions — sending emails, processing payments, modifying records — HITL patterns become essential for safety, compliance, and trust.

When to Use This Skill

  • Building AI agents that take irreversible actions (payments, deletions, communications)
  • Implementing compliance requirements for regulated industries (finance, healthcare, legal)
  • Designing confidence-based escalation from AI to human reviewers
  • Creating approval queues for AI-generated content or decisions
  • Building feedback loops for continuous AI improvement

Core Concepts

HITL Decision Framework

┌─────────────────────────────────────────────────┐
│                  AI Action                       │
├─────────────────────────────────────────────────┤
│                                                  │
│  Low Risk + High Confidence ──► Auto-execute     │
│  Low Risk + Low Confidence  ──► Auto + Log       │
│  High Risk + High Confidence──► Request Approval │
│  High Risk + Low Confidence ──► Escalate + Block │
│                                                  │
└─────────────────────────────────────────────────┘

Action Classification Matrix

Action TypeRisk LevelHITL Required?Example
Read dataNoneNoQuery database, fetch API
Format/transformNoneNoGenerate report, summarize
Send notificationLowOptionalSlack message, email alert
Modify recordMediumRecommendedUpdate CRM, edit document
Financial transactionHighRequiredProcess payment, refund
External comms (customer)HighRequiredSend client email
Delete/destroyCriticalRequiredDelete records, cancel subscription
Access escalationCriticalRequiredGrant permissions

Approval Flow Architecture

User Request
     │
     ▼
┌──────────┐     ┌──────────────┐     ┌──────────┐
│ AI Agent │────►│ Risk Assessor│────►│ Executor │
│ (Plans)  │     │ (Classifies) │     │ (Acts)   │
└──────────┘     └──────┬───────┘     └──────────┘
                        │                    ▲
                   High Risk?                │
                        │Yes                 │
                        ▼                    │
                 ┌─────────────┐     ┌──────┴──────┐
                 │  Approval   │────►│  Decision   │
                 │   Queue     │     │  (Approve/  │
                 │             │     │   Reject)   │
                 └─────────────┘     └─────────────┘

Implementation Guide

Confidence Thresholds

class ConfidenceRouter:
    """Route AI decisions based on confidence and risk."""

    THRESHOLDS = {
        "auto_execute": 0.95,   # High confidence, auto-proceed
        "soft_review": 0.80,    # Execute but flag for review
        "approval_required": 0.60,  # Queue for human approval
        "block": 0.0,           # Below 0.60, block entirely
    }

    def route(self, action, confidence, risk_level):
        if risk_level == "critical":
            return "approval_required"  # Always require approval

        if confidence >= self.THRESHOLDS["auto_execute"]:
            return "auto_execute"
        elif confidence >= self.THRESHOLDS["soft_review"]:
            return "soft_review" if risk_level == "low" else "approval_required"
        elif confidence >= self.THRESHOLDS["approval_required"]:
            return "approval_required"
        else:
            return "block"

Approval Queue System

interface ApprovalRequest {
  id: string;
  agentId: string;
  action: string;
  details: Record<string, unknown>;
  riskLevel: "low" | "medium" | "high" | "critical";
  confidence: number;
  createdAt: string;
  expiresAt: string;
  status: "pending" | "approved" | "rejected" | "expired";
}

class ApprovalQueue {
  async submit(request: Omit<ApprovalRequest, "id" | "status">): Promise<ApprovalRequest> {
    const approval: ApprovalRequest = {
      ...request,
      id: crypto.randomUUID(),
      status: "pending",
    };
    await this.store.save(approval);
    await this.notify(approval);  // Slack, email, dashboard
    return approval;
  }

  async waitForDecision(id: string, timeoutMs = 300000): Promise<Decision> {
    const deadline = Date.now() + timeoutMs;
    while (Date.now() < deadline) {
      const approval = await this.store.get(id);
      if (approval.status !== "pending") {
        return {
          approved: approval.status === "approved",
          approver: approval.reviewedBy,
          reason: approval.reviewNote,
        };
      }
      await sleep(1000);
    }
    // Auto-expire if no response
    await this.store.update(id, { status: "expired" });
    return { approved: false, reason: "Approval request expired" };
  }
}

Feedback Loop Integration

class HITLFeedbackLoop:
    """Capture human decisions to improve future AI confidence."""

    def record_decision(self, request_id, ai_recommendation, human_decision):
        self.feedback_store.append({
            "request_id": request_id,
            "ai_said": ai_recommendation,
            "human_said": human_decision,
            "agreed": ai_recommendation == human_decision,
            "timestamp": datetime.utcnow().isoformat(),
        })

    def get_accuracy_stats(self, action_type, window_days=30):
        """Track how often AI recommendations match human decisions."""
        recent = self.feedback_store.query(
            action_type=action_type,
            since=datetime.utcnow() - timedelta(days=window_days),
        )
        agreed = sum(1 for r in recent if r["agreed"])
        return {
            "total_reviews": len(recent),
            "agreement_rate": agreed / len(recent) if recent else 0,
            "can_auto_approve": (agreed / len(recent)) > 0.95 if len(recent) > 50 else False,
        }

Best Practices

  1. Default to requiring approval for new action types — relax as trust builds
  2. Set timeouts on approval requests — stale approvals should expire, not block forever
  3. Log everything — every approval, rejection, and auto-execution for audit trails
  4. Provide context to reviewers — show what the AI saw and why it made its recommendation
  5. Build escalation paths — if a reviewer is unavailable, route to backup
  6. Never bypass HITL for compliance-required actions — even if confidence is 100%
  7. Make approvals async — don't block users waiting for approvals; notify when decided

Resources

Changelog

VersionDateChanges
1.0.02026-03-31Initial documentation
保存したスキル