{"id":12720,"date":"2026-07-24T04:00:40","date_gmt":"2026-07-24T11:00:40","guid":{"rendered":"https:\/\/devblogs.microsoft.com\/cosmosdb\/?p=12720"},"modified":"2026-07-21T08:31:01","modified_gmt":"2026-07-21T15:31:01","slug":"native-agent-memory-for-microsoft-agent-framework-powered-by-azure-cosmos-db","status":"publish","type":"post","link":"https:\/\/devblogs.microsoft.com\/cosmosdb\/native-agent-memory-for-microsoft-agent-framework-powered-by-azure-cosmos-db\/","title":{"rendered":"Native Agent Memory for Microsoft Agent Framework, Powered by Azure Cosmos DB"},"content":{"rendered":"<p class=\"code-line\" dir=\"auto\" data-line=\"23\">Recently we introduced the\u00a0<a href=\"https:\/\/devblogs.microsoft.com\/cosmosdb\/new-toolkits-for-agent-memories-and-agentic-retrieval-in-azure-cosmos-db\/\" data-href=\"https:\/\/devblogs.microsoft.com\/cosmosdb\/new-toolkits-for-agent-memories-and-agentic-retrieval-in-azure-cosmos-db\/\">Agent Memory Toolkit and the Agentic Retrieval Toolkit for Azure Cosmos DB<\/a>. The Agent Memory Toolkit gives your agents durable, Cosmos-backed memory: it stores raw conversation turns and then distills them into higher-value derived memories (thread summaries, extracted facts, and cross-thread user profiles), all searchable with vector, full-text, and hybrid search in the one database you already use.<\/p>\n<p class=\"code-line\" dir=\"auto\" data-line=\"25\">Today we&#8217;re taking the next step. With the latest release of\u00a0<strong><a href=\"https:\/\/learn.microsoft.com\/agent-framework\/overview\/?pivots=programming-language-python\" data-href=\"https:\/\/learn.microsoft.com\/agent-framework\/overview\/?pivots=programming-language-python\">Microsoft Agent Framework<\/a><\/strong>, you can now drop that memory into an agent with a single object: the\u00a0<strong><code>CosmosMemoryContextProvider<\/code><\/strong>, shipped in the new\u00a0<code>agent-framework-azure-cosmos-memory<\/code>\u00a0package for Python (currently in preview). Wire it into your agent once, and every turn is remembered, distilled, and recalled across threads and sessions, with no orchestration code on your side.<\/p>\n<h2 id=\"why-a-context-provider-and-why-it-matters\" class=\"code-line\" dir=\"auto\" data-line=\"15\">Why a context provider, and why it matters<\/h2>\n<p class=\"code-line\" dir=\"auto\" data-line=\"29\">Most agent frameworks give you a\u00a0<em>memory<\/em>\u00a0interface: a fixed API for storing and retrieving conversation memory. Microsoft Agent Framework does something more general. It exposes a first-class, provider-agnostic\u00a0<strong>context provider<\/strong>\u00a0abstraction: a pair of lifecycle hooks,\u00a0<code>before_run<\/code>\u00a0and\u00a0<code>after_run<\/code>, that any component can implement to contribute context\u00a0<em>into<\/em>\u00a0a run and capture results\u00a0<em>out<\/em>\u00a0of it.<\/p>\n<p class=\"code-line\" dir=\"auto\" data-line=\"31\">That generality is the interesting part. A context provider isn&#8217;t limited to memory. It&#8217;s a clean seam for injecting anything an agent should know before it thinks, and for reacting to anything it produces afterwards. Among the major agent frameworks, Agent Framework stands out for making this a first-class, pluggable extension point rather than a memory-specific bolt-on, and that is precisely what let us build Cosmos-backed memory as a drop-in provider instead of a wrapper around the whole agent loop.<\/p>\n<p class=\"code-line\" dir=\"auto\" data-line=\"33\">Concretely,\u00a0<code>CosmosMemoryContextProvider<\/code>\u00a0does two things:<\/p>\n<ul class=\"code-line\" dir=\"auto\" data-line=\"35\">\n<li class=\"code-line\" dir=\"auto\" data-line=\"35\"><strong><code>before_run<\/code><\/strong>: searches your Cosmos-backed memory for context relevant to the incoming message and injects the matches (plus the user&#8217;s profile) into the model context, so the agent answers with what it already knows about the user.<\/li>\n<li class=\"code-line\" dir=\"auto\" data-line=\"36\"><strong><code>after_run<\/code><\/strong>: stores the new turns and lets the Agent Memory Toolkit&#8217;s pipeline extract facts, roll up summaries, and update the user profile in the background.<\/li>\n<\/ul>\n<p class=\"code-line\" dir=\"auto\" data-line=\"38\">You implement nothing. You attach one provider and get durable memory.<\/p>\n<p><a href=\"https:\/\/devblogs.microsoft.com\/cosmosdb\/wp-content\/uploads\/sites\/52\/2026\/07\/context-provider-2.png\"><img decoding=\"async\" class=\"alignnone wp-image-12725 size-full\" src=\"https:\/\/devblogs.microsoft.com\/cosmosdb\/wp-content\/uploads\/sites\/52\/2026\/07\/context-provider-2.png\" alt=\"Agent memory lifecycle showing relevant memories retrieved through vector, full-text, and hybrid search before a run, then conversation turns, facts, summaries, and user profiles stored afterward.\" width=\"1536\" height=\"896\" srcset=\"https:\/\/devblogs.microsoft.com\/cosmosdb\/wp-content\/uploads\/sites\/52\/2026\/07\/context-provider-2.png 1536w, https:\/\/devblogs.microsoft.com\/cosmosdb\/wp-content\/uploads\/sites\/52\/2026\/07\/context-provider-2-300x175.png 300w, https:\/\/devblogs.microsoft.com\/cosmosdb\/wp-content\/uploads\/sites\/52\/2026\/07\/context-provider-2-1024x597.png 1024w, https:\/\/devblogs.microsoft.com\/cosmosdb\/wp-content\/uploads\/sites\/52\/2026\/07\/context-provider-2-768x448.png 768w\" sizes=\"(max-width: 1536px) 100vw, 1536px\" \/><\/a><\/p>\n<h2 id=\"how-it-fits-together\" class=\"code-line\" dir=\"auto\" data-line=\"28\">How it fits together<\/h2>\n<p class=\"code-line\" dir=\"auto\" data-line=\"42\">Under the hood, the provider is a thin, idiomatic Agent Framework adapter over the\u00a0<a href=\"https:\/\/aka.ms\/AgentMemoryToolkit\" data-href=\"https:\/\/aka.ms\/AgentMemoryToolkit\">Agent Memory Toolkit<\/a>. Agent Framework owns the agent loop and the context-provider lifecycle; the toolkit owns the Cosmos DB storage model and the LLM pipeline that turns raw turns into facts, summaries, and profiles. Memory is scoped by a stable\u00a0<code>user_id<\/code>\u00a0(and a\u00a0<code>thread_id<\/code>\u00a0for the current conversation), so recall follows the user across brand-new threads and sessions.<\/p>\n<p class=\"code-line\" dir=\"auto\" data-line=\"44\">Everything lands in Azure Cosmos DB for NoSQL as JSON documents (turns, facts, and summaries), and retrieval uses the vector, full-text, and hybrid search that are already built into the database. No second vector store to provision, and nothing to keep in sync.<\/p>\n<p dir=\"auto\" data-line=\"44\"><a href=\"https:\/\/devblogs.microsoft.com\/cosmosdb\/wp-content\/uploads\/sites\/52\/2026\/07\/MAF-memory-2.png\"><img decoding=\"async\" class=\"alignnone wp-image-12726 size-full\" src=\"https:\/\/devblogs.microsoft.com\/cosmosdb\/wp-content\/uploads\/sites\/52\/2026\/07\/MAF-memory-2.png\" alt=\"Architecture diagram showing Microsoft Agent Framework using CosmosMemoryContextProvider and Agent Memory Toolkit to retrieve context and store conversation turns, facts, summaries, and profiles in Azure Cosmos DB for NoSQL.\" width=\"1536\" height=\"890\" srcset=\"https:\/\/devblogs.microsoft.com\/cosmosdb\/wp-content\/uploads\/sites\/52\/2026\/07\/MAF-memory-2.png 1536w, https:\/\/devblogs.microsoft.com\/cosmosdb\/wp-content\/uploads\/sites\/52\/2026\/07\/MAF-memory-2-300x174.png 300w, https:\/\/devblogs.microsoft.com\/cosmosdb\/wp-content\/uploads\/sites\/52\/2026\/07\/MAF-memory-2-1024x593.png 1024w, https:\/\/devblogs.microsoft.com\/cosmosdb\/wp-content\/uploads\/sites\/52\/2026\/07\/MAF-memory-2-768x445.png 768w\" sizes=\"(max-width: 1536px) 100vw, 1536px\" \/><\/a><\/p>\n<h2 id=\"walking-through-the-interactive-sample\" class=\"code-line\" dir=\"auto\" data-line=\"34\">Walking through the interactive sample<\/h2>\n<p class=\"code-line\" dir=\"auto\" data-line=\"48\">The\u00a0<code>agent-framework-azure-cosmos-memory<\/code>\u00a0package ships an interactive chat sample that shows the whole thing end to end. Let&#8217;s walk through it.<\/p>\n<h3 id=\"1-install-and-configure\" class=\"code-line\" dir=\"auto\" data-line=\"38\">1. Install and configure<\/h3>\n<pre><code class=\"code-line language-bash\" dir=\"auto\" data-line=\"52\">pip install agent-framework-azure-cosmos-memory agent-framework-foundry\r\n<\/code><\/pre>\n<p class=\"code-line\" dir=\"auto\" data-line=\"56\">Authentication is via\u00a0<code>DefaultAzureCredential<\/code>\u00a0(so\u00a0<code>az login<\/code>\u00a0locally, or a managed identity in Azure), with no API keys. Point the sample at your Cosmos DB account and your Microsoft Foundry project, and name the chat and embedding deployments you want to use:<\/p>\n<pre><code class=\"code-line language-powershell\" dir=\"auto\" data-line=\"58\"><span class=\"hljs-variable\">$env:COSMOS_ENDPOINT<\/span>  = <span class=\"hljs-string\">\"https:\/\/&lt;your-account&gt;.documents.azure.com:443\/\"<\/span>\r\n<span class=\"hljs-variable\">$env:FOUNDRY_ENDPOINT<\/span> = <span class=\"hljs-string\">\"https:\/\/&lt;your-project&gt;.services.ai.azure.com\"<\/span>\r\n<span class=\"hljs-variable\">$env:CHAT_MODEL<\/span>       = <span class=\"hljs-string\">\"gpt-5.4-mini\"<\/span>\r\n<span class=\"hljs-variable\">$env:EMBEDDING_MODEL<\/span>  = <span class=\"hljs-string\">\"text-embedding-3-large\"<\/span>\r\n<\/code><\/pre>\n<h3 id=\"2-give-the-agent-memory\" class=\"code-line\" dir=\"auto\" data-line=\"53\">2. Give the agent memory<\/h3>\n<p class=\"code-line\" dir=\"auto\" data-line=\"67\">Creating a memory-backed agent is just constructing the provider and passing it to the agent. The single Foundry endpoint powers both the memory pipeline (embeddings and extraction) and the chat agent:<\/p>\n<pre><code class=\"code-line language-python\" dir=\"auto\" data-line=\"69\"><span class=\"hljs-keyword\">import<\/span> os\r\n\r\n<span class=\"hljs-keyword\">from<\/span> agent_framework <span class=\"hljs-keyword\">import<\/span> Agent\r\n<span class=\"hljs-keyword\">from<\/span> agent_framework.foundry <span class=\"hljs-keyword\">import<\/span> FoundryChatClient\r\n<span class=\"hljs-keyword\">from<\/span> azure.identity.aio <span class=\"hljs-keyword\">import<\/span> DefaultAzureCredential\r\n\r\n<span class=\"hljs-keyword\">from<\/span> agent_framework_azure_cosmos_memory <span class=\"hljs-keyword\">import<\/span> CosmosMemoryContextProvider\r\n\r\n\r\n<span class=\"hljs-keyword\">def<\/span> <span class=\"hljs-title function_\">create_agent_with_memory<\/span>():\r\n    foundry_endpoint = os.environ[<span class=\"hljs-string\">\"FOUNDRY_ENDPOINT\"<\/span>]\r\n    credential = DefaultAzureCredential()\r\n\r\n    <span class=\"hljs-comment\"># One object gives the agent durable, Cosmos-backed long-term memory.<\/span>\r\n    provider = CosmosMemoryContextProvider(\r\n        cosmos_endpoint=os.environ[<span class=\"hljs-string\">\"COSMOS_ENDPOINT\"<\/span>],\r\n        cosmos_database=os.getenv(<span class=\"hljs-string\">\"COSMOS_DATABASE\"<\/span>, <span class=\"hljs-string\">\"ai_memory\"<\/span>),\r\n        foundry_endpoint=foundry_endpoint,\r\n        embedding_model=os.getenv(<span class=\"hljs-string\">\"EMBEDDING_MODEL\"<\/span>, <span class=\"hljs-string\">\"text-embedding-3-large\"<\/span>),\r\n        chat_model=os.getenv(<span class=\"hljs-string\">\"CHAT_MODEL\"<\/span>, <span class=\"hljs-string\">\"gpt-5.4-mini\"<\/span>),\r\n        credential=credential,\r\n        memory_types=[<span class=\"hljs-string\">\"fact\"<\/span>, <span class=\"hljs-string\">\"procedural\"<\/span>, <span class=\"hljs-string\">\"episodic\"<\/span>],\r\n    )\r\n\r\n    agent = Agent(\r\n        client=FoundryChatClient(\r\n            project_endpoint=foundry_endpoint,\r\n            model=os.getenv(<span class=\"hljs-string\">\"CHAT_MODEL\"<\/span>, <span class=\"hljs-string\">\"gpt-5.4-mini\"<\/span>),\r\n            credential=credential,\r\n        ),\r\n        name=<span class=\"hljs-string\">\"Memory Assistant\"<\/span>,\r\n        instructions=<span class=\"hljs-string\">\"You are a helpful assistant with long-term memory.\"<\/span>,\r\n        context_providers=[provider],  <span class=\"hljs-comment\"># &lt;- that's the whole integration<\/span>\r\n    )\r\n    <span class=\"hljs-keyword\">return<\/span> agent, provider\r\n<\/code><\/pre>\n<p class=\"code-line\" dir=\"auto\" data-line=\"107\">The only line that matters for memory is\u00a0<code>context_providers=[provider]<\/code>. From that point on,\u00a0<code>before_run<\/code>\u00a0and\u00a0<code>after_run<\/code>\u00a0fire automatically around every agent run.<\/p>\n<h3 id=\"3-scope-memory-to-a-user\" class=\"code-line\" dir=\"auto\" data-line=\"97\">3. Scope memory to a user<\/h3>\n<p class=\"code-line\" dir=\"auto\" data-line=\"111\">Long-term, cross-session memory needs a stable user id. You set it in the provider-scoped session state, so a fresh thread for the same user still recalls everything learned earlier:<\/p>\n<pre><code class=\"code-line language-python\" dir=\"auto\" data-line=\"113\"><span class=\"hljs-keyword\">def<\/span> <span class=\"hljs-title function_\">new_session<\/span>(<span class=\"hljs-params\">agent, provider, user_id<\/span>):\r\n    session = agent.create_session()\r\n    session.state.setdefault(provider.source_id, {})[<span class=\"hljs-string\">\"user_id\"<\/span>] = user_id\r\n    <span class=\"hljs-keyword\">return<\/span> session\r\n<\/code><\/pre>\n<h3 id=\"4-see-memory-in-action\" class=\"code-line\" dir=\"auto\" data-line=\"108\">4. See memory in action<\/h3>\n<p class=\"code-line\" dir=\"auto\" data-line=\"122\">Now the payoff. Enter the provider&#8217;s async context (so background extraction is drained cleanly on exit), tell the agent something durable, then start a\u00a0<strong>new thread<\/strong>\u00a0and ask it to recall:<\/p>\n<pre><code class=\"code-line language-python\" dir=\"auto\" data-line=\"124\">agent, provider = create_agent_with_memory()\r\n\r\n<span class=\"hljs-keyword\">async<\/span> <span class=\"hljs-keyword\">with<\/span> provider:\r\n    session = new_session(agent, provider, user_id=<span class=\"hljs-string\">\"alice\"<\/span>)\r\n    <span class=\"hljs-keyword\">await<\/span> agent.run(<span class=\"hljs-string\">\"I love hiking and I'm allergic to peanuts.\"<\/span>, session=session)\r\n\r\n    <span class=\"hljs-comment\"># Brand-new thread, same user -&gt; memory persists.<\/span>\r\n    session = new_session(agent, provider, user_id=<span class=\"hljs-string\">\"alice\"<\/span>)\r\n    reply = <span class=\"hljs-keyword\">await<\/span> agent.run(<span class=\"hljs-string\">\"What should we pack for a trail lunch?\"<\/span>, session=session)\r\n    <span class=\"hljs-built_in\">print<\/span>(reply.text)\r\n<\/code><\/pre>\n<p class=\"code-line\" dir=\"auto\" data-line=\"137\">Even though the second thread has no prior messages, the agent recalls that Alice hikes and is allergic to peanuts, and it plans a peanut-free trail lunch. That recall is driven entirely by the provider: on\u00a0<code>before_run<\/code>\u00a0it searched Alice&#8217;s extracted facts and injected her profile as context; on\u00a0<code>after_run<\/code>\u00a0of the first turn it stored the turn and let the toolkit extract the durable facts.<\/p>\n<p class=\"code-line\" dir=\"auto\" data-line=\"139\">The interactive sample wraps this in a simple REPL with a few commands so you can feel it working:<\/p>\n<ul class=\"code-line\" dir=\"auto\" data-line=\"141\">\n<li class=\"code-line\" dir=\"auto\" data-line=\"141\"><code>\/new<\/code>: start a new thread for the same user (memory carries over).<\/li>\n<li class=\"code-line\" dir=\"auto\" data-line=\"142\"><code>\/user<\/code>: switch to a different user id (isolated memory).<\/li>\n<li class=\"code-line\" dir=\"auto\" data-line=\"143\"><code>\/quit<\/code>: exit.<\/li>\n<\/ul>\n<p class=\"code-line\" dir=\"auto\" data-line=\"145\">Try telling it your name and a couple of preferences, hit\u00a0<code>\/new<\/code>, and ask &#8220;what do you know about me?&#8221;. It will answer from long-term memory, not from the current conversation.<\/p>\n<p class=\"code-line\" dir=\"auto\" data-line=\"147\">You can find the complete, runnable version of this walkthrough (along with a minimal\u00a0<code>basic_usage.py<\/code>\u00a0and the custom-extraction sample described below) in the package&#8217;s\u00a0<a href=\"https:\/\/github.com\/microsoft\/agent-framework\/tree\/main\/python\/packages\/azure-cosmos-memory\/samples\" data-href=\"https:\/\/github.com\/microsoft\/agent-framework\/tree\/main\/python\/packages\/azure-cosmos-memory\/samples\">samples folder on GitHub<\/a>. The full interactive chat is\u00a0<a href=\"https:\/\/github.com\/microsoft\/agent-framework\/blob\/main\/python\/packages\/azure-cosmos-memory\/samples\/interactive_chat.py\" data-href=\"https:\/\/github.com\/microsoft\/agent-framework\/blob\/main\/python\/packages\/azure-cosmos-memory\/samples\/interactive_chat.py\"><code>interactive_chat.py<\/code><\/a>.<\/p>\n<h2 id=\"customizing-what-your-agent-remembers\" class=\"code-line\" dir=\"auto\" data-line=\"137\">Customizing what your agent remembers<\/h2>\n<p class=\"code-line\" dir=\"auto\" data-line=\"151\">The default extraction rubric is general-purpose: it pulls out facts, procedural preferences, and episodic experiences that apply to almost any assistant. But &#8220;what is worth remembering&#8221; is usually domain-specific. A coding assistant should remember architectural decisions and language preferences; a travel agent should remember seat and dietary preferences; a support bot should remember account tier and past incidents. Left on the defaults, a specialized agent either forgets the things that matter most to it or clutters memory with things that don&#8217;t.<\/p>\n<p class=\"code-line\" dir=\"auto\" data-line=\"153\">The provider exposes a\u00a0<code>prompts_dir<\/code>\u00a0parameter for exactly this. Point it at a directory of\u00a0<a href=\"https:\/\/prompty.ai\/\" data-href=\"https:\/\/prompty.ai\/\">Prompty<\/a>\u00a0templates and the memory pipeline reads its extraction and summarization prompts from there instead of the toolkit&#8217;s bundled defaults. The one that matters most is\u00a0<code>extract_memories.prompty<\/code>. It defines the rubric the model uses to decide\u00a0<em>what<\/em>\u00a0to pull out of each turn and\u00a0<em>how<\/em>\u00a0to classify it. You keep the template&#8217;s inputs and JSON output schema intact and rewrite the guidance in between.<\/p>\n<p class=\"code-line\" dir=\"auto\" data-line=\"155\">The\u00a0<a href=\"https:\/\/github.com\/microsoft\/agent-framework\/blob\/main\/python\/packages\/azure-cosmos-memory\/samples\/interactive_chat_custom_extraction.py\" data-href=\"https:\/\/github.com\/microsoft\/agent-framework\/blob\/main\/python\/packages\/azure-cosmos-memory\/samples\/interactive_chat_custom_extraction.py\"><code>interactive_chat_custom_extraction.py<\/code><\/a>\u00a0sample shows this end to end. It builds a prompts directory at runtime (copying the bundled templates and swapping in a coding-focused\u00a0<code>extract_memories.prompty<\/code>), then passes it to the provider:<\/p>\n<pre><code class=\"code-line language-python\" dir=\"auto\" data-line=\"157\">provider = CosmosMemoryContextProvider(\r\n    cosmos_endpoint=os.environ[<span class=\"hljs-string\">\"COSMOS_ENDPOINT\"<\/span>],\r\n    foundry_endpoint=os.environ[<span class=\"hljs-string\">\"FOUNDRY_ENDPOINT\"<\/span>],\r\n    embedding_model=os.getenv(<span class=\"hljs-string\">\"EMBEDDING_MODEL\"<\/span>, <span class=\"hljs-string\">\"text-embedding-3-large\"<\/span>),\r\n    chat_model=os.getenv(<span class=\"hljs-string\">\"CHAT_MODEL\"<\/span>, <span class=\"hljs-string\">\"gpt-5.4-mini\"<\/span>),\r\n    credential=credential,\r\n    <span class=\"hljs-comment\"># The one line that matters: point the extraction pipeline at your own templates.<\/span>\r\n    prompts_dir=prompts_dir,\r\n)\r\n<\/code><\/pre>\n<p class=\"code-line\" dir=\"auto\" data-line=\"169\">Everything else (storage, scoping, retrieval, and injection) stays exactly the same. You are only changing what the pipeline considers memorable, so a coding assistant starts durably remembering &#8220;the team chose PostgreSQL over MySQL for the user service&#8221; and the instruction to &#8220;always show code before explaining it,&#8221; while ignoring small talk. It&#8217;s the cleanest way to tune memory to your domain without forking the toolkit, and because the retrieval and injection paths are untouched, everything you saw in the walkthrough above keeps working.<\/p>\n<h2 id=\"built-for-production-not-just-demos\" class=\"code-line\" dir=\"auto\" data-line=\"135\">Built for production, not just demos<\/h2>\n<p class=\"code-line\" dir=\"auto\" data-line=\"173\">A couple of details worth calling out for teams taking this past a prototype:<\/p>\n<ul class=\"code-line\" dir=\"auto\" data-line=\"175\">\n<li class=\"code-line\" dir=\"auto\" data-line=\"175\"><strong>Transparent extraction.<\/strong>\u00a0Turn writes are non-blocking; fact and summary extraction run in the background and are drained automatically when the provider&#8217;s context exits, so nothing is lost and your request path stays fast.<\/li>\n<li class=\"code-line\" dir=\"auto\" data-line=\"176\"><strong>Safe by default.<\/strong>\u00a0The user profile the agent recalls is generated from stored conversation content, so the provider injects it as an ordinary user-role message (never as system or agent instructions), prefixed with an explicit note telling the model to treat it as untrusted reference information rather than as instructions. That reduces the stored prompt-injection risk where a poisoned memory could otherwise become a standing directive.<\/li>\n<li class=\"code-line\" dir=\"auto\" data-line=\"177\"><strong>Your models, your rules.<\/strong>\u00a0Chat and embedding deployments are explicit; there is no silent default that might point at a model you haven&#8217;t deployed.<\/li>\n<\/ul>\n<h2 id=\"get-started\" class=\"code-line\" dir=\"auto\" data-line=\"143\">Get started<\/h2>\n<p class=\"code-line\" dir=\"auto\" data-line=\"181\">If you&#8217;re building agents on Microsoft Agent Framework and you want them to remember, this is now a one-object integration:<\/p>\n<ol class=\"code-line\" dir=\"auto\" data-line=\"183\">\n<li class=\"code-line\" dir=\"auto\" data-line=\"183\"><code>pip install agent-framework-azure-cosmos-memory agent-framework-foundry<\/code><\/li>\n<li class=\"code-line\" dir=\"auto\" data-line=\"184\">Attach a\u00a0<code>CosmosMemoryContextProvider<\/code>\u00a0to your agent&#8217;s\u00a0<code>context_providers<\/code>.<\/li>\n<li class=\"code-line\" dir=\"auto\" data-line=\"185\">Set a stable\u00a0<code>user_id<\/code>\u00a0in the provider&#8217;s session state.<\/li>\n<\/ol>\n<p class=\"code-line\" dir=\"auto\" data-line=\"187\">The\u00a0<code>agent-framework-azure-cosmos-memory<\/code>\u00a0package is currently in preview and Python-only, so APIs may change before general availability.<\/p>\n<p class=\"code-line\" dir=\"auto\" data-line=\"189\">Start from the runnable\u00a0<a href=\"https:\/\/github.com\/microsoft\/agent-framework\/tree\/main\/python\/packages\/azure-cosmos-memory\/samples\" data-href=\"https:\/\/github.com\/microsoft\/agent-framework\/tree\/main\/python\/packages\/azure-cosmos-memory\/samples\">samples<\/a>\u00a0in the package. Learn more about the memory engine behind it in the\u00a0<a href=\"https:\/\/aka.ms\/AgentMemoryToolkit\" data-href=\"https:\/\/aka.ms\/AgentMemoryToolkit\">Agent Memory Toolkit documentation<\/a>, read the original\u00a0<a href=\"https:\/\/devblogs.microsoft.com\/cosmosdb\/new-toolkits-for-agent-memories-and-agentic-retrieval-in-azure-cosmos-db\/\" data-href=\"https:\/\/devblogs.microsoft.com\/cosmosdb\/new-toolkits-for-agent-memories-and-agentic-retrieval-in-azure-cosmos-db\/\">toolkits announcement<\/a>, and explore\u00a0<a href=\"https:\/\/learn.microsoft.com\/agent-framework\/overview\/?pivots=programming-language-python\" data-href=\"https:\/\/learn.microsoft.com\/agent-framework\/overview\/?pivots=programming-language-python\">Microsoft Agent Framework<\/a>\u00a0and its\u00a0<a href=\"https:\/\/github.com\/microsoft\/agent-framework\" data-href=\"https:\/\/github.com\/microsoft\/agent-framework\">source on GitHub<\/a>.<\/p>\n<h2 id=\"about-azure-cosmos-db\" class=\"code-line\" dir=\"auto\" data-line=\"153\">About Azure Cosmos DB<\/h2>\n<p class=\"code-line\" dir=\"auto\" data-line=\"193\">Azure Cosmos DB is a fully managed and serverless NoSQL and vector database for modern app development, including AI applications. With its SLA-backed speed and availability as well as instant dynamic scalability, it is ideal for real-time NoSQL and MongoDB applications that require high performance and distributed computing over massive volumes of NoSQL and vector data.<\/p>\n<p class=\"code-line\" dir=\"auto\" data-line=\"195\">To stay in the loop on Azure Cosmos DB updates, follow us on\u00a0<a href=\"https:\/\/twitter.com\/AzureCosmosDB\" data-href=\"https:\/\/twitter.com\/AzureCosmosDB\">X<\/a>,\u00a0<a href=\"https:\/\/aka.ms\/AzureCosmosDBYouTube\" data-href=\"https:\/\/aka.ms\/AzureCosmosDBYouTube\">YouTube<\/a>, and\u00a0<a href=\"https:\/\/www.linkedin.com\/company\/azure-cosmos-db\/\" data-href=\"https:\/\/www.linkedin.com\/company\/azure-cosmos-db\/\">LinkedIn<\/a>.<\/p>\n","protected":false},"excerpt":{"rendered":"<p>Recently we introduced the\u00a0Agent Memory Toolkit and the Agentic Retrieval Toolkit for Azure Cosmos DB. The Agent Memory Toolkit gives your agents durable, Cosmos-backed memory: it stores raw conversation turns and then distills them into higher-value derived memories (thread summaries, extracted facts, and cross-thread user profiles), all searchable with vector, full-text, and hybrid search in [&hellip;]<\/p>\n","protected":false},"author":9387,"featured_media":12722,"comment_status":"open","ping_status":"closed","sticky":false,"template":"","format":"standard","meta":{"_acf_changed":false,"footnotes":""},"categories":[1610,14,1217],"tags":[],"class_list":["post-12720","post","type-post","status-publish","format-standard","has-post-thumbnail","hentry","category-ai","category-core-sql-api","category-python-sdk"],"acf":[],"blog_post_summary":"<p>Recently we introduced the\u00a0Agent Memory Toolkit and the Agentic Retrieval Toolkit for Azure Cosmos DB. The Agent Memory Toolkit gives your agents durable, Cosmos-backed memory: it stores raw conversation turns and then distills them into higher-value derived memories (thread summaries, extracted facts, and cross-thread user profiles), all searchable with vector, full-text, and hybrid search in [&hellip;]<\/p>\n","_links":{"self":[{"href":"https:\/\/devblogs.microsoft.com\/cosmosdb\/wp-json\/wp\/v2\/posts\/12720","targetHints":{"allow":["GET"]}}],"collection":[{"href":"https:\/\/devblogs.microsoft.com\/cosmosdb\/wp-json\/wp\/v2\/posts"}],"about":[{"href":"https:\/\/devblogs.microsoft.com\/cosmosdb\/wp-json\/wp\/v2\/types\/post"}],"author":[{"embeddable":true,"href":"https:\/\/devblogs.microsoft.com\/cosmosdb\/wp-json\/wp\/v2\/users\/9387"}],"replies":[{"embeddable":true,"href":"https:\/\/devblogs.microsoft.com\/cosmosdb\/wp-json\/wp\/v2\/comments?post=12720"}],"version-history":[{"count":2,"href":"https:\/\/devblogs.microsoft.com\/cosmosdb\/wp-json\/wp\/v2\/posts\/12720\/revisions"}],"predecessor-version":[{"id":12731,"href":"https:\/\/devblogs.microsoft.com\/cosmosdb\/wp-json\/wp\/v2\/posts\/12720\/revisions\/12731"}],"wp:featuredmedia":[{"embeddable":true,"href":"https:\/\/devblogs.microsoft.com\/cosmosdb\/wp-json\/wp\/v2\/media\/12722"}],"wp:attachment":[{"href":"https:\/\/devblogs.microsoft.com\/cosmosdb\/wp-json\/wp\/v2\/media?parent=12720"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"https:\/\/devblogs.microsoft.com\/cosmosdb\/wp-json\/wp\/v2\/categories?post=12720"},{"taxonomy":"post_tag","embeddable":true,"href":"https:\/\/devblogs.microsoft.com\/cosmosdb\/wp-json\/wp\/v2\/tags?post=12720"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}