langchain-ai/langgraph-interaction-humaine

À invoquer lors de la mise en œuvre de schémas d'interaction humaine (vérification, validation) ou de gestion d'erreurs dans LangGraph. Couvre interrupt(), Command(resume=...), les flux d'approbation/validation et la stratégie de gestion des erreurs à 4 niveaux.

Qu'est-ce que langgraph-interaction-humaine ?

Cette compétence pour LangGraph permet d'implémenter des boucles d'interaction humaine (Human-in-the-Loop) en interrompant l'exécution d'un graphe pour obtenir une approbation, une validation ou corriger des erreurs. Elle s'appuie sur les mécanismes `interrupt()` pour suspendre le graphe et `Command(resume=...)` pour reprendre après une saisie humaine. La compétence détaille également une stratégie de gestion des erreurs à 4 niveaux : reprise avec nouvelle tentative, remplacement de nœud, retour à un point de contrôle antérieur, et terminaison propre. Destinée aux développeurs utilisant LangGraph, elle explique comment structurer des flux d'approbation (ex. validation de code, actions financières) et gérer les cas d'arrêt ou de rejet. Les plateformes supportées incluent les environnements d'exécution LangGraph (CLI, SDK, déploiement cloud). La documentation fournit des exemples concrets avec des appels API simulés, des schémas de validation et des patterns de reprise, rendant l'intégration humaine simple et robuste.

Compatible avec~Claude Code~Codex CLI~Cursor
npx skills add https://github.com/langchain-ai/langchain-skills/tree/main/skills/langgraph-human-in-the-loop

Installed? Explore more Productivité et collaboration skills: steipete/gemini, steipete/gh-issues, steipete/skill-creator · View all 6 →

Demander à votre IA préférée

Ouvre une nouvelle conversation avec cette compétence d'agent déjà préchargée.

Documentation

Que fait langgraph-interaction-humaine ?

À INVOQUER cette compétence lors de la mise en œuvre de schémas d'interaction humaine (Human-in-the-Loop), de pauses pour approbation, ou de gestion d'erreurs dans LangGraph. Couvre interrupt(), Command(resume=...), les flux d'approbation/validation, et la stratégie de gestion d'erreurs à 4 niveaux.

Mécanismes d'interruption

Utilisez interrupt() pour suspendre le graphe et attendre une saisie humaine :

from langgraph.types import interrupt

def human_review(state):
    # Interrompt en attendant l'approbation
    decision = interrupt({
        "question": "Approuvez-vous cette opération ?",
        "operation": state["pending_action"]
    })
    return {"approved": decision == "oui"}

Reprise avec Command

Utilisez Command(resume=...) pour reprendre un graphe interrompu avec la saisie humaine :

from langgraph.types import Command

# Dans le processus externe
thread.execute(thread_id, Command(resume="oui"))

Stratégie de gestion d'erreurs à 4 niveaux

  1. Reprise avec nouvelle tentative : Relancez le nœud en cas d'erreur transitoire (ex. timeout API).
  2. Remplacement de nœud : Fournissez une implémentation alternative via Command(resume={"action": "use_fallback"}).
  3. Retour à un point de contrôle : Revenez à un état antérieur du graphe pour corriger la saisie.
  4. Terminaison propre : Arrêtez l'exécution avec un message d'erreur approprié.

Exemple de flux d'approbation

def validation_node(state):
    if not state["approved"]:
        result = interrupt({
            "type": "approval",
            "data": state["action_data"]
        })
        if result.get("status") != "approved":
            return {"error": "Action rejetée"}
    # Continuer

Notes importantes

  • Les interruptions sont persistées dans le graphe ; elles survivent aux redémarrages.
  • Utilisez Command avec un thread ID unique pour une reprise correcte.
  • Les schémas d'approbation doivent inclure des validations de saisie (ex. pydantic) pour la robustesse.

Références utiles

Individual skills in this repo

This repo contains 11 individual skills — each has its own dedicated page.

langchain-ai/deep-agents-core

INVOKE THIS SKILL when building ANY Deep Agents application. Covers create_deep_agent(), harness architecture, SKILL.md format, and configuration options.

langchain-ai/deep-agents-memory

INVOKE THIS SKILL when your Deep Agent needs memory, persistence, or filesystem access. Covers StateBackend (ephemeral), StoreBackend (persistent), FilesystemMiddleware, and CompositeBackend for routing.

langchain-ai/deep-agents-orchestration

INVOKE THIS SKILL when using subagents, task planning, or human approval in Deep Agents. Covers SubAgentMiddleware, TodoList for planning, and HITL interrupts.

langchain-ai/framework-selection

INVOKE THIS SKILL at the START of any LangChain/LangGraph/Deep Agents project, before writing any agent code. Determines which framework layer is right for the task: LangChain, LangGraph, Deep Agents, or a combination. Must be consulted before other agent skills.

langchain-ai/langchain-dependencies

INVOKE THIS SKILL when setting up a new project or when asked about package versions, installation, or dependency management for LangChain, LangGraph, LangSmith, or Deep Agents. Covers required packages, minimum versions, environment requirements, versioning best practices, and common community tool packages for both Python and TypeScript.

langchain-ai/langchain-fundamentals

Create LangChain agents with create_agent, define tools, and use middleware for human-in-the-loop and error handling.

langchain-ai/langchain-middleware

INVOKE THIS SKILL when you need human-in-the-loop approval, custom middleware, or structured output. Covers HumanInTheLoopMiddleware for human approval of dangerous tool calls, creating custom middleware with hooks, Command resume patterns, and structured output with Pydantic/Zod.

langchain-ai/langchain-rag

INVOKE THIS SKILL when building ANY retrieval-augmented generation (RAG) system. Covers document loaders, RecursiveCharacterTextSplitter, embeddings (OpenAI), and vector stores (Chroma, FAISS, Pinecone).

langchain-ai/langgraph-fundamentals

INVOKE THIS SKILL when writing ANY LangGraph code. Covers StateGraph, state schemas, nodes, edges, Command, Send, invoke, streaming, and error handling.

langchain-ai/langgraph-persistence

INVOKE THIS SKILL when your LangGraph needs to persist state, remember conversations, travel through history, or configure subgraph checkpointer scoping. Covers checkpointers, thread_id, time travel, Store, and subgraph persistence modes.

langchain-ai/swarm

Dispatches many independent items in parallel: create a table, fan out to subagents, aggregate results. One row = one unit of work.

Skills associés