transcribe

Managed Deep Agents - Instructions and Context Hub

LangChain · 5m · transcribed 14d ago
More from LangChain Business
𝕏 Share ▶ YouTube 📥 PDF 🤖 .md

Section Insights

# 0:00

Understanding Instructions in Managed D Agents

What role do instructions play in managed D agents?

Instructions define the behavior of managed D agents and can be modified without redeploying code through the context hub.

  • Instructions are crucial for defining agent behavior.
  • Changes can be made in the context hub without code redeployment.
  • The instructions.md file is where agent instructions are stored.
# 1:08

Impact of Instructions on Agent Responses

How do changes in instructions affect agent responses?

Changing the instructions allows the agent to respond in different languages, demonstrating the direct impact of instructions on behavior.

  • Instructions directly influence how the agent responds.
  • Real-time changes can be tested by interacting with the agent.
  • The system prompt reflects the current instructions and behavior.
# 2:16

Structure of the System Prompt

What is included in the system prompt of an agent?

The system prompt includes the agent's instructions along with additional context to help the agent function effectively.

  • The system prompt is minimal yet effective for agent performance.
  • Instructions are integrated into the system prompt to guide behavior.
  • A well-structured prompt can enhance response speed and quality.
# 3:25

Modifying Instructions in Context Hub

How can instructions be modified in the context hub?

Instructions can be updated in the context hub, allowing for testing changes without affecting the production agent until explicitly deployed.

  • Local modifications do not impact the production agent until deployed.
  • Changes can be made and tested in the context hub before going live.
  • The ability to modify instructions enhances flexibility in agent management.
# 4:33

Syncing Local and Production Instructions

What happens when local and production instructions differ?

When deploying, the system checks for changes in the context hub and allows the user to choose whether to override the production instructions with local changes.

  • The deployment process includes checks for instruction changes.
  • Users can decide which set of instructions to prioritize during deployment.
  • Managing instructions effectively is key to maintaining agent behavior consistency.

Transcript

0:00 In this video, we're going to talk about instructions and the role that they play in managed D agents. So, instructions are what define your agent's behavior. So, if you want your agent to do specific things, you're going to need to know how to work with instructions. One of the really cool parts of instructions is that with managed D agents, we deploy instructions to what we call the context hub, where you can edit them in the UI and make changes that affect your agent without you having to redeploy the code.

0:24 And so, we'll first show in this video how to change the instructions and the behavior impact that they have, and then we'll show how to use context hub. So, instructions are located in instructions.md of of my agent. And so, going in here, if we open it up, and this assumes that you've done the quick start. So, if you haven't done the quick start, please go and do that. So, in the instructions.md, we can see this this paragraph that we added from the quick start. Let's now make a change just to see and show how it can take effect. So, let's say respond in Italian.

0:57 Let's now go to our terminal. And let's run MDA dev. And let's spin up the agent that's running locally. Once it's spun up, we'll interact with it. We'll see that it's now responding in Italian, and then we'll actually open up the system prompt of the agent. We'll open up the trace, see where the system prompt is, and show how these instructions are causing this behavior change exactly. So, if we go to chat, let's ask it something like hi, and we can see that it starts running, and we can see that it responds in Italian.

1:26 Awesome. So, this is how the instructions change and how they impact the agent. If we go back here, we can take a look at the underlying trace. And so, let's open this up in a new tab, and let's click into this model call here. So, in this trace, we can see exactly what the inputs to each step are, including the inputs to the model call. And this is where the system prompt of our agent is. So, we can see a few things. First, we can see the tools that this agent has access to. There's a a of tools that it has access to by default. All of these come baked in into the deep agents harness.

2:01 So, you don't have to enable any of these. These are turned on automatically. Then you have the system prompt. As you can see, there is a good chunk of things in here. So, up here is our instructions that we added. So, this is exactly what we added in these instructions.md. But, there are other parts of the system prompt. So, here we have a very brief note on shell paths versus virtual paths. These are inserted into the system prompt automatically, so that we know how to work with these in our system.

2:31 Please note that this is actually a pretty small system prompt in the grand scheme of things. If you look at some of the agents out there like Claude code or Codex, they often times have longer system prompts. Recently, one of the things that we've done is we've made the deep agents harness a lot more small and more modular. And we've found that this actually yields faster responses and basically the same quality of responses. So, we do a lot of work in the background to manage this deep agents harness. And that's reflected by the system prompt that we create, which is minimal but does have some instructions on things that it often gets confused about and on these built-in tools. So, these are inserted automatically into the agents context. So, that's roughly how instructions are used by the agents.

3:10 They're always put in the system prompt and they always affect the agents behavior. Now, the other part that I want to cover is how these instructions are synced to context hub. So, previously, we created this research assistant deployment. And if we go in here, we can see that it's actually linked to this context hub entry. If we click in, this shows a few things. The main thing is this instructions.md. This is what it was before. So, this is the previous research assistant's instructions. So, in the context hub, they're unchanged. So, you can modify things locally, you can test things out locally, but they don't affect your production agent. And so, if we were to chat with this agent in the studio in the UI or use it in production, it would still have these standard production instructions.

3:51 What we can do is we can update these instructions. So, let's change something here and say something like respond in Spanish. And now let's save this by pressing this button. Now if we go back to deployments, we go into our research assistant, we connect to the studio from here, let's open it up in studio, let's go to chat, let's say something like hi. And we see that it responds in Spanish. So, this is how we change things in production.

4:19 Now, what happens if you made changes to the context hub in production and you also made changes locally. So again, in the context hub in production, we say respond in Spanish. Locally, we say respond in Italian. What happens if I go back here and I run MDA deploy again to try to redeploy this local code? If we run MDA deploy, we'll see that it starts to deploy, but then it pauses because it sees that the context hub instructions.md has changed since the last MDA sync.

4:49 Under the hood, the way that we actually do this is we have this MDA metadata here with this deploy manifest and we have a hash of the instructions. And so going back here, we can now choose whether we want to override the hub edited instructions with the local version or not. So remember, local is Italian, deployed is Spanish. Let's say yes. If we say yes, it will sync it to context hub. And so if we go back here and we click in now, we can see that it's responding in Italian.

5:17 And so that's how context hub can be used to manage the instructions and other contexts that the agent uses without having to redeploy the agent. And also how you can sync and keep them in sync if you edit in one place, but also change or adapt in another. Instructions are a key part of defining how an agent behaves and being able to edit them in context hub is really powerful. So, I hope this lesson was helpful.

Summary

Instructions play a crucial role in defining the behavior of managed D agents, allowing for dynamic updates without redeploying code. The video demonstrates how to modify instructions through the context hub, showcasing the immediate impact on agent responses and the synchronization process between local changes and production settings.

- Instructions define agent behavior and are stored in instructions.md.
- Changes to instructions can be made in the context hub, affecting agent behavior without code redeployment.
- The video illustrates how to modify instructions to change the agent's response language.
- The system prompt includes instructions and tools available to the agent, impacting its responses.
- The deep agents harness has been optimized for faster responses with a minimal system prompt.
- Context hub allows for testing local changes while keeping production instructions intact.
- Synchronization between local and context hub instructions is managed to prevent conflicts.
- Users can choose to override context hub instructions with local changes during deployment.

Questions Answered

What role do instructions play in managed D agents?

Instructions define the behavior of managed D agents and can be modified without redeploying code through the context hub.

How do changes in instructions affect agent responses?

Changing the instructions allows the agent to respond in different languages, demonstrating the direct impact of instructions on behavior.

What is included in the system prompt of an agent?

The system prompt includes the agent's instructions along with additional context to help the agent function effectively.

How can instructions be modified in the context hub?

Instructions can be updated in the context hub, allowing for testing changes without affecting the production agent until explicitly deployed.

What happens when local and production instructions differ?

When deploying, the system checks for changes in the context hub and allows the user to choose whether to override the production instructions with local changes.

© transcribe · For agents Built with care and craft by Gokul Rajaram