langchain-middleware Skill: Human Approval and Custom Middleware for LangChain Agents
Teaches your agent to add human approval steps and custom middleware to LangChain agents, in Python and TypeScript.
- Installs
- 16.6K
- on skills.sh
- Stars
- 1.3K
- on GitHub
- Updated
- Oct 2026
- last repo commit
The skill covers pausing an agent before a risky tool call (such as sending an email) so a person can approve, edit or reject it, and resuming the run afterwards. It also shows custom middleware hooks for retries, logging and guards. Every example comes in Python and TypeScript.
Every approval flow needs a checkpointer and a thread id, which the skill repeats in its fixes. The description also mentions structured output, but the SKILL.md has no section on it. The skill bundles no scripts and needs the LangChain packages in your own project.
Good for
- Developers building LangChain agents that must ask before risky actions
- Teams adding retries, logging or guards around tool calls
- TypeScript and Python users who want the same patterns in both
Install langchain-middleware
Claude Code
- 1
Copy this prompt.
Install the langchain-middleware skill in Claude Code. Run this command: npx skills add https://github.com/langchain-ai/langchain-skills --skill langchain-middleware Then check that it loaded and tell me how to use it.
- 2
Paste it into Claude Code. It shows the change and asks before running it.
Requires Node.js.
From its listing on skills.sh. Source.
What's in the skill
When it loads
INVOKE THIS SKILL when you need human-in-the-loop approval, custom middleware, or structured output. Covers HumanInTheLoopMiddleware for human approval of dangerous tool calls, creating custom middleware with hooks, Command resume patterns, and structured output with Pydantic/Zod.
Sections in SKILL.md
- Human-in-the-Loop
- What You CAN Configure
- Custom Middleware Hooks
- What You CANNOT Configure
Key facts
- Author
- LangChain
- Installs on skills.sh
- 16,559 (Nov 2, 2026)
- GitHub stars
- 1,320 (Nov 2, 2026), whole repo
- Last commit
- Oct 29, 2026 (repo)
- Languages
- Python and TypeScript examples
- Needs in your project
- A checkpointer and a thread_id for every human-in-the-loop flow
What it includes
HumanInTheLoopMiddleware with a checkpointer
Pauses before chosen tools and allows approve, edit or reject.
Basic HITL setupDetect an interrupt, then resume with a Command
Shows the resume syntax for approve decisions.
Running with interruptsHuman edits the call before it runs
The edited action must include the name and args.
Editing tool argumentsHuman rejects and explains
Feedback goes back to the agent.
Rejecting with feedbackinterrupt_on rules per tool
Each tool gets its own allowed decisions.
Different policies per toolwrap_tool_call, wrap_model_call, before and after hooks
Six decorator hooks in two patterns: wrap hooks and before/after hooks. Warns not to use yield in wrap hooks.
Custom middleware hooksMissing checkpointer, missing thread id, wrong resume syntax
WRONG versus CORRECT code for each.
Fixes
From the official docs
Questions
What does the langchain-middleware skill do?
It teaches your agent LangChain's human-in-the-loop middleware and custom middleware hooks. That covers approving, editing or rejecting tool calls and resuming the run.
How do I install it?
Use the install box above. The folder is a single SKILL.md. The LangChain README also documents npx skills add langchain-ai/langchain-skills --skill '*' for every skill, and a Claude Code plugin (/plugin install langchain-skills@langchain-skills) whose plugin.json points at the repo's 22 skills and lists no hooks or MCP servers.
Does it need an API key?
The skill itself does not. The agents it helps you write need a model key, and the LangChain README says to set OPENAI_API_KEY or ANTHROPIC_API_KEY before running your agent.
Does it cover structured output?
The description says so, but the SKILL.md body has no structured output section. Use another source for Pydantic or Zod response formats.
Is it safe?
The folder bundles no scripts, only SKILL.md with Python and TypeScript examples. The code it helps you write can send emails or call other tools, which is why the skill adds an approval step; review that code before you run it. The README warns the project is in early development.
Why does my approval flow fail?
The skill lists the usual causes: no checkpointer, no thread_id, or the wrong resume syntax. Each has a corrected example.
Does it work in Codex or Cursor?
The LangChain README says the skills install through npx skills for any agent that supports the Agent Skills format, and names Claude Code, Cursor, Windsurf, Codex and GitHub Copilot.
Information
updated Nov 2, 2026
- Repository
- langchain-ai/langchain-skills
- Folder
config/skills/langchain-middleware
Sources
Docs, issue trackers and discussions this page is built from.
Show all 2Hide
- langchain-middleware SKILL.md · github.com
- langchain-skills README · github.com