langchain-middleware

Configure human-in-the-loop approval for LangChain tool calls with per-tool policies.

Updated Apr 12, 2026
One-click install
npx skills add https://github.com/dotlab-hq/torque --skill langchain-middleware-dotlab-hq
Or copy as Structured Prompt for Agent
Please help me install this Agent Skill.
Skill: langchain-middleware
Source: https://github.com/dotlab-hq/torque/tree/main/.agents/skills/langchain-middleware
Command: npx skills add https://github.com/dotlab-hq/torque --skill langchain-middleware-dotlab-hq

SYSTEM DOCUMENTATION & REQUIREMENTS

What problem does it solve?

LangChain agents often execute tool calls without human oversight, risking unsafe or incorrect actions. This skill provides a structured human-in-the-loop workflow and reusable middleware patterns to govern tool usage, enable reviews, and ensure accountable decisions.

Core Features & Use Cases

  • HumanInTheLoopMiddleware pauses before dangerous tool calls to require human decisions.
  • Custom middleware hooks such as wrap_tool_call, before_model, after_model, before_agent, and after_agent enable interception and state inspection.
  • Command resume patterns allow continuing execution after approval, edits, or rejection.
  • Per-tool HITL policies with a checkpointer-backed thread_id enable robust, auditable workflows.

Quick Start

Configure your LangChain agent with HITL middleware, set a thread_id, and resume after human approval using Command.

Frequently Asked Questions about langchain-middleware

High-intent search queries and answers about installing and using this skill.

FAQPage Schema
How do I add human-in-the-loop approval to LangChain tool calls?

Human-in-the-loop approval for LangChain tool calls is added by applying HumanInTheLoopMiddleware to pause execution before dangerous actions. This requires a checkpointer-backed state with a thread_id to save the context and resume later.

How do I resume a LangChain agent after a human approves or edits a tool call?

You resume a LangChain agent after human approval by passing a Command object back to the graph. This Command pattern continues execution from the paused state, allowing the workflow to proceed with approved, edited, or rejected tool actions.

Can I configure different human-in-the-loop policies for individual tools in LangChain?

Yes, you can configure per-tool HITL policies in LangChain. This allows you to apply specific interception rules to individual tools, ensuring robust and auditable workflows where only dangerous or critical actions require human review.

What middleware hooks are available to intercept LangChain agent actions?

Available middleware hooks to intercept LangChain agent actions include wrap_tool_call, before_model, after_model, before_agent, and after_agent. These hooks enable state inspection and custom validation logic before or after key execution phases.

Do I need a checkpointer to implement human-in-the-loop workflows in LangChain?

Yes, a checkpointer is required to implement human-in-the-loop workflows in LangChain. It provides the state persistence needed to pause execution, maintain a thread_id for context, and reliably resume the agent after human decisions.

Why does my LangChain agent execute tool calls without pausing for review?

LangChain agents execute tool calls without pausing when HumanInTheLoopMiddleware is not applied. Without per-tool interrupt configurations and a checkpointer-backed thread_id, the workflow bypasses human oversight and runs actions automatically.