langchain-middleware

Pause LangChain agent tool calls for human approval via middleware.

Updated Nov 16, 2025
One-click install
npx skills add https://github.com/daniel-dihardja/menuyukti --skill langchain-middleware-daniel-dihardja
Or copy as Structured Prompt for Agent
Please help me install this Agent Skill.
Skill: langchain-middleware
Source: https://github.com/daniel-dihardja/menuyukti/tree/main/.agents/skills/langchain-middleware
Command: npx skills add https://github.com/daniel-dihardja/menuyukti --skill langchain-middleware-daniel-dihardja

SYSTEM DOCUMENTATION & REQUIREMENTS

What problem does it solve?

Enable production LangChain agents to require human oversight for sensitive tool calls using HumanInTheLoopMiddleware, ensuring safety and controllable behavior.

Core Features & Use Cases

  • HumanInTheLoopMiddleware: pause before dangerous tool calls for human approval.
  • Custom middleware hooks: before_model, after_model, wrap_tool_call, before_agent, after_agent to customize behavior.
  • Command resume patterns: resume after decisions (approve, edit, reject) with structured outputs and persistence.

Quick Start

Provide a minimal HITL-enabled LangChain agent example and run it to demonstrate interrupt-and-approve flow.

Frequently Asked Questions about langchain-middleware

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

FAQPage Schema
How do I require human approval before dangerous tool calls in LangChain agents?

You can require human approval for dangerous tool calls in LangChain agents by applying HumanInTheLoopMiddleware to pause execution before sensitive actions. It uses checkpointer persistence and thread_id tracking to maintain context while waiting for a human decision.

What is the human-in-the-loop pattern for LangChain middleware?

The human-in-the-loop pattern for LangChain middleware intercepts agent execution at specific hooks like before_model or wrap_tool_call to pause workflows. This ensures safe, controllable behavior by requiring human oversight before proceeding with sensitive operations.

How do I resume a LangChain agent after pausing it for human review?

You resume a LangChain agent after human review using command-resume patterns. This involves sending structured outputs like approve, edit, or reject decisions back to the paused agent, which then resumes execution from its checkpointer-persisted state.

Can I set per-tool interrupt policies for LangChain agents?

Yes, you can configure per-tool interrupt policies for LangChain agents. The middleware approach allows you to define specific rules that determine which tools require human approval and which can execute automatically, satisfying detailed human-in-the-loop configuration requirements.

Does human-in-the-loop middleware work with both Python and TypeScript LangChain workflows?

Yes, human-in-the-loop middleware works with both Python and TypeScript LangChain workflows. The interrupt and checkpoint patterns apply across both language implementations, allowing you to pause execution and require approval regardless of your development environment.

What are the limitations of using middleware to pause LangChain agents?

A limitation of using middleware to pause LangChain agents is the requirement for checkpointer persistence to maintain state. You must manage thread_id tracking and ensure your environment supports persistent storage to successfully pause and resume workflows during human review.