> ## Documentation Index
> Fetch the complete documentation index at: https://docs.langchain.com/llms.txt
> Use this file to discover all available pages before exploring further.

# Middleware integrations

> Integrate with middleware using LangChain Python.

Browse available middleware for different providers or contribute your own to the ecosystem. Learn more about how middleware works in the [middleware overview](/oss/python/langchain/middleware/overview) and how to use middleware with Deep Agents in the [Deep Agents docs](/oss/python/deepagents/customization#middleware).

## 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:

<CardGroup cols={2}>
  <Card title="Add an official integration" icon="package" href="/oss/python/contributing/implement-langchain#middleware">
    Follow the contributing guide to build and publish a middleware package.
  </Card>

  <Card title="Share a community middleware" icon="users" href="https://github.com/langchain-ai/docs">
    Open a PR to the docs repo to add your middleware to the table below.
  </Card>
</CardGroup>

## Official integrations

| Provider                                                          | Middleware available                                                                   | Source                                                                                                    |
| ----------------------------------------------------------------- | -------------------------------------------------------------------------------------- | --------------------------------------------------------------------------------------------------------- |
| [Anthropic](/oss/python/integrations/middleware/anthropic)        | Prompt caching, bash tool, text editor, memory, and file search                        | [`langchain-ai/langchain`](https://github.com/langchain-ai/langchain/tree/master/libs/partners/anthropic) |
| [AWS](/oss/python/integrations/middleware/aws)                    | Prompt caching                                                                         | [`langchain-ai/langchain-aws`](https://github.com/langchain-ai/langchain-aws/tree/main/libs/aws)          |
| [Microsoft Foundry](/oss/python/integrations/middleware/azure_ai) | Text moderation, image moderation, prompt shield, protected material, and groundedness | [`langchain-ai/langchain-azure`](https://github.com/langchain-ai/langchain-azure/tree/main/libs/azure-ai) |
| [OpenAI](/oss/python/integrations/middleware/openai)              | Content moderation                                                                     | [`langchain-ai/langchain`](https://github.com/langchain-ai/langchain/tree/master/libs/partners/openai)    |

## Community integrations

| Middleware                                                                              | Description                                                                                                                                                  | Source                                                                                                                    |
| --------------------------------------------------------------------------------------- | ------------------------------------------------------------------------------------------------------------------------------------------------------------ | ------------------------------------------------------------------------------------------------------------------------- |
| [Cisco AI Defense](https://github.com/cisco-ai-defense/ai-defense-langchain-middleware) | Runtime security inspection                                                                                                                                  | [`cisco-ai-defense/ai-defense-langchain-middleware`](https://github.com/cisco-ai-defense/ai-defense-langchain-middleware) |
| [compact-middleware](https://github.com/emanueleielo/compact-middleware)                | Claude Code's compaction engine as LangChain middleware. Multi-level context compaction for long-running agents.                                             | [`emanueleielo/compact-middleware`](https://github.com/emanueleielo/compact-middleware)                                   |
| [langchain-collapse](https://github.com/johanity/langchain-collapse)                    | Preventive context management. Collapses consecutive tool-call groups before they fill the context window.                                                   | [`johanity/langchain-collapse`](https://github.com/johanity/langchain-collapse)                                           |
| [langchain-task-steering](https://github.com/edvinhallvaxhiu/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`](https://github.com/edvinhallvaxhiu/langchain-task-steering)                   |
| [advisor-middleware](https://github.com/emanueleielo/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`](https://github.com/emanueleielo/advisor-middleware)                                   |
| [langchain-router](https://github.com/johanity/langchain-router)                        | Phase-based model routing. Routes execution turns to a fast model, keeps the primary for planning and recovery.                                              | [`johanity/langchain-router`](https://github.com/johanity/langchain-router)                                               |

***

<div className="source-links">
  <Callout icon="terminal-2">
    [Connect these docs](/use-these-docs) to Claude, VSCode, and more via MCP for real-time answers.
  </Callout>

  <Callout icon="edit">
    [Edit this page on GitHub](https://github.com/langchain-ai/docs/edit/main/src/oss/python/integrations/middleware/index.mdx) or [file an issue](https://github.com/langchain-ai/docs/issues/new/choose).
  </Callout>
</div>
