> ## Documentation Index
> Fetch the complete documentation index at: https://langchain-5e9cc07a-preview-codexf-1788227809-773f4d5.mintlify.site/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 all integrations table.
  </Card>
</CardGroup>

## Featured integrations

<div class="integration-downloads-table">
  | Provider                                                                       | Middleware available                                                                   | Source                                                                                                                                                                                      | Downloads                                                                                                                                                                                                                                               |
  | :----------------------------------------------------------------------------- | :------------------------------------------------------------------------------------- | :------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------ | :------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------ |
  | [`OpenAI middleware`](/oss/python/integrations/middleware/openai)              | Content moderation                                                                     | [`langchain-ai/langchain`](https://github.com/langchain-ai/langchain/tree/master/libs/partners/openai)                                                                                      | <span data-sort-value="68000000"><a href="https://pypi.org/project/langchain-openai/" target="_blank">  <img src="https://static.pepy.tech/badge/langchain-openai/month" alt="Downloads per month" noZoom class="rounded not-prose" /></a></span>       |
  | [`Anthropic middleware`](/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)                                                                                   | <span data-sort-value="22000000"><a href="https://pypi.org/project/langchain-anthropic/" target="_blank">  <img src="https://static.pepy.tech/badge/langchain-anthropic/month" alt="Downloads per month" noZoom class="rounded not-prose" /></a></span> |
  | [`AWS middleware`](/oss/python/integrations/middleware/aws)                    | Prompt caching and AgentCore Payments                                                  | [`langchain-ai/langchain-aws`](https://github.com/langchain-ai/langchain-aws/tree/main/libs/aws), [`aws/bedrock-agentcore-sdk-python`](https://github.com/aws/bedrock-agentcore-sdk-python) | <span data-sort-value="12000000"><a href="https://pypi.org/project/langchain-aws/" target="_blank">  <img src="https://static.pepy.tech/badge/langchain-aws/month" alt="Downloads per month" noZoom class="rounded not-prose" /></a></span>             |
  | [`Microsoft Foundry middleware`](/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)                                                                                   | <span data-sort-value="1000000"><a href="https://pypi.org/project/langchain-azure-ai/" target="_blank">  <img src="https://static.pepy.tech/badge/langchain-azure-ai/month" alt="Downloads per month" noZoom class="rounded not-prose" /></a></span>    |
  | [`NVIDIA middleware`](/oss/python/integrations/middleware/nvidia)              | Model routing and Nemotron 3 Ultra harness optimization                                | [`langchain-ai/langchain-nvidia`](https://github.com/langchain-ai/langchain-nvidia), [`langchain-ai/deepagents`](https://github.com/langchain-ai/deepagents)                                | <span data-sort-value="-1">N/A</span>                                                                                                                                                                                                                   |
</div>

## All middleware

<div class="integration-downloads-table">
  | Provider                                                                                                              | Middleware available                                                                                                                                                                                                                                                                                                                                                                     | Source                                                                                                                                                                                      | Downloads                                                                                                                                                                                                                                                            |
  | :-------------------------------------------------------------------------------------------------------------------- | :--------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------- | :------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------ | :------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------- |
  | [`OpenAI middleware`](/oss/python/integrations/middleware/openai)                                                     | Content moderation                                                                                                                                                                                                                                                                                                                                                                       | [`langchain-ai/langchain`](https://github.com/langchain-ai/langchain/tree/master/libs/partners/openai)                                                                                      | <span data-sort-value="68000000"><a href="https://pypi.org/project/langchain-openai/" target="_blank">  <img src="https://static.pepy.tech/badge/langchain-openai/month" alt="Downloads per month" noZoom class="rounded not-prose" /></a></span>                    |
  | [`Anthropic middleware`](/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)                                                                                   | <span data-sort-value="22000000"><a href="https://pypi.org/project/langchain-anthropic/" target="_blank">  <img src="https://static.pepy.tech/badge/langchain-anthropic/month" alt="Downloads per month" noZoom class="rounded not-prose" /></a></span>              |
  | [`AWS middleware`](/oss/python/integrations/middleware/aws)                                                           | Prompt caching and AgentCore Payments                                                                                                                                                                                                                                                                                                                                                    | [`langchain-ai/langchain-aws`](https://github.com/langchain-ai/langchain-aws/tree/main/libs/aws), [`aws/bedrock-agentcore-sdk-python`](https://github.com/aws/bedrock-agentcore-sdk-python) | <span data-sort-value="12000000"><a href="https://pypi.org/project/langchain-aws/" target="_blank">  <img src="https://static.pepy.tech/badge/langchain-aws/month" alt="Downloads per month" noZoom class="rounded not-prose" /></a></span>                          |
  | [`Microsoft Foundry middleware`](/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)                                                                                   | <span data-sort-value="1000000"><a href="https://pypi.org/project/langchain-azure-ai/" target="_blank">  <img src="https://static.pepy.tech/badge/langchain-azure-ai/month" alt="Downloads per month" noZoom class="rounded not-prose" /></a></span>                 |
  | [`CopilotKit`](/oss/python/langchain/frontend/integrations/copilotkit)                                                | CopilotKit middleware and FastAPI bridge for Deep Agents, create\_agent graphs, AG-UI, and the React and runtime clients                                                                                                                                                                                                                                                                 | [`CopilotKit/CopilotKit`](https://github.com/CopilotKit/CopilotKit)                                                                                                                         | <span data-sort-value="502000"><a href="https://pypi.org/project/copilotkit/" target="_blank">  <img src="https://static.pepy.tech/badge/copilotkit/month" alt="Downloads per month" noZoom class="rounded not-prose" /></a></span>                                  |
  | [`ISNAD`](https://github.com/alizahidraja/isnad)                                                                      | Claim-level provenance and trust grading for agent outputs. Grades every transmitter in a claim's chain (source, scraper, model) in a living registry, caps the chain at its weakest link, and quarantines fabricated (mawḍūʿ) chains—with a tamper-evident audit trail.                                                                                                                 | [`alizahidraja/isnad`](https://github.com/alizahidraja/isnad)                                                                                                                               | <span data-sort-value="17000"><a href="https://pypi.org/project/isnad/" target="_blank">  <img src="https://static.pepy.tech/badge/isnad/month" alt="Downloads per month" noZoom class="rounded not-prose" /></a></span>                                             |
  | [`xaidr`](https://github.com/delphisecurity/xaidr#langchain-middleware)                                               | In-process runtime security sensor for AI agents. LangChain middleware covering input, tool-call, and output boundaries for prompt injection, jailbreak, DLP, and A2A-protocol scanning.                                                                                                                                                                                                 | [`delphisecurity/xaidr`](https://github.com/delphisecurity/xaidr)                                                                                                                           | <span data-sort-value="5000"><a href="https://pypi.org/project/xaidr/" target="_blank">  <img src="https://static.pepy.tech/badge/xaidr/month" alt="Downloads per month" noZoom class="rounded not-prose" /></a></span>                                              |
  | [`PIIAnonymizationMiddleware`](https://athroniaeth.github.io/piighost/getting-started/langchain/)                     | Protect personal data (PII) in prompts, tool calls, and agent conversations. Hides sensitive values from the model, then restores the real values in the reply and at the tool boundary, so tools and the user still get the real data. Pluggable regex, NER, and LLM detectors, thread-consistent tokens, and token-by-token streaming restoration.                                     | [`Athroniaeth/piighost`](https://github.com/Athroniaeth/piighost)                                                                                                                           | <span data-sort-value="4000"><a href="https://pypi.org/project/piighost/" target="_blank">  <img src="https://static.pepy.tech/badge/piighost/month" alt="Downloads per month" noZoom class="rounded not-prose" /></a></span>                                        |
  | [`attenu-guard`](https://attenu.io/docs/example-langgraph/)                                                           | Per-agent permission enforcement on every tool call and subagent handoff through wrap\_tool\_call (a subagent's permissions are a computed subset of its parent's), with a hash-chained audit log verified offline                                                                                                                                                                       | [`attenu-io/attenu-guard`](https://github.com/attenu-io/attenu-guard)                                                                                                                       | <span data-sort-value="3000"><a href="https://pypi.org/project/attenu-guard/" target="_blank">  <img src="https://static.pepy.tech/badge/attenu-guard/month" alt="Downloads per month" noZoom class="rounded not-prose" /></a></span>                                |
  | [`Highflame`](https://github.com/highflame-ai/highflame-sdk)                                                          | Runtime AI security guardrails (prompt injection, PII/DLP, content safety) applied as middleware via Highflame Shield (OWASP LLM Top 10).                                                                                                                                                                                                                                                | [`highflame-ai/highflame-sdk`](https://github.com/highflame-ai/highflame-sdk)                                                                                                               | <span data-sort-value="3000"><a href="https://pypi.org/project/highflame/" target="_blank">  <img src="https://static.pepy.tech/badge/highflame/month" alt="Downloads per month" noZoom class="rounded not-prose" /></a></span>                                      |
  | [`ATLTaskMiddleware`](https://github.com/wenhua6666668-oss/langchain-agenttrafficlab#automatic-task-time-routing-v03) | Automatic task-time routing to executable MCP and provider capabilities, with failure redecision and outcome reporting.                                                                                                                                                                                                                                                                  | [`wenhua6666668-oss/langchain-agenttrafficlab`](https://github.com/wenhua6666668-oss/langchain-agenttrafficlab)                                                                             | <span data-sort-value="2000"><a href="https://pypi.org/project/langchain-agenttrafficlab/" target="_blank">  <img src="https://static.pepy.tech/badge/langchain-agenttrafficlab/month" alt="Downloads per month" noZoom class="rounded not-prose" /></a></span>      |
  | [`Nuggets Authority`](https://nuggets.life)                                                                           | Pre-execution authority enforcement for tool calls. Verifies a scoped, signed delegation before each tool runs, fails closed on deny, and emits an independently verifiable cryptographic proof of every decision.                                                                                                                                                                       | [`NuggetsLtd/langchain-nuggets`](https://github.com/NuggetsLtd/langchain-nuggets)                                                                                                           | <span data-sort-value="2000"><a href="https://pypi.org/project/langchain-nuggets/" target="_blank">  <img src="https://static.pepy.tech/badge/langchain-nuggets/month" alt="Downloads per month" noZoom class="rounded not-prose" /></a></span>                      |
  | [`prompt-shield`](https://github.com/mthamil107/prompt-shield)                                                        | Runtime prompt-injection firewall. Scans inputs, tool results, and outputs across detectors and output scanners with block, flag, and log modes.                                                                                                                                                                                                                                         | [`mthamil107/prompt-shield`](https://github.com/mthamil107/prompt-shield)                                                                                                                   | <span data-sort-value="2000"><a href="https://pypi.org/project/prompt-shield-ai/" target="_blank">  <img src="https://static.pepy.tech/badge/prompt-shield-ai/month" alt="Downloads per month" noZoom class="rounded not-prose" /></a></span>                        |
  | [`TealTiger`](https://docs.tealtiger.ai/integrations/langchain)                                                       | Deterministic governance middleware. Policy enforcement, cost limits, tool allowlisting, FREEZE rules, and SARIF audit evidence with no LLM in the governance path.                                                                                                                                                                                                                      | [`agentguard-ai/tealtiger`](https://github.com/agentguard-ai/tealtiger/tree/main/packages/langchain-tealtiger)                                                                              | <span data-sort-value="2000"><a href="https://pypi.org/project/langchain-tealtiger/" target="_blank">  <img src="https://static.pepy.tech/badge/langchain-tealtiger/month" alt="Downloads per month" noZoom class="rounded not-prose" /></a></span>                  |
  | [`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)                                                                                                     | <span data-sort-value="1000"><a href="https://pypi.org/project/advisor-middleware/" target="_blank">  <img src="https://static.pepy.tech/badge/advisor-middleware/month" alt="Downloads per month" noZoom class="rounded not-prose" /></a></span>                    |
  | [`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)                                                                                                     | <span data-sort-value="1000"><a href="https://pypi.org/project/compact-middleware/" target="_blank">  <img src="https://static.pepy.tech/badge/compact-middleware/month" alt="Downloads per month" noZoom class="rounded not-prose" /></a></span>                    |
  | [`langchain-runcycles`](https://runcycles.io)                                                                         | Pre-execution budget authority for model calls, tool calls, and agent loops                                                                                                                                                                                                                                                                                                              | [`runcycles/langchain-runcycles`](https://github.com/runcycles/langchain-runcycles)                                                                                                         | <span data-sort-value="1000"><a href="https://pypi.org/project/langchain-runcycles/" target="_blank">  <img src="https://static.pepy.tech/badge/langchain-runcycles/month" alt="Downloads per month" noZoom class="rounded not-prose" /></a></span>                  |
  | [`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)                                                                                               | <span data-sort-value="1000"><a href="https://pypi.org/project/langgraph-state-machine/" target="_blank">  <img src="https://static.pepy.tech/badge/langgraph-state-machine/month" alt="Downloads per month" noZoom class="rounded not-prose" /></a></span>          |
  | [`SeekritCredentials`](https://seekrit.dev/docs/guides/frameworks/langgraph#4-scope-a-key-to-one-tool)                | Scopes secrets per model call and per tool call. Credentials stay as placeholders in agent code and are substituted at the HTTP boundary against a default-deny allowlist, so an unlisted tool cannot reach a credential.                                                                                                                                                                | [`seekritdev/python-sdk`](https://github.com/seekritdev/python-sdk)                                                                                                                         | <span data-sort-value="987"><a href="https://pypi.org/project/seekrit/" target="_blank">  <img src="https://static.pepy.tech/badge/seekrit/month" alt="Downloads per month" noZoom class="rounded not-prose" /></a></span>                                           |
  | [`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)                                                                                     | <span data-sort-value="913"><a href="https://pypi.org/project/langchain-task-steering/" target="_blank">  <img src="https://static.pepy.tech/badge/langchain-task-steering/month" alt="Downloads per month" noZoom class="rounded not-prose" /></a></span>           |
  | [`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)                                                                                                                 | <span data-sort-value="827"><a href="https://pypi.org/project/langchain-router/" target="_blank">  <img src="https://static.pepy.tech/badge/langchain-router/month" alt="Downloads per month" noZoom class="rounded not-prose" /></a></span>                         |
  | [`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)                                                                   | <span data-sort-value="767"><a href="https://pypi.org/project/langchain-cisco-aidefense/" target="_blank">  <img src="https://static.pepy.tech/badge/langchain-cisco-aidefense/month" alt="Downloads per month" noZoom class="rounded not-prose" /></a></span>       |
  | [`RelayShield`](https://api.relayshield.net/developers)                                                               | Mandatory pre-execution gate that blocks connect\_mcp\_server and install\_mcp\_package tool calls when RelayShield reports risk.                                                                                                                                                                                                                                                        | [`nzdsf2-gif/langchain-relayshield`](https://github.com/nzdsf2-gif/langchain-relayshield)                                                                                                   | <span data-sort-value="663"><a href="https://pypi.org/project/langchain-relayshield/" target="_blank">  <img src="https://static.pepy.tech/badge/langchain-relayshield/month" alt="Downloads per month" noZoom class="rounded not-prose" /></a></span>               |
  | [`BastionGuardrailMiddleware`](https://bastionsoft.com)                                                               | Prompt-injection and jailbreak detection. Screens user input and tool results, including indirect injection through retrieved content, before the model runs. Runs locally on your own hardware.                                                                                                                                                                                         | [`bastion-soft/bastion-prompt-protection`](https://github.com/bastion-soft/bastion-prompt-protection)                                                                                       | <span data-sort-value="612"><a href="https://pypi.org/project/bastion-prompt-protection/" target="_blank">  <img src="https://static.pepy.tech/badge/bastion-prompt-protection/month" alt="Downloads per month" noZoom class="rounded not-prose" /></a></span>       |
  | [`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)                                                                                                             | <span data-sort-value="572"><a href="https://pypi.org/project/langchain-collapse/" target="_blank">  <img src="https://static.pepy.tech/badge/langchain-collapse/month" alt="Downloads per month" noZoom class="rounded not-prose" /></a></span>                     |
  | [`DeepKeep middleware`](https://docs.deepkeep.ai)                                                                     | DeepKeep AI Firewall pre-moderation and post-moderation for LangChain agents.                                                                                                                                                                                                                                                                                                            |                                                                                                                                                                                             | <span data-sort-value="548"><a href="https://pypi.org/project/langchain-deepkeep/" target="_blank">  <img src="https://static.pepy.tech/badge/langchain-deepkeep/month" alt="Downloads per month" noZoom class="rounded not-prose" /></a></span>                     |
  | [`NeuralTrust TrustGuard`](https://github.com/NeuralTrust/langchain-neuraltrust)                                      | TrustGuard evaluate middleware. Allow, block, report, or transform agent input, model output, and optional tool traffic.                                                                                                                                                                                                                                                                 | [`NeuralTrust/langchain-neuraltrust`](https://github.com/NeuralTrust/langchain-neuraltrust)                                                                                                 | <span data-sort-value="433"><a href="https://pypi.org/project/langchain-neuraltrust/" target="_blank">  <img src="https://static.pepy.tech/badge/langchain-neuraltrust/month" alt="Downloads per month" noZoom class="rounded not-prose" /></a></span>               |
  | [`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)                                                                                                   | <span data-sort-value="382"><a href="https://pypi.org/project/text2sql-framework/" target="_blank">  <img src="https://static.pepy.tech/badge/text2sql-framework/month" alt="Downloads per month" noZoom class="rounded not-prose" /></a></span>                     |
  | [`AxioRank`](https://axiorank.com/docs/integrations/langchain)                                                        | Security gateway for AI agents: score tool calls and model turns against policy with allow, deny, and redact.                                                                                                                                                                                                                                                                            | [`AxioRank/langchain-axiorank`](https://github.com/AxioRank/langchain-axiorank)                                                                                                             | <span data-sort-value="306"><a href="https://pypi.org/project/langchain-axiorank/" target="_blank">  <img src="https://static.pepy.tech/badge/langchain-axiorank/month" alt="Downloads per month" noZoom class="rounded not-prose" /></a></span>                     |
  | [`Pydantic Monty Code Interpreter`](https://github.com/shane-rand/langchain-monty)                                    | Provides Code Interpretation inside Pydantic's Monty Runtime                                                                                                                                                                                                                                                                                                                             | [`langchain-monty`](https://github.com/shane-rand/langchain-monty)                                                                                                                          | <span data-sort-value="305"><a href="https://pypi.org/project/langchain-monty/" target="_blank">  <img src="https://static.pepy.tech/badge/langchain-monty/month" alt="Downloads per month" noZoom class="rounded not-prose" /></a></span>                           |
  | [`OpenBox`](https://docs.openbox.ai/getting-started/langgraph)                                                        | Real-time governance for LangGraph and Deep Agents. Policies, guardrails, HITL, OTel hook governance, and behavior rules.                                                                                                                                                                                                                                                                | [`OpenBox-AI/openbox-langgraph-sdk-python`](https://github.com/OpenBox-AI/openbox-langgraph-sdk-python)                                                                                     | <span data-sort-value="255"><a href="https://pypi.org/project/openbox-langgraph-sdk-python/" target="_blank">  <img src="https://static.pepy.tech/badge/openbox-langgraph-sdk-python/month" alt="Downloads per month" noZoom class="rounded not-prose" /></a></span> |
  | [`Tessera`](https://github.com/kenithphilip/Tessera)                                                                  | Signed trust labels and taint-tracking that gate tool calls when context contains untrusted segments.                                                                                                                                                                                                                                                                                    | [`kenithphilip/Tessera`](https://github.com/kenithphilip/Tessera)                                                                                                                           | <span data-sort-value="255"><a href="https://pypi.org/project/tessera-mesh/" target="_blank">  <img src="https://static.pepy.tech/badge/tessera-mesh/month" alt="Downloads per month" noZoom class="rounded not-prose" /></a></span>                                 |
  | [`langchain-distil`](https://github.com/dshakes/distil)                                                               | Reversible, certified context compression. Digests large tool outputs and message history before the model call (tool and function messages reversibly, human and system losslessly, the model messages never rewritten), with byte-exact recovery of every digest. Decision-equivalence between compressed and full context is certified offline by a statistical non-inferiority gate. | [`dshakes/distil`](https://github.com/dshakes/distil)                                                                                                                                       | <span data-sort-value="182"><a href="https://pypi.org/project/langchain-distil/" target="_blank">  <img src="https://static.pepy.tech/badge/langchain-distil/month" alt="Downloads per month" noZoom class="rounded not-prose" /></a></span>                         |
  | [`comply54`](https://comply54.io/langchain)                                                                           | Runtime compliance enforcement for AI agents under African data protection and financial-sector regulations (deny, escalate, audit, or allow).                                                                                                                                                                                                                                           | [`comply54/langchain-comply54`](https://github.com/comply54/langchain-comply54)                                                                                                             | <span data-sort-value="158"><a href="https://pypi.org/project/langchain-comply54/" target="_blank">  <img src="https://static.pepy.tech/badge/langchain-comply54/month" alt="Downloads per month" noZoom class="rounded not-prose" /></a></span>                     |
  | [`langchain-pop`](https://github.com/joy7758/persona-object-protocol/tree/main/integrations/langchain-pop)            | Portable persona loading, legacy migration, and boundary-aware tool filtering for LangChain agents.                                                                                                                                                                                                                                                                                      | [`joy7758/persona-object-protocol`](https://github.com/joy7758/persona-object-protocol/tree/main/integrations/langchain-pop)                                                                | <span data-sort-value="138"><a href="https://pypi.org/project/langchain-pop/" target="_blank">  <img src="https://static.pepy.tech/badge/langchain-pop/month" alt="Downloads per month" noZoom class="rounded not-prose" /></a></span>                               |
  | [`OWASP Agent Memory Guard`](https://owasp.org/www-project-agent-memory-guard/)                                       | Runtime defense against AI agent memory poisoning (OWASP ASI06). Scans messages, model responses, and tool outputs locally with block, warn, and strip modes.                                                                                                                                                                                                                            | [`OWASP/www-project-agent-memory-guard`](https://github.com/OWASP/www-project-agent-memory-guard/tree/main/integrations/langchain-agent-memory-guard)                                       | <span data-sort-value="132"><a href="https://pypi.org/project/langchain-agent-memory-guard/" target="_blank">  <img src="https://static.pepy.tech/badge/langchain-agent-memory-guard/month" alt="Downloads per month" noZoom class="rounded not-prose" /></a></span> |
  | [`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)                                                                             | <span data-sort-value="127"><a href="https://pypi.org/project/langchain-nopii-middleware/" target="_blank">  <img src="https://static.pepy.tech/badge/langchain-nopii-middleware/month" alt="Downloads per month" noZoom class="rounded not-prose" /></a></span>     |
  | [`DNS-AID`](https://github.com/IngmarVG-IB/langchain-dns-aid)                                                         | DNS-based agent discovery via the DNS-AID protocol. Auto-publishes agents on startup, auto-unpublishes on shutdown, and provides discovery tools.                                                                                                                                                                                                                                        | [`IngmarVG-IB/langchain-dns-aid`](https://github.com/IngmarVG-IB/langchain-dns-aid)                                                                                                         | <span data-sort-value="124"><a href="https://pypi.org/project/langchain-dns-aid/" target="_blank">  <img src="https://static.pepy.tech/badge/langchain-dns-aid/month" alt="Downloads per month" noZoom class="rounded not-prose" /></a></span>                       |
  | [`VecrContextCompressor`](https://github.com/h2cker/vecr)                                                             | Deterministic LLM context compression with a regex retention whitelist for structured tokens before the model call.                                                                                                                                                                                                                                                                      | [`h2cker/vecr`](https://github.com/h2cker/vecr)                                                                                                                                             | <span data-sort-value="93"><a href="https://pypi.org/project/vecr-compress/" target="_blank">  <img src="https://static.pepy.tech/badge/vecr-compress/month" alt="Downloads per month" noZoom class="rounded not-prose" /></a></span>                                |
  | [`ATR Guardrail`](https://github.com/Agent-Threat-Rule/agent-threat-rules/tree/main/integrations/langchain)           | Runtime detection of prompt injection, tool poisoning, and unsafe tool calls using Agent Threat Rules. Halts the agent or blocks the tool call on a critical finding and keeps an audit trail.                                                                                                                                                                                           | [`Agent-Threat-Rule/agent-threat-rules`](https://github.com/Agent-Threat-Rule/agent-threat-rules/tree/main/integrations/langchain)                                                          | <span data-sort-value="-1">N/A</span>                                                                                                                                                                                                                                |
  | [`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)                                                                                                             | <span data-sort-value="-1">N/A</span>                                                                                                                                                                                                                                |
  | [`Haldir`](https://github.com/ExposureGuard/haldir/tree/main/integrations/langchain-haldir)                           | Governance layer for LangChain agents with scoped sessions, encrypted secrets, hash-chained audit, and policy enforcement.                                                                                                                                                                                                                                                               | [`ExposureGuard/haldir`](https://github.com/ExposureGuard/haldir/tree/main/integrations/langchain-haldir)                                                                                   | <span data-sort-value="-1">N/A</span>                                                                                                                                                                                                                                |
  | [`NVIDIA middleware`](/oss/python/integrations/middleware/nvidia)                                                     | Model routing and Nemotron 3 Ultra harness optimization                                                                                                                                                                                                                                                                                                                                  | [`langchain-ai/langchain-nvidia`](https://github.com/langchain-ai/langchain-nvidia), [`langchain-ai/deepagents`](https://github.com/langchain-ai/deepagents)                                | <span data-sort-value="-1">N/A</span>                                                                                                                                                                                                                                |
</div>

<Info>
  If you'd like to contribute an integration, see [Contributing integrations](/oss/python/contributing#add-a-new-integration).
</Info>

***

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