langchain-human-in-the-loop
Add human oversight to LangChain agents using HITL middleware - includes interrupts, approval workflows, edit/reject decisions, and checkpoints
npx skills add majiayu000/claude-skill-registry --skill langchain-human-in-the-loop --agent claude-code
Same command for any agent — swap --agent for codex, cursor, copilot.
Weekly change comes from our own snapshots, not the repository page — it measures attention, not adoption.
# langchain-human-in-the-loop (JavaScript/TypeScript) ## 概述 人工在环(Human-in-the-Loop,HITL)让您可以向代理工具调用添加人工监督。当代理提出敏感操作(如数据库写入或发送电子邮件)时,执行会暂停以供人工批准、编辑或拒绝。 **核心概念:** - **humanInTheLoopMiddleware**:暂停执行以供人工决策 - **中断**(Interrupts):代理等待人工输入的检查点 - **决策**(Decisions):批准、编辑或拒绝工具调用 - **检查点**(Checkpointer):跨中断持久化所必需的 ## 何时使用 HITL | 场景 | 使用 HITL? | 原因 | |----------|-----------|-----| | 数据库写入 | ✅ 是 | 防止数据损坏 | | 发送电子邮件/消息 | ✅ 是 | 发送前审查 | | 金融交易 | ✅ 是 | 执行前确认 | | 删除数据 | ✅ 是 | 防止意外丢失 | | 只读操作 | ❌ 否 | 低风险 | | 内部计算 | ❌ 否 | 无外部影响 | ## 决策表 ### HITL 决策类型 | 决策 | 效果 | 何时使用 | |----------|--------|-------------| | `approve` | 按原样执行工具 | 工具调用看起来正确 | | `edit` | 修改参数然后执行 | 需要更改参数 | | `reject` | 不执行,提供反馈 | 工具调用错误 | ## 代码示例 ### 基本 HITL 设置 ```typescript import { createAgent, humanInTheLoopMiddleware } from "langchain"; import { MemorySaver } from "@langchain/langgraph"; import { tool } from "langchain"; import { z } from "zod"; const sendEmail = tool( async ({ to, subject, body }) => { // 发送电子邮件逻辑 return `已发送电子邮件到 ${to}`; }, { name: "send_email", description: "发送电子邮件", schema: z.object({ to: z.string().email(), subject: z.string(), body: z.string(), }), } ); const agent = createAgent({ model: "gpt-4.1", tools: [send
- 概述
- 何时使用 HITL
- 决策表
- HITL 决策类型
- 代码示例
- 基本 HITL 设置
- 使用中断运行
- 编辑工具参数
- 带反馈的拒绝
- 不同策略的多个工具
- 使用 HITL 流式传输
- 自定义中断逻辑
- 边界
- 您可以配置什么
What does the langchain-human-in-the-loop skill do?
Add human oversight to LangChain agents using HITL middleware - includes interrupts, approval workflows, edit/reject decisions, and checkpoints
How do I install it?
Run `npx skills add majiayu000/claude-skill-registry --skill langchain-human-in-the-loop --agent claude-code` — it drops the skill into your project so the agent can pick it up. Swap the --agent value for codex, cursor or copilot if you use one of those.
Where does this skill come from?
From majiayu000/claude-skill-registry, a repository with 534 stars. We read it straight from the repository tree rather than a submitted listing, so what you see here is what is actually published.
Is a popular skill a good skill?
Not necessarily. Stars measure attention, not adoption — a repository can trend for a week and be abandoned. That is why we show the weekly change from our own snapshots next to the total, instead of a single flattering number.
