Uploaded September 2026 | Updated November 2026, 1 day ago
Nathan Drezner, PM at LangChain, walks through middleware for Managed Deep Agents, the layer that lets you extend your agent's lifecycle with custom behavior like policy enforcement, fault tolerance, and rate limits. He demos adding the prebuilt PIIMiddleware to redact a customer email before it ever reaches the LLM, then builds a custom logging middleware from scratch using the wrap_tool_call decorator.
Chapters:
0:00 What middleware does for managed deep agents
0:36 Common middleware use cases
0:52 Demo setup: redacting a customer email
1:03 Baseline agent behavior with no middleware
1:31 Adding PIIMiddleware to the agent definition
1:51 Re-running the same question with middleware on
2:01 Watching PIIMiddleware redact the email live
2:18 Confirming the email never reaches LangSmith
2:35 When to reach for prebuilt PII middleware
2:51 Writing custom middleware with wrap_tool_call
3:37 Adding custom middleware to the agent definition
3:44 Testing the custom logging middleware live
4:12 Built in vs custom middleware, and where to go next
Resources:
→ Managed Deep Agents middleware docs: docs.langchain.com/langsmith/python/managed-deep-agents-middleware
→ LangGraph: langchain.com/langgraph
→ LangSmith: langchain.com/langsmith
→ LangChain Academy: academy.langchain.com
Nathan Drezner, PM at LangChain, walks through middleware for Managed Deep Agents, the layer that lets you extend your agent's lifecycle with custom behavior like policy enforcement, fault tolerance, and rate limits. He demos adding the prebuilt PIIMiddleware to redact a customer email before it ever reaches the LLM, then builds a custom logging middleware from scratch using the wrap_tool_call decorator.
Chapters:
0:00 What middleware does for managed deep agents
0:36 Common middleware use cases
0:52 Demo setup: redacting a customer email
1:03 Baseline agent behavior with no middleware
1:31 Adding PIIMiddleware to the agent definition
1:51 Re-running the same question with middleware on
2:01 Watching PIIMiddleware redact the email live
2:18 Confirming the email never reaches LangSmith
2:35 When to reach for prebuilt PII middleware
2:51 Writing custom middleware with wrap_tool_call
3:37 Adding custom middleware to the agent definition
3:44 Testing the custom logging middleware live
4:12 Built in vs custom middleware, and where to go next
Resources:
→ Managed Deep Agents middleware docs: docs.langchain.com/langsmith/python/managed-deep-agents-middleware
→ LangGraph: langchain.com/langgraph
→ LangSmith: langchain.com/langsmith
→ LangChain Academy: academy.langchain.com










