Designs human-in-the-loop systems for AI agents with approval gates, confidence-based escalation, and correction loops. Useful when agent actions are irreversible, costly, or require regulatory compliance.
Ships in claude-skills-collection. Installing the plugin adds it to Claude Code.
What the skill costs in Claude's context, stage by stage
Name and description: Claude knows it exists.
SKILL.md joins the conversation and stays.
None: SKILL.md is the whole skill.
Intègre un point de contrôle humain dès qu'une action de l'agent est :
Parcours le workflow de l'agent, identifie chaque nœud d'action, et classe-le :
| Catégorie | Exemples | Mode HITL recommandé |
|---|---|---|
| Irréversible + haut risque | Suppression DB, virement, envoi en masse | approval gate systématique |
| Réversible + impact modéré | Brouillon d'email, mise à jour de ticket | exception escalation (si doute) |
| Basse criticité, haute fréquence | Catégorisation, tagging, résumé | shadow mode puis autonomie progressive |
| Obligation légale | Signature, validation KYC | approval gate systématique + audit trail |
approval gate — bloquer jusqu'à approbation explicite# LangGraph interrupt pattern (SDK 0.2+)
from langgraph.types import interrupt, Command
def human_approval_node(state: AgentState):
payload = {
"action": state["proposed_action"],
"context": state["context"],
"risk_level": state["risk_level"],
"estimated_impact": state["impact_summary"],
}
decision = interrupt(payload) # suspend le graph, reprend après résumption
if decision["approved"]:
return {"approved_action": state["proposed_action"]}
return {"approved_action": decision.get("correction", "__abort__")}
confidence threshold — escalade automatique selon le scoreHIGH_RISK_THRESHOLD = 0.7 # ex : coût normalisé 0..1
CONFIDENCE_THRESHOLD = 0.82 # calibrer empiriquement
def should_escalate(task: Task, confidence: float) -> bool:
risk = task.estimated_cost_normalized * (1 - task.reversibility)
return risk > HIGH_RISK_THRESHOLD or confidence < CONFIDENCE_THRESHOLD
correction loop — l'agent propose, l'humain corrige, l'agent continuedef apply_human_correction(agent_output: str, correction: str, task_id: str) -> str:
feedback_store.save({
"task_id": task_id,
"agent_output": agent_output,
"human_correction": correction,
"ts": datetime.utcnow().isoformat(),
})
return correction # l'agent continue avec la version validée
exception escalation — l'agent agit seul, escalade uniquement sur cas limitetry:
result = agent.execute(task)
except UncertaintyException as e:
notify_human(task, e.reason)
result = await wait_for_human_decision(task.id, timeout_s=3600)
shadow mode — recommandation sans exécution, pour établir la confianceif phase == "shadow":
log_recommendation(agent_output)
return human_decides(task) # humain garde la main
elif phase == "supervised":
return approval_gate(agent_output)
else:
return agent_output # autonomie établie
Règle d'or : l'humain ne doit pas chercher l'information, elle doit lui être livrée.
Structure d'une notification HITL minimale :
[HITL] Action requérant approbation
Agent : payment-agent v2.1
Action : Virement 4 850 € → IBAN FR76...3421
Déclencheur : Facture #INV-2026-0789 (PDF joint)
Risque : ÉLEVÉ — irréversible sous 10 min
Contexte : Client Acme Corp, contrat C-4421 actif
Impact : Solde après opération : 12 340 €
[Approuver ✓] [Corriger ✎] [Rejeter ✗]
Expire dans : 47 min
Checklist UX :
# Utilise slack_sdk + Block Kit
blocks = [
{"type": "section", "text": {"type": "mrkdwn", "text": f"*Action* : {action_summary}"}},
{"type": "actions", "elements": [
{"type": "button", "text": {"type": "plain_text", "text": "Approuver"}, "value": "approve", "style": "primary"},
{"type": "button", "text": {"type": "plain_text", "text": "Rejeter"}, "value": "reject", "style": "danger"},
]},
]
client.chat_postMessage(channel=APPROVER_CHANNEL, blocks=blocks, text=action_summary)
token = secrets.token_urlsafe(32)
redis.setex(f"hitl:{token}", 3600, json.dumps({"task_id": task_id, "action": action}))
approve_url = f"https://app.example.com/hitl/approve?token={token}"
reject_url = f"https://app.example.com/hitl/reject?token={token}"
send_email(approver_email, subject="[Action requise]", body=render_template(approve_url, reject_url))
# L'agent POST une demande et attend un callback
response = requests.post("/api/hitl/requests", json={
"task_id": task_id, "action": action, "callback_url": f"{BASE_URL}/resume/{task_id}"
})
# Le endpoint /resume/{task_id} reprend le graph suspendu
async def wait_for_decision(task_id: str, timeout_s: int = 1800) -> Decision:
try:
return await asyncio.wait_for(decision_queue.get(task_id), timeout=timeout_s)
except asyncio.TimeoutError:
match TIMEOUT_POLICY:
case "safe_default": return Decision(approved=False, reason="timeout")
case "escalate_up": return await notify_supervisor(task_id)
case "abort": raise AgentAbortError(f"HITL timeout for {task_id}")
Politiques de timeout recommandées selon l'urgence :
| Urgence | Timeout | Politique |
|---|---|---|
| Critique (paiement) | 30 min | escalate_up |
| Modérée (email) | 4 h | safe_default (ne pas envoyer) |
| Faible (rapport) | 24 h | abort + log |
Chaque décision HITL doit produire un enregistrement immuable :
@dataclass
class HITLAuditRecord:
task_id: str
agent_version: str
proposed_action: str
decision: Literal["approved", "rejected", "corrected", "timeout"]
corrected_action: str | None
approver_id: str
approver_comment: str | None
ts_requested: datetime
ts_decided: datetime
workflow_outcome: str # ce qui s'est passé ensuite
Stocke dans un log append-only (ex : fichier JSONL, table SQL INSERT-only, Kafka topic).
| Métrique | Formule | Signal d'alerte |
|---|---|---|
approval_rate | approbations / total | < 70 % → agent se dégrade |
correction_rate | corrections / escalades | > 30 % → seuils trop bas |
escalation_rate | escalades / actions totales | > 20 % → faux positifs, coût humain élevé |
human_response_time | médiane ts_decided - ts_requested | > SLA → revoir le canal |
false_positive_rate | escalades approuvées sans correction | > 50 % → relâcher les seuils |
Automatise un rapport hebdomadaire pour calibrer les seuils CONFIDENCE_THRESHOLD et HIGH_RISK_THRESHOLD.
sleep ou input().What SKILL.md sets; muted values are Claude Code's defaults
Three short reads, in order
/claude-skills-collection:agent-human-in-the-loop-designerfrom claude-skills-collection
npx claudepluginhub vantaflow/claude-skills-collection --plugin claude-skills-collection348 skills in this plugin
/agent-a2a-protocol-guideGuide du protocole Agent-to-Agent (A2A) de Google pour l'interopérabilité entre agents IA — découverte, communication et collaboration inter-agents, avec exemples de code, critères de décision et pièges à éviter. Se déclenche avec "A2A", "agent-to-agent", "protocole A2A", "Google A2A", "interopérabilité agents". Also triggers on "agent-to-agent protocol", "agent interoperability", "connect two agents"./agent-agent-observabilityInstrumentation technique d'un agent IA — tracing distribué des appels LLM et outils, spans, métriques custom, corrélation de logs et dashboards de supervision. Pour les alertes et garde-fous de production, voir agent-monitoring-setup. Se déclenche avec "observabilité agent", "tracing agent", "LangSmith", "Langfuse", "OpenTelemetry agent", "spans LLM", "corréler les logs agent". Also triggers on "trace my agent", "LLM tracing", "agent spans"./agent-api-caller-subagentSous-agent spécialisé dans les appels API REST/GraphQL avec retry, auth et transformation de données. Se déclenche avec "sous-agent API", "API caller agent", "agent qui appelle une API", "REST agent", "HTTP agent", "API integration subagent", "external API agent". Also triggers on "subagent that calls an API", "API calling agent", "agent HTTP requests".Other plugins' skills for the same job