Share your middleware
Middleware enables context engineering, harness customization, and runtime safety controls. It is a useful extension point in LangChain and we love highlighting what the community builds with it:Add an official integration
Follow the contributing guide to build and publish a middleware package.
Share a community middleware
Open a PR to the docs repo to add your middleware to the table below.
Official integrations
| Provider | Middleware available | Source |
|---|---|---|
| Anthropic | Prompt caching, bash tool, text editor, memory, and file search | langchain-ai/langchain |
| AWS | Prompt caching | langchain-ai/langchain-aws |
| Microsoft Foundry | Text moderation, image moderation, prompt shield, protected material, and groundedness | langchain-ai/langchain-azure |
| OpenAI | Content moderation | langchain-ai/langchain |
Community integrations
| Middleware | Description | Source |
|---|---|---|
| Cisco AI Defense | Runtime security inspection | cisco-ai-defense/ai-defense-langchain-middleware |
| compact-middleware | Claude Code’s compaction engine as LangChain middleware. Multi-level context compaction for long-running agents. | emanueleielo/compact-middleware |
| langchain-collapse | Preventive context management. Collapses consecutive tool-call groups before they fill the context window. | johanity/langchain-collapse |
| langchain-task-steering | Implicit state-machine middleware for ordered task pipelines with per-task tool scoping, dynamic prompt injection, and composable completion validation. | edvinhallvaxhiu/langchain-task-steering |
| advisor-middleware | Claude Code’s advisor pattern as LangChain middleware. Pairs a fast executor model with a powerful advisor model that intervenes only on critical decisions. | emanueleielo/advisor-middleware |
| langchain-router | Phase-based model routing. Routes execution turns to a fast model, keeps the primary for planning and recovery. | johanity/langchain-router |
Connect these docs to Claude, VSCode, and more via MCP for real-time answers.

