Middleware for Managed Deep Agents
Sep 16, 2026LangChain
Summary
The post introduces and demonstrates middleware for LangChain's Managed Deep Agents. It showcases the use of prebuilt PIIMiddleware to redact sensitive customer data (like emails) before it is processed by an LLM, ensuring privacy. Additionally, it provides a practical example of building a custom logging middleware from scratch using the `wrap_tool_call` decorator, illustrating how to extend agent lifecycles with custom logic for policy enforcement, fault tolerance, and rate limiting.