The ability for Microsoft Agent Framework agents to retain and utilize knowledge across interactions is critical. One solution for this is Agent Memory for .NET, a cutting-edge, mind-blowing, graph-native memory engine that leverages the robust capabilities of Neo4j as its backend. This framework is designed to empower AI agents with persistent memory, enabling them to provide contextually relevant responses and maintain continuity.
In this post, we will explore the key features, real-world applications, and implementation details of Agent Memory for .NET, along with a practical code example to get you started.

Get it? An elephant never forgets. Get it? Get it??
Overview of Agent Memory for .NET
Agent Memory for .NET is a sophisticated solution that allows AI agents to store and recall information across sessions. By utilizing a graph database structure, that is, one that organizes data as nodes, edges and properties, it enables agents to create a rich knowledge graph that captures entities, relationships, and interactions over time.
Key Features and Innovations
Types of Memory:
- Short-term Memory: This component captures the immediate context of conversations, allowing agents to respond appropriately to ongoing dialogues.
- Long-term Memory: This aspect stores a comprehensive knowledge graph that includes entities and relationships, enabling agents to recall past interactions and provide personalized responses.
- Reasoning Memory: By recording the agent’s actions and decisions, this memory type enhances the agent’s ability to make informed decisions in future interactions.
Time-aware Memory: One of the standout features of Agent Memory for .NET is its support for bitemporal recall. Bitemporal recall is the ability of a data system to track and query information across two distinct timelines — in this case valid time (when the fact was true in the real world) and transaction time (when the fact was recorded in the Database). This allows agents to answer questions based on both past beliefs and current knowledge, providing a more nuanced understanding of user queries.
Integration: The framework is designed to be compatible with the Microsoft Agent Framework and other .NET applications. This seamless integration makes it easy for developers to incorporate Agent Memory into existing systems without significant overhead.
Graph-Native Structure: By leveraging Neo4j’s graph database capabilities, Agent Memory for .NET can store and query memory efficiently. This structure allows for complex relationships and interactions to be represented in a way that is both intuitive and powerful.
Implementation: Getting Started with Agent Memory for .NET
To illustrate how to set up Agent Memory for .NET, let’s walk through a simple code example. This demonstrates how to initialize the memory store, store a memory, and retrieve it.
Prerequisites
Before you begin, ensure you have the following:
- .NET SDK installed on your machine.
- A running instance of Neo4j. You can download and install Neo4j from the official website.
Code Example
Here’s a straightforward example of how to set up Agent Memory for .NET using Neo4j:
using Neo4j.Driver;
using AgentMemory;
class Program
{
static async Task Main(string[] args)
{
// Initialize Neo4j Driver
var driver = GraphDatabase.Driver("bolt://localhost:7687", AuthTokens.Basic("neo4j", "password"));
// Create a new memory store
var memoryStore = new MemoryStore(driver);
// Store a memory
await memoryStore.StoreMemory("user123", "What is the capital of France?", "Paris");
// Retrieve a memory
var response = await memoryStore.RetrieveMemory("user123", "What is the capital of France?");
Console.WriteLine(response); // Outputs: Paris
}
}
Explanation of the Code
- Initialize Neo4j Driver: The first step is to create a connection to your Neo4j database using the
GraphDatabase.Drivermethod. Replace the connection string and authentication details with your own. - Create a Memory Store: An instance of
MemoryStoreis created, which will handle the storage and retrieval of memories. - Store a Memory: The
StoreMemorymethod is called to save a memory associated with a specific user. In this case, we store the question “What is the capital of France?” along with the answer “Paris”. - Retrieve a Memory: Finally, we retrieve the stored memory using the
RetrieveMemorymethod and print the response to the console.
By leveraging the power of Neo4j, Agent Memory for .NET provides a solution for enhancing applications with persistent memory.
For more information and resources, see the Agent Memory for .NET GitHub Repository and the Neo4j Blog on Agent Memory.





































