Section Insights
Introduction to Managed Deep Agents
What is the purpose of this video?
The video serves as a quick start guide for managed deep agents, outlining the basic setup and components involved.
- The video will cover the quick start for managed deep agents.
- Future videos will explore different components in detail.
- Creating a Langmith API key is a prerequisite.
Project Setup and File Structure
What files are created when setting up a new project?
The project setup creates several files including environment variables, a README, core agent definitions, and a sandbox folder.
- The project includes essential files like agent.py and instructions.py.
- Environment dependencies are listed in piprototl.
- The setup process is crucial for organizing the agent's structure.
Configuring Agent Instructions
How do you define the agent's behavior?
The agent's behavior is defined by editing the instructions in a markdown file, which will be used as context during its operation.
- Instructions are crucial for guiding the agent's responses.
- The agent's context window is populated with the defined instructions.
- Customization of the agent's name is important for deployment.
Running the Agent Locally
What steps are involved in running the agent locally?
To run the agent locally, dependencies are installed, and a local development server is started, allowing for interaction and testing.
- Running the agent locally facilitates quick testing and iteration.
- The local environment provides a user-friendly interface for interaction.
- Initial commands are necessary to set up the local server.
Deploying the Agent
What is the process for deploying the agent?
Deploying the agent involves syncing context to the context hub and creating a deployment that can be accessed through the Langmith UI.
- Deployment allows for real-time updates to the agent's instructions and skills.
- The context hub stores all relevant information for the agent.
- A paid Langmith account is required for deployment.
Transcript
0:00 In this video, we're going to walk through a managed deep agents quick start. This will help us get up and running with managed deep agents and understand the basic primitives. In future videos, we'll dive deep into all of the different components that you can use in managed deep agents. If you haven't already done so, go and create a Langmith API key in your Langmith or you can do this by going to settings and then creating an API key.
0:25 After that, let's come back to this quick start. You can do this quick start in either Python or TypeScript. I'm going to do it in Python, but it's pretty similar whether you do it in TypeScript. To follow along, I'm just going to need Python and UV installed. If you don't already have UV, you can go to docs.astal.sh and install it from there. You're also going to need an API key for your model provider of choice. I'm going to use OpenAI for this tutorial, and so I'm going to need an OpenAI API key.
0:56 So, first I'm going to install manage deep agents, create a project, and open its directory. So, let's run these commands one at a time. Let's go over to my terminal here. UV tool install manage deep agents. I can see that it's installed and it's got this MDA executable. We'll use that later on. I'm going to use it right now. In fact, I'm going to do MDA innit. And then research assistant is the name of the project that I want to create. So I'm going to do this and it's going to create this research assistant folder right here. You'll notice that it also found a lang API key in my environment and it put it in this end file. So if we look at the files that it created, we can see it right here. It's got this is going to be a bunch of environment variables and so this is where it put my linksmith API key. It's got a git ignore, so a basic git ignore to ignore files that it doesn't need. It's got a readme.md, which we'll describe the agent. It's got agent.py, Pi and we'll see that in a little bit and that contains the core agent definition. It's got identity.py. This we'll actually go into in a future video where we dive deep into identity. We won't touch this for now. It's got instructions.py.
2:03 This we will touch. These are the core instructions of the agent and they're easily editable and it's a markdown file. You'll notice it's got piprototl. These are all the different environment dependencies that are needed to set up the agent. And then finally, it's got this sandbox folder. And we'll dive deep into this in a future video as well. So after this, I'm going to change directories to go into this research assistant folder. Awesome. And now this is all the scaffolding for my agent. So now I'm going to add API keys to this agent. So I'm going to open up the agent in IDE of my choice. I'm going to use PyCharm, but you can use whatever you want. And in this end file, I'm going to add my OpenAI API key because that's what I need. If you choose to use a different model, you can add a different API key for the provider of your choice. After that, if you haven't already set up Linksmith, you should do this now. I did this at the start of the video, so I'm going to ignore this. But if you haven't, you can just add your Linksmith API key directly to the M file as well.
3:06 The first thing we're going to edit are the instructions. So, we're going to open up instructions.mmd. And this describes how the agent should behave. So, if we open this up, we'll see that it has a super simple description of what the assistant is. We're going to add a slightly more detailed one, although it's still not nearly as detailed enough as you would want. And let's paste it here. And now, when our agent runs, it will run with these instructions in mind. So, whatever you put here will be put automatically into the context window of the agent as it runs. So, this defines the agent's instructions.
3:41 Now we can configure our model and search tool. So what we're going to do is we're going to choose the model we want to use. So there's some snippets here for OpenAI and Google and Anthropic, but there's a lot of other models you can choose and we'll dive into this later on. We can toggle here. And then we're also going to define a tool for it to use. So specifically, we're going to give it a web search type of tool. So let's copy this snippet and let's open up our agent.py pi file and let's paste it here.
4:10 Great. One other part to pay attention to is this name parameter here. So this name defines the name of the agent that we're going to deploy. If you want to deploy multiple agents, you'll want to name them different things. In this case, let's change the name so we can see how this shows up later on when we actually do the deployment of the agent. So let's change this to something like research assistant-1. Now, we're going to run it locally. And so, what this will do is this will run the agent locally and give us a nice studio for us to interact with the agent in. So, we can test it out, edit it locally, test it out again, and iterate on it quickly here.
4:52 So, let's copy these two commands. Let's run them in our terminal. UV sync first is going to install all my dependencies and then MDA dev is going to spin up this local development server for my agent. So we can see the server spinning up here and it's going to open this file in my web browser. So this is our nice lang studio. This is how you can interact with agents that you've deployed. So let's say something simple like hi. And we can see that it's running and then it responds. And now let's ask it something where it needs to use its web search. So let's ask it something like what was the latest lang chain release and what was in it.
5:48 We can see it's spinning. It's doing work. We can see that it calls the web search tool. It calls it again. It calls it again. So, it's doing a bunch of searching and then it starts to generate the answer. We can see the answer stream out here and then it gives us a detailed announcement on Langchain 1.3.15. Perfect. So, coming back to the quick start, we're going to do the final step, which is to deploy the agent. In order to do this, you are going to need a paid Langmith account. So, if you don't have one, you can skip it, but I'm going to do this for those of you who do. Let's copy this command, go to our terminal, and paste it in.
6:33 We'll see that it does a few things. First, we'll see that it syncs context to the context hub. Contexthub, and I'll show what this is in a second, but context hub is a place in Langmith where all of the instructions and skills and other context is stored. you can then actually edit it from the UI. And so this makes it possible to change the instructions or skills of the agent from the UI and have that affect the agent that's running without having to redeploy it at all. After that, it goes ahead and it's starting to create this deployment. And so we can see it building here. If we go to Langmith and we take a look at our deployments page, we can see that we have this research assistant one here. So remember when I changed the name to research assistant one, this is where it shows up. It shows up as the deployment name. If we click in here, we can see that it's still building the agent. We can now see in the UI that it's deployed. And if we go back to the terminal, we see the same thing. And finally, we can connect to this now. So, if we click this connect button and if we click open in studio, it now brings us to the same UI that we had locally where we have a studio where we can interact with the agent.
7:39 So, let's test it out. And we can see that it runs and responds here. And so, again, this is connected to your production deployment. is connected to your deployment back here. And so in fact, if we go back to this deployment and click into here and we see that we can see this trace showing up. Great. So this finishes the quick start for manage deep agents. In the next few videos, we're going to dive into a bunch of advanced components for manage deep agents, different ways you can configure it and give it functionality and use it.
8:08 So follow along. Let's continue.
Summary
- Create a Langmith API key and install the necessary tools (Python and UV).
- Set up a project using the command line to initialize a research assistant agent.
- Modify the agent's instructions and API keys in the provided files.
- Configure the model and tools, including a web search tool for the agent.
- Run the agent locally to interact with it through a web interface.
- Deploy the agent to Langmith, requiring a paid account for deployment.
- Use the context hub in Langmith to manage agent instructions and skills dynamically.
- Future videos will explore advanced configurations and functionalities of managed deep agents.
Questions Answered
What is the purpose of this video?
The video serves as a quick start guide for managed deep agents, outlining the basic setup and components involved.
What files are created when setting up a new project?
The project setup creates several files including environment variables, a README, core agent definitions, and a sandbox folder.
How do you define the agent's behavior?
The agent's behavior is defined by editing the instructions in a markdown file, which will be used as context during its operation.
What steps are involved in running the agent locally?
To run the agent locally, dependencies are installed, and a local development server is started, allowing for interaction and testing.
What is the process for deploying the agent?
Deploying the agent involves syncing context to the context hub and creating a deployment that can be accessed through the Langmith UI.