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

<Note>
  The community maintains these middleware integrations. They are contributed on an open-source basis and are not managed or maintained by LangChain.
</Note>

| 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)                                               |
| [CopilotKit](/oss/python/langchain/frontend/integrations/copilotkit)                             | CopilotKit `CopilotKitMiddleware` and FastAPI bridge for [Deep Agents](/oss/python/deepagents/overview), `create_agent` graphs, AG-UI, and the React and runtime clients.                              | [`CopilotKit/CopilotKit`](https://github.com/CopilotKit/CopilotKit)                                                       |
| [eager-tools](https://github.com/cloudthinker-ai/eager-tools)                                    | Reduces agent wall-clock latency by dispatching each tool call the moment its streaming block closes, overlapping tool execution with LLM generation.                                                  | [`cloudthinker-ai/eager-tools`](https://github.com/cloudthinker-ai/eager-tools)                                           |
| [NoPII](https://github.com/Enigma-Vault/NoPII/tree/main/integrations/langchain-nopii-middleware) | Runtime PII tokenization. Detects personal data in outbound prompts, replaces it with deterministic vault tokens before the request reaches the LLM, and restores the original values in the response. | [`Enigma-Vault/NoPII`](https://github.com/Enigma-Vault/NoPII/tree/main/integrations/langchain-nopii-middleware)           |
| [langgraph-state-machine](https://github.com/mahmoud661/langgraph-state-machine)                 | Section-based flow control for LangGraph React agents. Divides conversations into discrete phases with scoped tools, prompts, auto-transitions, branching, and optional per-section LLM override.      | [`mahmoud661/langgraph-state-machine`](https://github.com/mahmoud661/langgraph-state-machine)                             |
| [text2sql-framework](https://github.com/Text2SqlAgent/text2sql-framework)                        | Replaces RAG with recursive tool use — the agent explores, writes, tests, and self-corrects using one `execute_sql` tool.                                                                              | [`Text2SqlAgent/text2sql-framework`](https://github.com/Text2SqlAgent/text2sql-framework)                                 |

***

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