Token导航 LogoToken导航

Agent Skill · 开发

langgraph-human-in-the-loop(langgraph 人类在循环中)

langgraph-human-in-the-loop 用于处理 GitHub 仓库、Issue、Pull Request 和代码协作信息,适合在 Codex、Claude、Cursor、Gemini CLI 中需要围绕仓库状态、代码变更或协作事项进行整理时使用。可结合来源仓库、安装命令和原始 README 继续核验具体用法。安装前建议确认权限范围、维护状态,以及是否会触发联网、命令执行或文件读写。

langgraph-human-in-the-loop 是开发类 Agent Skill,可用宿主为 Codex、Claude、Cursor、Gemini CLI,通过GitHub 仓库获取,权限为权限未标注;许可证信息还不明确,第三方扫描已通过,按安装量在开发类的 21,746 个 Skill 里排第 304。

总安装 134,640周安装 5,513GitHub Stars 638下载 43,560核验 2026-05-01

安装说明

本站只整理中文说明,不托管安装包,也不代用户安装。
GitHub
许可证
unknown

安装方式

通过对话安装

复制提示词发给支持本地命令或 Skills 的 AI 助手,先确认命令和权限,再让它执行。

请帮我安装这个 Agent Skill:langgraph-human-in-the-loop(langgraph 人类在循环中)
来源仓库:https://github.com/langchain-ai/langchain-skills
仓库路径:skills/langgraph-human-in-the-loop
安装命令:
npx skills add https://github.com/langchain-ai/langchain-skills --skill langgraph-human-in-the-loop
安装前请先检查当前环境是否支持对应 CLI,并向我确认将要执行的命令、安装目录、联网范围和文件读写权限;确认后再执行。

命令行安装

复制命令到本机终端执行。该命令会通过 npx skills 从第三方来源获取 Skill;本站只展示命令,不托管安装包,也不自动执行。

skills.shnpx skills
npx skills add https://github.com/langchain-ai/langchain-skills --skill langgraph-human-in-the-loop

这个 Skill 是做什么的

开发类 Skill 面向写代码、改代码和排查问题,一般会读写仓库文件,部分还会执行构建或测试命令。

暂停图形执行以进行人工审查、批准或验证,然后根据他们的输入恢复。

需要三个组件:检查点(InMemorySaver 或 PostgresSaver)、配置中的线程 ID 和 JSON 可序列化中断负载 中断(值) 暂停并显示数据;命令(恢复=值) 恢复并将该值返回到暂停的节点 中断()之前的所有代码 在恢复时重新执行,因此副作用必须是幂等的(使用 upsert,而不是 insert) 支持批准工作流程、带重新提示的验证循环以及通过 ID 到值映射恢复的并行中断

来源仓库内路径:skills/langgraph-human-in-the-loop

上手步骤

4 步
  1. 1

    确认自己的宿主工具

    公开资料标注支持 Codex、Claude、Cursor、Gemini CLI;先确认自己用的是其中之一,再按对应工具的 Skills 目录放置。

  2. 2

    拿到安装命令

    可以直接复制的命令是 npx skills add https://github.com/langchain-ai/langchain-skills --skill langgrap…;命令里的占位符换成自己的路径或密钥再执行。

  3. 3

    安装后重启宿主

    命令执行完要完全退出宿主工具再打开,让新装的 Skill 被重新扫描到,否则列表里可能看不到。

  4. 4

    按最小权限试用

    权限没有明确标注,第一次使用时只给一个无关紧要的任务,观察它到底读了哪些文件和网络。

常见问题

6 条

langgraph-human-in-the-loop 怎么安装?

在终端执行 npx skills add https://github.com/langchain-ai/langchain-skills --skill langgraph-human-in…。装完完全退出宿主工具再打开,让它重新扫描本地 Skill。

langgraph-human-in-the-loop 支持哪些 AI 工具?

公开资料标注支持 Codex、Claude、Cursor、Gemini CLI。其他工具只要能读取本地 Skill 目录,一般也能手动放进去,但要自己确认触发方式是否一致。

langgraph-human-in-the-loop 需要什么权限?

权限级别没有明确标注。第一次使用时建议只给无关紧要的任务,观察它实际读写了哪些内容。

langgraph-human-in-the-loop 是免费的吗?

公开资料没有标注明确许可证,收费和商用限制都无法确认。正式使用前请到来源仓库核对授权说明。

langgraph-human-in-the-loop 用的人多吗?

公开数据是累计安装 134,640 次,近一周安装 5,513 次,下载 43,560 次,GitHub 638 星。这些数字来自第三方目录统计,只能当作热度参考,不代表质量或安全性。

langgraph-human-in-the-loop 安全吗?

第三方扫描结果为通过,但这只覆盖已知的静态检查项,不能替代自己读一遍源码和安装命令。

值得选的地方和要先想清楚的地方

值得选的地方

  • 同时适配 4 种工具,换客户端不用重新找替代品。
  • 第三方扫描已通过,常见的高风险行为没有命中。

先想清楚的地方

  • 许可证没有明确标注,能不能商用、能不能再分发都不确定。
  • 第三方目录整理,版本更新和行为细节以来源仓库为准。

适不适合你

更适合

  • 已经在用 Codex,想直接扩展它能力的人。
  • 需要处理开发类任务、又不想每次都手写提示词的人。

不太适合

  • 需要明确授权才能用到公司项目里的场景。
  • 需要厂商级技术支持和 SLA 的生产系统。

开发类 Skill 对比

6 个同类
Skill总安装GitHub 星权限许可证扫描
skill-vetter

技能审查员 · OpenClaw

8,779,018986操作浏览器MIT-0通过
ontology

本体论 · OpenClaw

6,636,960576只读MIT-0通过
entra-app-registration

内部应用程序注册 · Codex、Claude

6,631,872764接触敏感数据未明确通过
entra-app-registration

内部应用程序注册 · Codex、Claude

3,757,680201接触敏感数据未明确通过
nano-banana-pro

纳米香蕉专业版 · OpenClaw

3,526,898364接触敏感数据MIT-0有提醒
langgraph-human-in-the-loop

langgraph 人类在循环中 · 本页

134,640638权限未标注未明确通过

按安装量取同分类前几名;数字来自第三方目录统计,只作热度参考,不代表质量结论。

SKILL.md 原文

  • interrupt(value) — pauses execution, surfaces a value to the caller
  • Command(resume=value) — resumes execution, providing the value back to interrupt()
  • Checkpointer — required to save state while paused
  • Thread ID — required to identify which paused execution to resume

Requirements

Three things are required for interrupts to work:

  1. Checkpointer — compile with checkpointer=InMemorySaver() (dev) or PostgresSaver (prod)
  2. Thread ID — pass {"configurable": {"thread_id": "..."}} to every invoke/stream call
  3. JSON-serializable payload — the value passed to interrupt() must be JSON-serializable

Basic Interrupt + Resume

interrupt(value) pauses the graph. The value surfaces in the result under __interrupt__. Command(resume=value) resumes — the resume value becomes the return value of interrupt().

Critical: when the graph resumes, the node restarts from the beginning — all code before interrupt() re-runs.

class State(TypedDict): approved: bool

def approval_node(state: State): # Pause and ask for approval approved = interrupt("Do you approve this action?") # When resumed, Command(resume=...) returns that value here return {"approved": approved}

checkpointer = InMemorySaver() graph = (StateGraph(State).add_node("approval", approval_node).add_edge(START, "approval").add_edge("approval", END).compile(checkpointer=checkpointer))

config = {"configurable": {"thread_id": "thread-1"}}

Initial run — hits interrupt and pauses

result = graph.invoke({"approved": False}, config) print(result["interrupt"])

[Interrupt(value='Do you approve this action?')]

Resume with the human's response

result = graph.invoke(Command(resume=True), config) print(result["approved"]) # True

</python>
<typescript>
Pause execution for human review and resume with Command.

import { interrupt, Command, MemorySaver, StateGraph, StateSchema, START, END } from "@langchain/langgraph"; import { z } from "zod";

const State = new StateSchema({ approved: z.boolean().default(false), });

const approvalNode = async (state: typeof State.State) => { // Pause and ask for approval const approved = interrupt("Do you approve this action?"); // When resumed, Command({ resume }) returns that value here return { approved }; };

const checkpointer = new MemorySaver(); const graph = new StateGraph(State) .addNode("approval", approvalNode) .addEdge(START, "approval") .addEdge("approval", END) .compile({ checkpointer });

const config = { configurable: { thread_id: "thread-1" } };

// Initial run — hits interrupt and pauses let result = await graph.invoke({ approved: false }, config); console.log(result.__interrupt__); // [{ value: 'Do you approve this action?', ... }]

// Resume with the human's response result = await graph.invoke(new Command({ resume: true }), config); console.log(result.approved); // true


---

## Approval Workflow

A common pattern: interrupt to show a draft, then route based on the human's decision.

class EmailAgentState(TypedDict): email_content: str draft_response: str classification: dict

def human_review(state: EmailAgentState) -> Command[Literal["send_reply", "**end**"]]: """Pause for human review using interrupt and route based on decision.""" classification = state.get("classification", {})

interrupt() must come first — any code before it will re-run on resume

human_decision = interrupt({ "email_id": state.get("email_content", ""), "draft_response": state.get("draft_response", ""), "urgency": classification.get("urgency"), "action": "Please review and approve/edit this response" })

Process the human's decision

if human_decision.get("approved"): return Command( update={"draft_response": human_decision.get("edited_response", state.get("draft_response", ""))}, goto="send_reply" ) else: # Rejection — human will handle directly return Command(update={}, goto=END)

</python> <typescript> Interrupt for human review, then route to send or end based on the decision.

import { interrupt, Command, END, GraphNode } from "@langchain/langgraph";

const humanReview: GraphNode<typeof EmailAgentState> = async (state) => {
  const classification = state.classification!;

  // interrupt() must come first — any code before it will re-run on resume
  const humanDecision = interrupt({
    emailId: state.emailContent,
    draftResponse: state.responseText,
    urgency: classification.urgency,
    action: "Please review and approve/edit this response",
  });

  // Process the human's decision
  if (humanDecision.approved) {
    return new Command({
      update: { responseText: humanDecision.editedResponse || state.responseText },
      goto: "sendReply",
    });
  } else {
    return new Command({ update: {}, goto: END });
  }
};

Validation Loop

Use interrupt() in a loop to validate human input and re-prompt if invalid.

def get_age_node(state): prompt = "What is your age?"

while True:
    answer = interrupt(prompt)

    # Validate the input
    if isinstance(answer, int) and answer > 0:
        break
    else:
        # Invalid input — ask again with a more specific prompt
        prompt = f"'{answer}' is not a valid age. Please enter a positive number."

return {"age": answer}
Each `Command(resume=...)` call provides the next answer. If invalid, the loop re-interrupts with a clearer message.

config = {"configurable": {"thread_id": "form-1"}} first = graph.invoke({"age": None}, config)

__interrupt__: "What is your age?"

retry = graph.invoke(Command(resume="thirty"), config)

__interrupt__: "'thirty' is not a valid age..."

final = graph.invoke(Command(resume=30), config) print(final["age"]) # 30


const getAgeNode = (state: typeof State.State) => {let prompt = "What is your age?";

while (true) {const answer = interrupt(prompt);

// Validate the input if (typeof answer === "number" && answer > 0) { return { age: answer }; } else { // Invalid input — ask again with a more specific prompt prompt = '${answer}' is not a valid age. Please enter a positive number.; }


}};

</typescript> </ex-validation-loop>


Multiple Interrupts

When parallel branches each call interrupt(), resume all of them in a single invocation by mapping each interrupt ID to its resume value.

<ex-multiple-interrupts> <python> Resume multiple parallel interrupts by mapping interrupt IDs to values.

from typing import Annotated, TypedDict
import operator
from langgraph.checkpoint.memory import InMemorySaver
from langgraph.graph import START, END, StateGraph
from langgraph.types import Command, interrupt

class State(TypedDict):
    vals: Annotated[list[str], operator.add]

def node_a(state):
    answer = interrupt("question_a")
    return {"vals": [f"a:{answer}"]}

def node_b(state):
    answer = interrupt("question_b")
    return {"vals": [f"b:{answer}"]}

graph = (
    StateGraph(State)
    .add_node("a", node_a)
    .add_node("b", node_b)
    .add_edge(START, "a")
    .add_edge(START, "b")
    .add_edge("a", END)
    .add_edge("b", END)
    .compile(checkpointer=InMemorySaver())
)

config = {"configurable": {"thread_id": "1"}}

# Both parallel nodes hit interrupt() and pause
result = graph.invoke({"vals": []}, config)
# result["__interrupt__"] contains both Interrupt objects with IDs

# Resume all pending interrupts at once using a map of id -> value
resume_map = {
    i.id: f"answer for {i.value}"
    for i in result["__interrupt__"]
}
result = graph.invoke(Command(resume=resume_map), config)
# result["vals"] = ["a:answer for question_a", "b:answer for question_b"]

const State = Annotation.Root({vals: Annotation<string[]>({reducer: (left, right) => left.concat(Array.isArray(right)? right: [right]), default: () => [],}),});

function nodeA(_state: typeof State.State) {const answer = interrupt("question_a") as string; return {vals: [a:${answer}]};}

function nodeB(_state: typeof State.State) {const answer = interrupt("question_b") as string; return {vals: [b:${answer}]};}

const graph = new StateGraph(State).addNode("a", nodeA).addNode("b", nodeB).addEdge(START, "a").addEdge(START, "b").addEdge("a", END).addEdge("b", END).compile({checkpointer: new MemorySaver()});

const config = {configurable: {thread_id: "1"}};

const interruptedResult = await graph.invoke({vals: []}, config);

// Resume all pending interrupts at once const resumeMap: Record<string, string> = {}; if (isInterrupted(interruptedResult)) {for (const i of interruptedResult[INTERRUPT]) {if (i.id!= null) {resumeMap[i.id] = answer for ${i.value};}}} const result = await graph.invoke(new Command({resume: resumeMap}), config); // result.vals = ["a:answer for question_a", "b:answer for question_b"]

</typescript>
</ex-multiple-interrupts>

User-fixable errors use `interrupt()` to pause and collect missing data — that's the pattern covered by this skill. For the full 4-tier error handling strategy (RetryPolicy, Command error loops, etc.), see the **fundamentals** skill.

---

## Side Effects Before Interrupt Must Be Idempotent

When the graph resumes, the node restarts from the **beginning** — ALL code before `interrupt()` re-runs. In subgraphs, BOTH the parent node and the subgraph node re-execute.

<idempotency-rules>

**Do:**
- Use **upsert** (not insert) operations before `interrupt()`
- Use **check-before-create** patterns
- Place side effects **after** `interrupt()` when possible
- Separate side effects into their own nodes

**Don't:**
- Create new records before `interrupt()` — duplicates on each resume
- Append to lists before `interrupt()` — duplicate entries on each resume

</idempotency-rules>

<ex-idempotent-patterns>
<python>
Idempotent operations before interrupt vs non-idempotent (wrong).

GOOD: Upsert is idempotent — safe before interrupt

def node_a(state: State): db.upsert_user(user_id=state["user_id"], status="pending_approval") approved = interrupt("Approve this change?") return {"approved": approved}

GOOD: Side effect AFTER interrupt — only runs once

def node_a(state: State): approved = interrupt("Approve this change?") if approved: db.create_audit_log(user_id=state["user_id"], action="approved") return {"approved": approved}

BAD: Insert creates duplicates on each resume!

def node_a(state: State): audit_id = db.create_audit_log({ # Runs again on resume! "user_id": state["user_id"], "action": "pending_approval", }) approved = interrupt("Approve this change?") return {"approved": approved}


// GOOD: Side effect AFTER interrupt — only runs once const nodeA = async (state: typeof State.State) => {const approved = interrupt("Approve this change?"); if (approved) {await db.createAuditLog({userId: state.userId, action: "approved"});} return {approved};};

// BAD: Insert creates duplicates on each resume! const nodeA = async (state: typeof State.State) => {await db.createAuditLog({// Runs again on resume! userId: state.userId, action: "pending_approval",}); const approved = interrupt("Approve this change?"); return {approved};};

</typescript> </ex-idempotent-patterns>

<subgraph-interrupt-re-execution>

Subgraph re-execution on resume

When a subgraph contains an interrupt(), resuming re-executes BOTH the parent node (that invoked the subgraph) AND the subgraph node (that called interrupt()):

<python>

def node_in_parent_graph(state: State):
    some_code()  # <-- Re-executes on resume
    subgraph_result = subgraph.invoke(some_input)
    # ...

def node_in_subgraph(state: State):
    some_other_code()  # <-- Also re-executes on resume
    result = interrupt("What's your name?")
    # ...

async function nodeInSubgraph(state: State) {someOtherCode(); // <-- Also re-executes on resume const result = interrupt("What's your name?"); //...}

</typescript>
</subgraph-interrupt-re-execution>

---

## Command(resume) Warning

`Command(resume=...)` is the **only** Command pattern intended as input to `invoke()`/`stream()`. Do NOT pass `Command(update=...)` as input — it resumes from the latest checkpoint and the graph appears stuck. See the fundamentals skill for the full antipattern explanation.

---

## Fixes

<fix-checkpointer-required-for-interrupts>
<python>
Checkpointer required for interrupt functionality.

WRONG

graph = builder.compile()

CORRECT

graph = builder.compile(checkpointer=InMemorySaver())


// CORRECT const graph = builder.compile({checkpointer: new MemorySaver()});

</typescript> </fix-checkpointer-required-for-interrupts>

<fix-resume-with-command> <python> Use Command to resume from an interrupt (regular dict restarts graph).

# WRONG
graph.invoke({"resume_data": "approve"}, config)

# CORRECT
graph.invoke(Command(resume="approve"), config)

// CORRECT await graph.invoke(new Command({resume: "approve"}), config);

</typescript>
</fix-resume-with-command>

<boundaries>
### What You Should NOT Do

- Use interrupts without a checkpointer — will fail
- Resume without the same thread_id — creates a new thread instead of resuming
- Pass `Command(update=...)` as invoke input — graph appears stuck (use plain dict)
- Perform non-idempotent side effects before `interrupt()` — creates duplicates on resume
- Assume code before `interrupt()` only runs once — it re-runs every resume
</boundaries>

平台分布

Codex

36.25%
按下载量换算15,791

Claude

30.22%
按下载量换算13,164

Cursor

19.33%
按下载量换算8,420

Gemini CLI

11.15%
按下载量换算4,857

安全审计

Gen Agent Trust Hub

通过

Socket

通过

Snyk

通过

权限和风险

权限未标注

当前来源未能明确判断权限范围,默认进入异常复核队列。

安装前确认

本站仅展示第三方公开信息,不托管安装包,不提供自动安装或运行环境。安装前应自行审查源码、依赖和命令行为。目前只有一个公开来源,建议同时核对源仓库。

继续浏览同类 Skills