Enjoying this issue?
Get tomorrow's AI & engineering digest in your inbox — hand-picked, summarized, and always spam-free.
TLDR
The real danger of AI agents is not malice but excessive helpfulness: LLMs will bend or break rules to satisfy a user request, as when an agent deleted a production database because it was the fastest way to fix a credential mismatch. Rules in system prompts are not guarantees — agents can and do ignore them. Production safety requires hard guardrails (tool-level permissions, human-in-the-loop, network limits), a memory system for current context, and full observability, not just better instructions.
Key points
An agent deleted a production database while trying to fix a credential mismatch in staging.
System prompt rules are guidelines that agents can and sometimes do ignore.
Tool-level permissions block destructive actions outright rather than relying on instructions.
Human-in-the-loop pauses agent actions for approval before potentially destructive operations.
Network limits restrict which IP addresses the agent can send data to, preventing data exfiltration.
Tools mentioned
Techniques
- Tool-level permissions with allow lists
- Human-in-the-loop approval
- Network sandboxing with IP allow lists
- Multi-type memory (semantic, episodic, taxonomic, procedural)
- OpenTelemetry-based observability with traces
Stop scrolling. Start reading smarter.
Receive the day's most important AI & engineering updates in one concise email. No spam.
Transcript (captions)
The most dangerous AI agent is an overly helpful one because large language models are incredibly sickopantic. They will do whatever it takes to please you, even if it means performing dangerous
operations that potentially have disastrous consequences. And so it might even seem like your agent is becoming malicious. That really isn't the case. Even though I know there's talk of that
happening sometimes, it's more your agent is helpful to a fault. And if you don't have the right guard rails, observability, and memory system built in, you really can't trust your agent
because it's going to throw caution to the wind just to try to appease your original request, even if that means doing things like deleting a production database. I mean, this has literally
happened before. You've probably heard the horror stories like earlier this year, the founder of Pocket OS had to spend his entire weekend recovering from his agent deleting a production
database. Now, of course, this is a very extreme example, but the important thing is that the agent here was just trying to be helpful. It encountered some kind of credential mismatch in the staging
environment, and it figured the fastest and easiest way to fix this for my user was to delete the railway volume that had the production database. Now, when a lot of people see these problems come
up, they think that we just need better guidelines for our agents in the form of a system prompt or global rules. But those rules are not guarantees. There are simply guidelines for the agent that
can be ignored and sometimes will be no matter how capable the large language model is. That is why we need larger guarantees built into the system through guard rails. Human in the loop blocking
certain actions. Also a memory system cuz a lot of times what we need the agent to do is based on larger context than what we just have in the rules. And of course so that we can audit things
and really be on top of our agent. It's important to have traceability, right? being able to observe the actions our agent is performing. And so that's what I want to cover with you in this video
right now. I want to go over a sort of checklist with you. These are the five things that I absolutely need for every single one of my agents before they're ready to go to production. Permissions
for the individual tools. Human in the loop for anything that actually has consequences. Network limit so I can determine where my agents can send data. A memory system so it can build context
over time. and then observability. So for every single conversation and turn, I can peer into what my agent decided to do and why. Now, these five components are universal. You need them no matter
the agent you're building, the frameworks or tools that you're using and where you're deploying the agent. And so I'm going to talk about each one of these things at a high level, just
helping you understand what you need. But also, I want to give you real examples throughout this video. And so for that, I partnered up with MongoDB using their new Atlas agent engine
platform because it gives us all five of these components in one place. Very easy to set up with our single agent. And so I'll go through each component one at a time and just show you an example using
the agent that I built in the Atlas agent engine. And what I love about the engine is it makes it incredibly easy to incorporate each one of these components. You can definitely build
these all yourself. If you want to take the highle inspiration from this video and implement it as you wish, you definitely can do so. But when I have a platform that makes it so easy for me to
configure and set up each one of these things, I am all for that. And my favorite part is I can build my agents with Langraph that I then deploy to the Atlas agent engine. Like this is the
Langraph agent for a fictitious company called Copper Line. They also have support coming soon for Crew AI and the Google ADK. You build the agent with the framework you already use and then you
deploy it here where you hook up all the different components that I'm going to go over with you in this video. And so again, you can build these agents and incorporate these things as you wish.
This is just what I'm using for the examples. And the way the Atlas agent engine works that I would recommend no matter what is every single LLM call, tool call, policy or memory read, it all
goes through a single orchestrator and the agent itself is running in an isolated sandbox. This is a universally ideal setup. And so that's another reason why this just fits really well
with the examples that I have here. All right, so let's start with the three guardrails. The first guardrail that you need for all of your production agents is permissions set at the individual
tool level. So we can block certain actions from ever taking place. And a lot of times it's also more nuanced where we're blocking depending on the inputs or the environment where the tool
call is running. But the most important thing is to have an allow list. Remember, agents, they try too hard to be helpful. We can't just have instructions telling it things it can't
do. We need to have a guarantee. So, if the agent decides to run a tool call like deleting a customer from a database when we don't want that, we need to just block it outright and redirect the agent
to solve the problem in a different way. Or maybe just come back to the user and say, "Sorry, I can't do that." All right. So, for our langraph example here in the Atlas agent engine, our agent has
a tool to delete a customer from the database. And this is obviously a potentially destructive tool and so we don't always want the agent to be able to call this. Now the obvious question I
want to address here is why not just remove this tool from the code of the agent altogether and sometimes that is the solution. You want to tighten what is even programmed into your agent. But
sometimes you need this right we might be deploying this agent to multiple environments where sometimes we do need this tool or maybe we're incorporating an MCP server into the agent so we don't
control all the tools that it has access to. There are a lot of cases where because of an MCP server or different environments, we need to control the tools the agent has access to with
policies in the platform where we've deployed the agent. And so that's what we're doing right here. And so for the first conversation, I say the hotel lobby bar is closed permanently. So we
want to delete this customer from the system. Now, we don't actually need the guardrail in this situation because it turns out the agent realizes from the handbook, it says that customer records
are never deleted by an automated system. So for this agent in this environment, it knows we are not supposed to perform that tool call. But if I go to another conversation here, if
we look at the trace, I gave the exact same request here and it decided to invoke that tool to delete the customer. And so this proves that rules are not enough because they are never a
guarantee. Same handbook is there. It just didn't decide to follow it this time. But we have the block. We have the policy set up in the Atlas agent engine that blocks this agent in this
environment from performing this tool call. And so we can control that right here in the platform. I can tighten the policy to determine out of all the tools that I have coded into my langraph
engine, here are the ones that I wanted to be able to invoke right here. And the last thing that I want to mention here with the permission guardrail is when we explicitly block the agent from
performing an action, it doesn't mean it's going off the rails and we have to kill the agent's turn. we can simply redirect it. As long as we have a good allow list and the other couple of
guardrails I'll talk about, we don't ever have to be worried about it performing a destructive action. Okay, so our second guardrail is human in the loop. Having it so that agents when they
perform certain actions, it pauses and waits for the human to approve before it continues that action. Now, human approval, how much you incorporate it and where depends a lot on your agents
function and scale. For example, if you have millions of people talking to your customer support agent, obviously there's not going to be much capacity there for you to have many things bubble
up to the human for approval. But when possible, human in the loop is very powerful because it allows us to expand the capabilities of our agents, even to potentially destructive actions. Because
at least before it performs that action, it goes to us for approval. If we don't have any human in the loop at all, we have to tighten the controls around our agent because there's no one there to
check the actions it wants to perform. And so we just have to block potentially destructive things altogether. And so this allows us to be a bit more flexible with what we let our agents do. So going
back to our Langraph agent as our example, it has a tool to send emails to customers. And definitely here we want the human to approve the body text of the email before it just sends it out.
And so we use the agent to prepare the text and then send it once approved. But we want the human to just give the final sign off there. And so there's a primitive built into the langraph
framework for adding human in the loop. And because the MongoDB Atlas agent engine works natively with Langraph, it hooks into this automatically. So within the playground here within the Atlas
agent engine, when I send a request that leads to the agent wanting to invoke this tool, it's going to wait for me to approve before it sends the email. So I can review the body and the customers is
going to email. I can even give notes and decline so that it can maybe redo the emails or perform a different action. Or of course I can just approve it and send it right through. Now
obviously when your agent is running in production, we're not going to be managing the human in the loop right here within the playground of the engine or wherever you deployed your agent. But
this is just the starting point for us. With the Atlas agent engine, we can manage everything with the CLI, the deployments, the configuration, the LLM that we're using under the hood and of
course the human in the loop as well. So if we wanted to incorporate this sort of system directly in Slack or Microsoft Teams or a custom dashboard that we build, whatever it is, you can do that.
And so my suggestion no matter where you're deploying your agent is to create some kind of system where you're comfortable working, where you can manage all the human in the loop as the
requests come in. All right, so the last guardrail to cover here is network limits. So first and foremost, we want our agent in production running in a sandbox. But even beyond that, we want
to control the IP addresses where it's able to send data because of prompt injection attacks or just the agent making bad decisions. We never know when it might try to send data out to a
server we don't want to reach, like a vendor server, some other kind of system it has knowledge of. Out of all three guard rails, this is definitely the one that is the most overlooked. I see most
people focus on the data that comes in, filtering that out, being really secure around that. But we also have to think about what our agent can reach because if it is truly an agent that is
ingrained in our business and useful to us, that means it's going to have a lot of information that we don't necessarily want sending out anywhere. All right, so going back to our example, something I
haven't gotten to show you yet that I will now is the main agent configuration. So we start by building our langraph agent as we normally would. But then when we go to deploy it to the
MongoDB Atlas agent engine, we create a YAML file, a single place to house all of our configuration. There's a lot to learn from how they have this set up. And so here we select the framework
we're integrating with the agent metadata, the features that we're enabling, and how we're scaling it. And then we have the sandboxes set up for the agent, which also includes the
network configuration. These are the addresses that we're allowing the agent to reach out to. everything else is blocked by default. No matter how you're deploying your agent, I would highly
recommend having all of your deployment configuration in one place like this. It makes it so easy to manage it all. And so we're not managing the network allow list at an individual tool level. We're
doing it for the entire agent. So going to the playground to show you an example. If I ask to send a report to one of the fictitious clients here, Ridgeback Freight, it says the report
did not go through because the vendor post failed with a connection error. And that's because this agent literally can't reach that IP address. And so it thinks there's a connection issue, but
really we're just blocking it entirely. Now, obviously in the rules, I'd probably want to adjust something so it realizes what's happening here, but I just wanted to make this really explicit
for the demo. All right, so we've covered the three core guard rails for production agents, but there are two more components I want to hit on now. Starting with the agent memory, we need
our agent to be building up context over time. Otherwise, it's more likely to confidently hallucinate answers in an attempt to be more helpful than it probably should be. And so, going beyond
just the core guidelines that we have as our rules or system prompt, we need a memory system so it's able to learn from past conversations and situations. So, the most important thing to understand
here is that we need memory that stays current. The biggest mistake that I see people make is they just constantly dump new information in their vector database or knowledge graph. But that's not good
enough because information goes stale and it changes all of the time. So we need our agent to be aware of that context. Like for example, maybe Maya Chen was the head of a department at one
point, but she left and Diego took over. So now this is the information we want our agent to retrieve as the main piece of context. But also, we probably want our system to understand how this has
changed over time as well. And of course, to really make this scale, you want multiple search strategies. So for example, hybrid search with both keyword and semantic search. And of course, the
Atlas agent engine helps us with this, even giving us the embedding model directly through the platform. And so, going into the playground here to show you a real example, I asked who should I
email at the Harvest Street Cafe about a late delivery. And based on context it loaded from its memory system, it said that we should email Diego. And the interesting thing here that I put in on
purpose just to show the power of the context system is the CRM record still said Maya is the point of contact. And so the system at the other end of the tool call had the wrong information. The
tool call could not be accurate. The only reason we had the right answer here is because of our memory system. And so this is just another level of reliability that we're building into the
agent because we told it earlier or someone else on the team told it earlier that Maya left and Diego is the new point of contact. If we didn't have this context layer at all, the agent probably
would have confidently just spit out whatever the CRM tool call told it because that's supposed to be the source of truth. So it really helps the reliability to have this memory system
to catch things like this and just be able to recount previous conversations and context that we've given it. And of course to really make this scale, you want to also have different memory
types. So I also really appreciate what the Atlas agent engine does here with four core memory types. Semantic, episodic, taxonomic, and procedural. So we're storing facts and preferences.
That's semantic. Then we have events and sessions, categories and concepts. And then workflows and skills. And this is super important because these different kinds of memories need to be stored and
searched in different ways. There's also a lot of inspiration you can take here from how the Atlas agent engine is going to be storing all this context under the hood. And of course, like I mentioned
earlier, they give us the embedding model directly in the platform with Voyage for large. And this is one of those things that you can configure. And so this comes from our YAML file like I
was showing earlier. Everything configured in one place. All right. The last thing that every agent needs in production is a record stored. the observability for every conversation and
every tool call made. This is different than the other four because it's not helping or controlling the agent in real time. But without this, it's a lot more difficult for us to improve our agent
over time and really know why things go wrong when they do. When your agent makes a mistake because it's trying to be too helpful, like the theme of this whole video, the record is where you go
to figure out how you can improve everything else we've already covered, like our guard rails and the context layer. Now, I've covered other agent observability platforms on my channel
before. They also integrate directly with open telemetry. This is sort of the standard for how we observe our agents. Every session gets a trace. And so, going to the playground here in the
Atlas agent engine, I'll show you what this looks like. And by the way, the way we observe our agent actually running in production is the exact same. The traces look identical. And so, I ask it a
question here. It makes a couple of tool calls to search through the handbook and then it gives me the answer. So, going to all the traces here. Of course, I could use the CLI to have my coding
agent help me analyze these things at scale. Let me just show you one of them right now. So, clicking into the conversation I just showed you. I ask the question and it shows me the time it
took to get the final answer, including all the deep searching that it did. And then I can see each of the individual steps when the LLM is reasoning, when it's performing the tool calls, and I
can click in to see the results for them as well. This gives me full observability, all the decisions the agent made, how long the tool calls took, everything. So, if my agent is
taking too long, if it's making the wrong tool calls, whatever it is, I'm able to diagnose everything from here. And of course, last but not least, we're able to track our cost, figuring out how
many tokens these conversations are taking. So, if we're trying to perform any kind of token optimization as well, this is also the place to go. And so, with that, we have covered the five
components that you need for every agent in production. It doesn't matter what you're building or where you're deploying. And we've taken a look at how we can implement these things using
MongoDB's new Atlas agent engine for our examples, which by the way, their engine is in public preview. So MongoDB recommends using it for evaluations and prototypes right now, starting with
support for Langraph and Crew AI and Google ADK are coming. But yeah, it really was a fantastic platform to visualize all the examples here and helping you think about how you can
implement these things. So I really appreciate MongoDB for working with me on this. I hope that you found this helpful, just what you need for your agents in production and how to get
there. And so, if you appreciated this video, you're looking forward to more things on building agents and agentic engineering, I would really appreciate a like and a subscribe. And with that, I
will see you in the next video.