MongoDBTutorial
Build, Deploy, and Govern your Agents with MongoDB Atlas Agent Engine
Summary
MongoDB Atlas Agent Engine provides a managed control layer for AI agents, including identity, runtime, long-term memory, auditability, and guardrails, and is model- and framework-neutral. This tutorial demonstrates migrating a LangGraph-based travel agent to Agent Engine with minimal code changes, using the agent_engine_sdk_langgraph adapter. The agent uses custom tools and MongoDB Atlas Managed MCP Server tools to query flight and accommodation data stored in MongoDB, and its state is persisted via Agent Engine’s checkpointer. Migration steps include wrapping the agent with the App class, routing LLM calls through Agent Engine, registering tools with the @app.tool() decorator, and configuring memory and governance policies. After deployment, administrators can enforce policies that limit tools and models, and content guardrails that block sensitive data like credit card numbers from reaching the LLM.
Context
The post frames the need for a managed agent control layer in the context of the ‘Big Model vs. Big Harness’ debate, arguing that persistent memory, identity, access control, governance, and audit trails must live outside the model. MongoDB Atlas Agent Engine provides this control layer as a managed service, neutral across models, frameworks, and data sources.
Approach / What changed
Migrate a LangGraph agent to Atlas Agent Engine by wrapping the agent with the App class from agent_engine_sdk_langgraph, routing LLM calls through app.llm(), registering tools with @app.tool(), replacing the LangGraph checkpointer with app.checkpointer(), and deploying via the agentengine CLI. After deployment, enforce governance policies and content guardrails via the Agent Engine UI.
Takeaways
Agent Engine provides a managed runtime with sandboxed execution: the agent graph runs in an agent sandbox and tools/LLM calls run in a separate tool sandbox.
Migrating a LangGraph agent requires only a handful of code changes: wrapping with App class, using app.llm(), @app.tool(), app.checkpointer(), and @app.entrypoint.
Governance policies can restrict which tools an agent can use; for example, a policy can limit the travel agent to read-only tools, preventing the create_booking tool from being called.
FAQ
What changes are needed to migrate a LangGraph agent to Agent Engine?
You need to wrap the agent with the App class, wrap the LLM with app.llm(), register tools with @app.tool(), replace the checkpointer with app.checkpointer(), mark the entrypoint with @app.entrypoint, and call app.run(). The core graph and tool logic remain unchanged.
How does Agent Engine handle memory for agents?
Agent Engine provides a memory service that stores long-term memories in MongoDB Atlas. You configure memory types (e.g., user memories) in a memory.yaml file and upload it to the project. The agent's state and short-term memory are managed by Agent Engine's checkpointer instead of a custom one.
Can Agent Engine enforce policies on agent behavior?
Yes, Agent Engine allows admins to set governance policies that control which models and tools an agent can use, limit LLM calls and tokens per execution, and content guardrails that block or modify inputs/outputs based on regular expressions, such as blocking credit card numbers.
Source and freshness
- Source
- mongodb.com
- Published
- Added to Yomu
Summaries are generated from the original by a language model. Check the original before relying on it.
Keep reading
Related reading
The Good Stuff
Paid picks we use ourselves. Links carry a referral code — a subscription through one earns us a commission at no extra cost to you.
The best engineering reads, once a week
One useful email. Unsubscribe anytime.