
Langchain Middleware
langchain-ai/langchain-skillsOfficial
For production LangChain agents that need human oversight on risky operations like sending emails or deleting data. Sets up human-in-the-loop middleware that pauses execution before dangerous tool calls, letting humans approve, edit arguments, or reject with feedback. Also covers custom middleware hooks for logging, retries, and error handling. The resume pattern with Command objects handles the back-and-forth flow cleanly. Requires a checkpointer and thread_id configuration, which trips up developers initially but makes sense once you need to pause and resume agent execution across different processes.
- skills.sh installs
- 17K
- GitHub stars
- 1.3K
- last updated
- Aug 21, 2026
Install
$ npx -y skills add langchain-ai/langchain-skills --skill langchain-middleware --agent claude-codeInstalls into .claude/skills of the current project.
Files
Middleware patterns for production LangChain agents:
- HumanInTheLoopMiddleware / humanInTheLoopMiddleware: Pause before dangerous tool calls for human approval
- Custom middleware: Intercept tool calls for error handling, logging, retry logic
- Command resume: Continue execution after human decisions (approve, edit, reject)
Requirements: Checkpointer + thread_id config for all HITL workflows.
Human-in-the-Loop
Set up an agent with HITL middleware that pauses before sending emails for approval.from langchain.agents import create_agent
from langchain.agents.middleware import HumanInTheLoopMiddleware
from langgraph.checkpoint.memory import MemorySaver
from langchain.tools import tool
@tool
def send_email(to: str, subject: str, body: str) -> str:
"""Send an email."""
return f"Email sent to {to}"
Sponsors
Promote your product hereReach 125k+ visitors monthlyPromote your product hereReach 125k+ visitors monthly
Agent CaffeineSponsoredClose your lid, come back to finished work
SnugSponsoredThe clipboard manager for the AI eraPromote your product hereReach 125k+ visitors monthly
WaxSponsoredBlock anything with supervision, without erasing your iPhonePromote your product hereReach 125k+ visitors monthly
knobsSponsoredSee your site on any phone, any day, in any language
Details
- Repository
- github.com/langchain-ai/langchain-skills
- Categories
- Frontend Development, Backend & APIs, AI & Agent Building, Python
More from langchain-ai/langchain-skills
All 15- Deep Agents Orchestration16.8K
- Langchain Dependencies16.8K
- Deep Agents Core16.7K
- Managed Deep Agents10K
- Langgraph Cli9.7K
- Swarm9.5K
- Ecosystem Primer8.8K
- Framework Selection7.7K
- Deep Agents Memory19.8K
- Langgraph Fundamentals18.9K
- Langgraph Persistence18.8K
- Langchain Rag18.4K
- Langchain Fundamentals18.2K
- Langgraph Human In The Loop18K
Recommended
More Frontend Development1
healthtw93/wazaRuns a budget-aware agent-assisted engineering health audit for instruction/config drift, hooks/MCP, verifier surfaces, and AI maintainability. Use when users a16.4Kskills.sh installs
2
gpt-image-2agentspace-so/runcomfy-agent-skillsImage generation and editing with OpenAI's GPT Image 2, optimized for embedded text, logos, and layout precision.16Kskills.sh installs
3
nature-readeryuan1z0825/nature-skillsBuild full-paper Chinese-English side-by-side, figure/table/equation-aware, source-grounded Markdown readers for journal or conference papers from PDF, DOI, arX15.9Kskills.sh installs
4
building-componentsvercel/components.buildGuide for building modern, accessible, and composable UI components. Use when building new components, implementing accessibility, creating composable APIs, set15.1Kskills.sh installs
5
clerk-swiftclerk/skillsImplement Clerk authentication for native Swift and iOS apps using ClerkKit and ClerkKitUI source-guided patterns. Use for prebuilt AuthView or custom native fl15Kskills.sh installs
6
fastapifastapi/fastapiFastAPI best practices and conventions. Use when working with FastAPI APIs, Pydantic models, dependencies, streaming responses including Server-Sent Events (SSE14.9Kskills.sh installs