Introduction to Langchain Deep Agents LangChain has introduced Managed Deep Agents, a framework that provides a batteries-included approach to building AI agents with tool usage, context management, and subagent delegation. The article demonstrates using Deep Agents to automate a supply chain stockout risk analysis, where an agent reads inventory data, calculates days-of-cover, and drafts alert emails, reducing manual effort in S&OP cycles. Langchain introduced Managed Deep Agents a few days ago. In this article, I will go through the basics of Deep Agents and use them in a simple use case. Many of you reading this article will be familiar with agents. Agents are programs that are designed to achieve an output based on instructions provided by the user. Agents are special because they can use tools like a normal person would. Deep Agents is a framework created by LangChain which gives us a batteries-included approach to creating AI agents. It supports all the important features which an agent needs — tool usage, context management and delegation of tasks to subagents. In other words, Deep Agents provides a “harness” which acts as a guiding principle for the agent. It ends up saving us a lot of time and effort while creating agents. I’ll consider a simple supply chain problem. A planner has a small spreadsheet with current inventory, average daily demand, and supplier lead time for a handful of SKUs. Instead of manually calculating which items are at risk of stocking out, they ask a Deep Agent: “Look at this inventory file and tell me which SKUs are at risk of stockout in the next 2 weeks, and draft an alert email for the ones that are critical.” Anyone who has run an S&OP cycle knows the real bottleneck isn’t the math, it’s the manual grind. Pulling inventory numbers, checking them against the demand forecast, deciding what’s urgent and then writing up an email or report so someone else can act on it. Each step is simple. Doing all of them, correctly and on time, every single day, is where things break down. This is where something like an agent can help because it can plan out its tasks and approach the problem just like a junior analyst would. In this example I will use Managed Deep Agents. It is an offering from LangChain which bundles the agent harness and the infrastructure into a platform so that I can focus more on the business part of the problem. I don’t have to worry about deploying the agent as it will be available in LangSmith deployments. And I’ll be able to use a UI for changing things around which can be quite useful. I’ll explain things as I go through this article. First, we need to set up everything needed to run our agent. We need the following things for running Deep Agents I am going to assume that you know how to get these. It’s actually quite simple. There are tons of videos on YouTube on how to do this. I like putting a lot of comments in the code to make sure I don’t miss anything if I make any changes to it later. First, I’ll open VSCode and create a virtual environment using the terminal. You need to make sure you have uv installed in your system . bash $ uv tool install managed-deepagents$ mda init stockout-watcher$ cd stockout-watcher This creates a basic scaffold for the project. My final project structure will look something like the one shown below. stockout-watcher/├── agent.py Core agent definition├── instructions.md Managed context├── identity.py├── pyproject.toml├── tools ├── init.py ├── check stockout risk.py ├── send mail.py Dependencies and secrets├── .env I’ll add the API keys to my .env file. LANGSMITH API KEY=