langchain-middleware

Enforce human-in-the-loop approval for LangChain tool calls with middleware hooks.

Updated Aug 27, 2026
One-click install
npx skills add https://github.com/HyunjunJeon/SDS-AX-Advanced-2026-1 --skill langchain-middleware-hyunjunjeon
Or copy as Structured Prompt for Agent
Please help me install this Agent Skill.
Skill: langchain-middleware
Source: https://github.com/HyunjunJeon/SDS-AX-Advanced-2026-1/tree/main/Day-01/.agents/skills/langchain-middleware
Command: npx skills add https://github.com/HyunjunJeon/SDS-AX-Advanced-2026-1 --skill langchain-middleware-hyunjunjeon

SYSTEM DOCUMENTATION & REQUIREMENTS

What problem does it solve?

Provides a framework to pause before dangerous tool calls for human approval, enable custom middleware with hooks, support Command resume patterns, and produce structured output with Pydantic/Zod.

Core Features & Use Cases

  • Human-in-the-Loop middleware pauses before dangerous tool calls to require approval
  • Custom middleware hooks (before_model, after_model, wrap_tool_call, before_agent, after_agent)
  • Command resume workflows to continue execution after decisions (approve, edit, reject)

Quick Start

Configure an agent with HumanInTheLoopMiddleware and a MemorySaver checkpointer to require approvals before sensitive tool calls.

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 risky tool calls in a LangChain agent?

Human-in-the-loop approval for LangChain agents is added by configuring HumanInTheLoopMiddleware to pause execution before dangerous tool calls. This middleware requires a mandatory checkpointer and supports configurable HITL policies per tool.

What are middleware hooks available for customizing LangChain agent workflows?

Middleware hooks for LangChain agents include before_model, after_model, wrap_tool_call, before_agent, and after_agent. These custom hooks allow you to inject logic at various stages of the agent and tool execution lifecycle.

How does Command resume work after a human approves or rejects a tool call?

Command resume workflows continue execution after a human decision by applying approve, edit, or reject semantics. The agent resumes from its paused state using the checkpointer, applying the decision to the structured tool call output.

Can I enforce structured output with Pydantic or Zod for LangChain tool calls?

Structured output for LangChain tool calls is enforced using Pydantic or Zod schemas. The middleware framework integrates these validation schemas to ensure tool calls produce predictable, safe, and structured data formats.

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

A checkpointer is mandatory to use human-in-the-loop middleware with LangChain. You must configure a checkpointer, such as MemorySaver, to persist the agent state while execution is paused awaiting human approval.

When should I use HITL middleware for LangChain agents instead of standard execution?

HITL middleware for LangChain agents should be used when tool calls carry risk and require pre-call human decisions. It enforces safe tool usage by pausing execution for approval, editing, or rejection before proceeding.