Sponsored byOutsenseAI that finds your next clients
SponsorGROUOutbound, LinkedIn content and leads for B2B teamsSponsorOutsenseAI that finds your next clientsAd+Your tool hereSeen by people installing AI tools@Weekly picksThe best new tools, one email a week

langchain-middleware

Skill by langchain-ai

Adds human approval, custom middleware and resume patterns to LangChain agents. It is for developers who need to pause dangerous tool calls for review before they run.

  • Score 87
  • 1.4k stars
  • MIT
  • Updated
Works withClaude CodeClaude apps Antigravity CLI

Install langchain-middleware

Built from the published package, never by AI.

git clone --depth 1 https://github.com/langchain-ai/langchain-skills /tmp/langchain-skills && mkdir -p ~/.claude/skills && cp -r /tmp/langchain-skills/config/skills/langchain-middleware ~/.claude/skills/langchain-middleware

Run in your terminal. Claude Code loads skills from ~/.claude/skills automatically.

Step-by-step: install langchain-middleware in Claude Code

Skills can run scripts on your machine. Some need an API key: check the README.

About

The langchain-middleware skill gives an AI assistant patterns for building production LangChain agents. Its main feature is HumanInTheLoopMiddleware, which pauses before selected tool calls, such as sending an email, so a person can approve, edit or reject them. Each tool can have its own allowed decisions, and a tool can be set to skip review. The skill also covers custom middleware hooks and resuming a run with the Command class after a human decision.

Human-in-the-loop workflows need a checkpointer and a thread_id so state persists between the pause and the resume. The skill includes Python and TypeScript examples and common fixes for missing checkpointers, missing thread IDs and wrong resume syntax. It is aimed at developers building agents that need approval gates or retry and logging logic around tool calls. The description also mentions structured output with Pydantic and Zod, but the examples in the body focus on middleware.

Written from the project's SKILL.md and checked against it.

What it can do

  • HumanInTheLoopMiddlewarePauses dangerous tool calls so a human can approve them before they run.
  • Per-tool policiesSets allowed decisions (approve, edit, reject) for each tool, or turns review off for a tool.
  • Command resumeContinues an agent run after an approve, edit or reject decision from a human.
  • wrap_tool_callIntercepts tool execution to add retry logic or block a tool with a short-circuit.
  • Before and after hooksRuns before_model, after_model, before_agent and after_agent hooks to inspect or update state.
  • wrap_model_callWraps model calls with a request and handler, so middleware can proceed or return early.

What you need

  • LangChain agent setup in Python or TypeScript
  • A checkpointer, such as MemorySaver
  • A thread_id config for human-in-the-loop runs

Try asking

  • Require my approval before the agent sends any email.
  • Set up a LangChain agent that asks me to approve delete actions.
  • Show me how to resume a LangChain agent after I reject a tool call.

Good to know

  • Interrupts can only happen before a tool runs, not after.
  • Human-in-the-loop needs a checkpointer and a thread_id.
  • In Python, wrap hooks must not use yield.

Security check

A

No download-and-run commands, hidden instructions or signs of sending keys out were found.

Checked automatically: config/skills/langchain-middleware/SKILL.md. This looks for known risky patterns and is not a full audit. How grades work

Alternatives to langchain-middleware

All alternatives →

Compare with agent-reproduce-align, google_contacts or m06-error-handling

langchain-middleware: common questions

Does human-in-the-loop work without a checkpointer?

No. The source says HITL middleware requires a checkpointer to persist state, and a thread_id config for all HITL workflows.

Can a human change tool arguments before approving?

Yes. An edit decision can include an edited_action with the tool name and corrected args before the call runs.

Can an approval happen after a tool has already run?

No. The source says interrupts must happen before tool execution, not after.

How do I install langchain-middleware?

Run the command above to copy the skill into ~/.claude/skills/. Claude Code picks it up automatically.

Is langchain-middleware free?

The code is published under the MIT licence. The service it connects to may have its own pricing.

Is langchain-middleware safe to use?

It scores 87 of 100. Grades: maintenance A, licence A, quality A. Security check: grade A, no risky patterns found in the files checked. Review the code before you install. How grades work.

What are alternatives to langchain-middleware?

Similar skills: agent-reproduce-align, google_contacts, m06-error-handling, caveman.

langchain-middleware Install

Add to stack

Loading.