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.
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-middlewareRun in your terminal. Claude Code loads skills from ~/.claude/skills automatically.
git clone --depth 1 https://github.com/langchain-ai/langchain-skills /tmp/langchain-skills && mkdir -p ~/.gemini/antigravity-cli/skills && cp -r /tmp/langchain-skills/config/skills/langchain-middleware ~/.gemini/antigravity-cli/skills/langchain-middlewareAntigravity CLI loads skills from ~/.gemini/antigravity-cli/skills, or .agents/skills for one project.
Step-by-step: install langchain-middleware in Antigravity CLI
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
ANo 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 →Aligns a Qwen Code feature with a Codex or Claude Code reference agent. It runs both under the same scenario, captures HTTP and terminal traces, and compares them until behavior matches.
Searches, views, creates, updates, and deletes the user's Google Contacts from an AI assistant. It is for people who want to manage their address book through conversation. A one-time Google connect is required before it returns data.
Guides an AI assistant on error handling choices. It covers when to use Result, Option, ? propagation, unwrap, expect and panic, plus anyhow and thiserror.
Caveman is an agent skill that makes an AI assistant reply in a terse style. It cuts filler and keeps technical facts, code, commands and errors exact. It is built for users who want shorter, cheaper replies.
docs-sync audits or updates English SDK documentation against the requested implementation scope. It is for maintainers who want docs to match main branch features, configuration options, and defaults.
Guides an AI assistant through setting up and running monorepos with pnpm workspaces, Turborepo and Nx. Aimed at developers who need faster builds, shared code and managed dependencies across multiple packages.
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.
