langchain-middleware

Pause LangChain agents before dangerous tool calls for human approval.

1|Updated Aug 23, 2025
One-click install
npx skills add https://github.com/laceto/financialtools --skill langchain-middleware-laceto
Or copy as Structured Prompt for Agent
Please help me install this Agent Skill.
Skill: langchain-middleware
Source: https://github.com/laceto/financialtools/tree/main/.claude/skills/langchain-middleware
Command: npx skills add https://github.com/laceto/financialtools --skill langchain-middleware-laceto

SYSTEM DOCUMENTATION & REQUIREMENTS

What problem does it solve?

Provide production-grade HITL middleware patterns to safely manage tool calls in LangChain agents, ensuring human oversight for dangerous actions.

Core Features & Use Cases

  • HumanInTheLoopMiddleware pauses before dangerous tool calls to require human approval.
  • Custom middleware hooks intercept tool calls for error handling, logging, and retries.
  • Command resume supports continuing execution after human decisions (approve, edit, or reject).
  • Per-tool policies and thread-id tracking enable configurable, auditable workflows.

Quick Start

Set up a LangChain agent with HITL middleware and test interrupt/resume flows.

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 for dangerous LangChain agent tool calls?

To add human-in-the-loop approval for LangChain agents, implement middleware that pauses execution before dangerous tool calls. This requires a checkpointer to persist state and uses hooks like wrap_tool_call to intercept actions and wait for human decisions.

What are LangChain middleware hooks and how do they manage agent execution?

LangChain middleware hooks are interception points that manage agent execution flows. Specific hooks include before_model, after_model, wrap_tool_call, before_agent, and after_agent, enabling custom policies for error handling, logging, and pausing dangerous actions.

Does LangChain human-in-the-loop middleware support resuming execution after a rejection?

LangChain human-in-the-loop middleware supports resuming execution after a human decision using command resume. This allows workflows to continue execution seamlessly whether the human operator chooses to approve, edit, or reject the paused tool call.

Can I configure per-tool interruption policies for LangChain agents?

You can configure per-tool interruption policies for LangChain agents. This enables customizable workflows where only specific dangerous tools require human approval, while safe tools execute automatically without pausing.

Do I need a checkpointer to use human-in-the-loop middleware with LangChain?

A checkpointer is required to use human-in-the-loop middleware with LangChain. The checkpointer persists agent state, allowing the workflow to pause before a dangerous tool call and resume execution later after human review.

How to handle tool call errors and retries using LangChain middleware?

To handle tool call errors and retries using LangChain middleware, implement custom hooks like wrap_tool_call. These middleware hooks intercept tool calls, allowing you to inject error handling logic, log actions, and automatically retry failed operations.