Today, we’re launching the MongoDB Strands Harness SDK Integration, available now as the open-source strands-mongodb Python package. Strands, built and maintained by AWS, is an open-source framework for building AI agents. With this integration, MongoDB becomes the single data platform behind your Strands agents, providing:
Session persistence, so agents can resume conversations and complex tasks after a restart or on a different instance.
Long-term memory for facts and lessons that carry across conversations.
Vector search to retrieve relevant past interactions by meaning.
Strands’ MemoryManager decides what to remember and when to recall it, while MongoDB handles where it’s stored and how it’s retrieved, so there’s no custom memory code to build or maintain. And because your operational data already lives in MongoDB, agents can use Atlas Vector Search to ground their answers in it, with no copy synced to a separate vector database.
What is the Strands Harness SDK?
The Strands Harness SDK helps developers build AI agents. It manages the agent loop while giving developers control over how agents execute tasks and maintain context. Support for memory, sessions, and hooks lets developers shape agent behavior and connect agents to their application’s data and persistence layer. It provides pluggable storage and memory interfaces, with built-in backends for local files and Amazon S3. Integrations like this one let you swap in another backing service without rewriting your agent’s core logic.
Why do sessions need a database?
Say a team deploys its Strands agent as an AWS Lambda function, callable as an internal service by teams across the company. Every invocation runs in a disposable environment (i.e., a scratchpad for the agent). There may be no local disk, and no guarantee that the next invocation lands on the same instance, so the state tied to one process is invisible to the next.
With this integration, every agent session is saved in MongoDB. Each invocation loads the session by its ID and carries on, regardless of which instance handled the last turn. Long-term memories the agent saves to MongoDBMemoryStore persist beyond the session, so they’re available the next time that user returns.
Figure 1. Stateless agent architecture keeps state out of the agent process.
Two Lambda instances serve consecutive turns of the same session. Both read and write the session via MongoDBStorage and long-term memory via MongoDBMemoryStore, so neither depends on the other's local state. That matters most for enterprises with many teams running Strands agents across different machines. They get one MongoDB-backed foundation for agent state and memory, instead of building and maintaining separate systems to store and retrieve sessions and memory.
What does the MongoDB Strands Harness SDK Integration provide?
This integration covers three core areas:
Cross-environment continuity: When a different instance handles the next request, or a user returns after a restart, the agent retrieves its saved session from MongoDB. Continuity doesn't depend on any machine.
Resilience to failure: If a host crashes or a container is rescheduled, another instance resumes the session from the last turn written to MongoDB.
Retention and control: You decide how long sessions and memories are retained, with separate retention periods for each. A memory store can also delete a single memory, or all of its memories, on demand. Everything lives alongside your application's operational data in MongoDB, under the access controls and backups you already have in place.
The memory store also handles what production agents run into:
No duplicate memories: Strands can extract the same fact more than once. A content hash turns the repeat into a no-op. For example, if the agent extracts "Prefers metric units and a 24-hour clock" a second time, the store keeps the copy it already has, with its original timestamp and expiry. This means that, as a developer, you don’t need to write your own deduplication logic, and your memory store stays clean, regardless of how often the agent re-extracts the same fact.
Tenant scope: The store stamps every memory with a scope, such as a tenant or user ID, and limits every search and delete to that scope. Callers can't override it through filters or metadata. This isolation is enforced by the package, not by the server, so where a tenant boundary is also a compliance boundary, give each tenant its own database or collection, with credentials restricted to it, and MongoDB enforces the boundary itself.
Search adapts to your deployment: The integration supports Vector Search, Text Search via Atlas Search, or Hybrid Search combined with $rankFusion. The store automatically selects the optimal method available in your deployment, and each result indicates which search type was used.
OpenTelemetry tracing. Every operation records a span on the tracer your application already uses, and no memory content is captured.
How it works
Memory, with no embedding pipeline to run: Atlas Automated Embedding embeds each memory for you, using voyage-4-lite unless you choose a different model. You write plain text and search with plain text. There's no embedding library to install and no model API key to manage. Atlas generates, stores, and updates the embeddings itself as memories are written, so there's no batch job to keep vectors in step with the text.
As you can see above, the query and the stored fact share no words, but the store still finds it. This path needs an Atlas cluster with an embedding model registered. If you already produce your own embeddings, the store can index and query them instead; the README covers the additional code required.
Figure 2. Without an embedding pipeline, memory is just text in and text out. Atlas generates and stores the embeddings and embeds each query before running $vectorSearch.
store.add() writes plain text and returns. Atlas embeds it in the background, and embeds each search query the same way before running $vectorSearch. Bringing your own embedding model is optional.
Sessions and memory together: One connection config serves both. Hand them to the agent and let the SDK wire them up:
The storage= parameter makes MongoDB the default backend for five SDK subsystems, including sessions, context offloading, and transcripts. The SDK's SnapshotSessionManager saves the conversation under its session ID, and any agent built with that ID restores it. MemoryManager gives the model a tool to search memory and, with add_tool_config=True, one to save to it. There's no MongoDB-specific session class to learn.
Figure 3. After a Strands agent is wired to MongoDB, it can save and restore conversations and search long-term memory without any MongoDB-specific session code.
Three agent parameters do the wiring. storage= points the SDK's storage subsystems at MongoDBStorage, session_manager= saves and restores the conversation by session ID, and memory_manager= gives the model search and save tools backed by MongoDBMemoryStore.
Get started today!
strands-mongodb requires Python 3.10 or later and strands-agents 1.54.0 or later. MongoDBStorage works on any MongoDB deployment; memory search with Automated Embedding needs MongoDB Atlas. Install it with the following commands:
Moving from the mongodb_memory tool or a community MongoDB package? MIGRATION has the field mapping and a copy script.
Explore the source, open issues, or contribute on GitHub.
The README covers connection options, the full configuration reference, and index privileges.
Linked resources: