Back openDesk Edu for a sovereign, open-source education β every vote counts.
Vote nowTeaser: Neo4j's AgentMemory SDK for .NET brings graph-backed memory to AI agents β episodic, semantic, and procedural memory types stored as nodes and edges in Neo4j, queryable via Cypher and exposable as MCP tools. This article covers the architecture, retrieval patterns (contextual recall, temporal chaining, cross-session continuity), and a head-to-head comparison with LangChain Memory, Mem0, and custom vector stores.
In July 2026, Neo4j released AgentMemory for .NET β a native .NET sibling to the Neo4j Agent Memory system. The SDK provides a structured, graph-backed memory layer for AI agents built on the .NET stack, using knowledge graphs to store, retrieve, and reason over agent experiences across sessions.
Agent memory has been one of the most active research areas in 2026. Benchmarks from Microsoft's STATE-Bench, GroupMemBench, and others have consistently shown that naive vector-similarity or key-value memory stores fail on tasks requiring multi-step reasoning, temporal ordering, or relationship-aware retrieval. Graph-structured memory β where facts, entities, and their relationships are stored as nodes and edges β has emerged as the most promising alternative.
AgentMemory for .NET brings this graph-backed memory paradigm to the .NET ecosystem with a first-class SDK, tight integration with Neo4j Aura, and native support for the MCP protocol.
The STATE-Bench paper (Microsoft, May 2026) evaluated five memory architectures across 50+ enterprise tasks:
| Memory Architecture | Task Completion | Cross-Session Recall | Relation Tracking |
|---|---|---|---|
| Raw LLM context window | 42% | β None | β None |
| Vector store (FAISS) | 58% | β οΈ Poor | β None |
| Key-value store (Redis) | 51% | β οΈ Partial | β None |
| SQL relational store | 67% | β Good | β οΈ Limited |
| Graph store (AgentMemory) | 82% | β Excellent | β Native |
The graph store's advantage comes from its ability to represent not just facts, but the connections between them β which agent took what action, in what sequence, with which tools, and with what outcome. This relational structure is what enables cross-session recall, causal chaining, and context-aware retrieval.
AgentMemory for .NET follows a layered architecture that separates the memory programming model from the underlying graph storage:
ββββββββββββββββββββββββββββββββββββββββββββββββββββ
β AI Agent (.NET) β
β ββββββββββββββββββββββββββββββββββββββββββββββ β
β β AgentMemory SDK β β
β β β β
β β ββββββββββββββββββββββββ β β
β β β Memory Store API β β β
β β β β’ SaveAsync() β β
β β β β’ RecallAsync() β β
β β β β’ SearchAsync() β β
β β β β’ ForgetAsync() β β
β β ββββββββββββ¬ββββββββββββ β β
β β β β β
β β ββββββββββββΌββββββββββββ β β
β β β Memory Mapper β β
β β β β’ Entity extraction β β
β β β β’ Relation inference β β
β β β β’ Embedding compute β β
β β ββββββββββββ¬ββββββββββββ β β
β β β β β
β β ββββββββββββΌββββββββββββ β β
β β β Storage Adapter β β
β β β β’ Neo4j driver β β
β β β β’ MCP client β β
β β β β’ Local cache β β
β β ββββββββββββββββββββββββ β β
β ββββββββββββββββββββββββββββββββββββββββββββββ β
ββββββββββββββββββββββββββββββββββββββββββββββββββββ
The SDK defines three primary memory types:
Episodic Memory β Records of specific agent actions and observations:
var episode = new Episode
{
Id = Guid.NewGuid(),
Timestamp = DateTime.UtcNow,
AgentId = "code-reviewer-01",
Action = "AnalyzedPullRequest",
Input = "PR #1423: refactor authentication middleware",
Output = "Found 3 potential security issues",
Entities = new[] { "PR-1423", "AuthMiddleware", "JwtHandler" },
Relations = new[] { "referenced", "implemented_by" },
Metadata = new Dictionary<string, object>
{
["repository"] = "org/auth-service",
["confidence"] = 0.87
}
};
await memoryStore.SaveAsync(episode);
Semantic Memory β Extracted knowledge and inferred facts:
var fact = new Fact
{
Id = Guid.NewGuid(),
Statement = "The authentication middleware uses RS256 JWT tokens",
Confidence = 0.92,
Source = "code-reviewer-01",
Entities = new[] { "AuthMiddleware", "RS256", "JWT" },
Validated = false
};
await memoryStore.SaveAsync(fact);
Procedural Memory β Learned patterns and workflows:
var pattern = new Pattern
{
Id = Guid.NewGuid(),
Trigger = "NewPullRequest:contains:auth",
Workflow = "RunSecurityReview",
Frequency = 12,
LastInvoked = DateTime.UtcNow.AddDays(-1)
};
await memoryStore.SaveAsync(pattern);
Under the hood, AgentMemory maps these abstractions to a standardised graph model:
graph TD
E[Episode] -->|REFERENCES| R[Relation]
E -->|MENTIONS| Ent[Entity]
F[Fact] -->|MENTIONS| Ent
F -->|DERIVED_FROM| E
P[Pattern] -->|TRIGGERED| E
E -->|HAS| Prop[Property]
Ent -->|HAS| Prop
classDef memory fill:#4C78A8,stroke:#2c4e6e,color:#fff
classDef entity fill:#54A24B,stroke:#3a7a35,color:#fff
class E,F,P memory
class Ent,R,Prop entity
Node labels: AgentMemory:Episode, AgentMemory:Entity, AgentMemory:Fact, AgentMemory:Pattern
Relationship types: REFERENCES, MENTIONS, DERIVED_FROM, TRIGGERED
The most common retrieval pattern is contextual recall β given a current context, find the most relevant past episodes and facts:
var context = new RecallContext
{
Query = "JWT token validation issues",
AgentId = "code-reviewer-01",
MaxResults = 10,
RecencyWeight = 0.3,
RelevanceWeight = 0.5,
RelationWeight = 0.2
};
var results = await memoryStore.RecallAsync(context);
// Results include episodes, facts, and inferred relationships
The recall algorithm uses a hybrid approach: vector similarity on embeddings (for semantic relevance) combined with graph traversal (for relational relevance). The weights let you tune the balance between "find similar content" and "find connected content."
For debugging and analysis, temporal chaining reconstructs the sequence of events leading to a specific outcome:
var chain = await memoryStore.TraceAsync(
from: "PR-1423",
maxHops: 5,
direction: "backward"
);
// Returns: AuthMiddleware refactor β JwtHandler update β PR #1423 β SecurityReview β IssuesFound
AgentMemory persists across sessions by default. When an agent restarts, it can recover its full memory context:
var session = await memoryStore.ResumeAsync(agentId: "code-reviewer-01");
Console.WriteLine($"Previous session: {session.LastActive}");
Console.WriteLine($"Unresolved items: {session.PendingActions.Count}");
This enables agents to maintain long-running workflows across container restarts, deployment cycles, and even agent identity rotations.
AgentMemory for .NET can optionally expose its memory store as an MCP server, allowing other agents (or the same agent running on a different host) to query its memory:
var mcpHost = new McpHostBuilder()
.WithMemoryStore(memoryStore)
.WithTools(tools =>
{
tools.AddTool("recall", RecallHandler);
tools.AddTool("save_episode", SaveEpisodeHandler);
tools.AddTool("trace", TraceHandler);
})
.Build();
await mcpHost.StartAsync();
This makes AgentMemory interoperable with any MCP-compatible client β Claude Desktop, VS Code Copilot, Cline, or custom agent frameworks.
| Feature | AgentMemory for .NET | LangChain Memory | Mem0 | Custom Vector Store |
|---|---|---|---|---|
| Graph structure | β Native | β Flat | β Flat | β |
| Cross-session recall | β Built-in | β οΈ Limited | β | β |
| Temporal chaining | β | β | β | β |
| Relation tracking | β Native | β | β οΈ Via tagging | β |
| MCP support | β Built-in | β | β | β |
| .NET native | β | β Python | β Python | β |
| Self-hosted | β Neo4j | β Any DB | β Cloud | β Any |
| Query language | Cypher | SQL/Vector | API | API |
Add the NuGet package:
dotnet add package Neo4j.AgentMemory --version 1.0.0-preview.1
Configure the memory store:
using Neo4j.AgentMemory;
var store = new AgentMemoryStore(options =>
{
options.ConnectionString = Environment.GetEnvironmentVariable("NEO4J_CONNECTION");
options.Database = "agentmemory";
options.Schema = AgentMemorySchema.Standard;
options.EmbeddingProvider = new OpenAIEmbeddingProvider("text-embedding-3-small");
});
var agent = new AgentBuilder()
.WithMemory(store)
.WithLlm(new OpenAIClient(options))
.Build();
var response = await agent.RunAsync("Review the latest pull request");
AgentMemory for .NET is in public preview. Key considerations:
IEmbeddingProvider interface.AgentMemorySchema enum currently offers Standard and Minimal variants; Custom schema support is coming.AgentMemory for .NET brings graph-backed agent memory to one of the largest enterprise development ecosystems. By combining Neo4j's native graph storage with a .NET-idiomatic SDK, it enables C# and F# developers to build agents that remember not just what happened, but how things are connected β the difference between a lookup table and a reasoning substrate.
For teams already invested in the .NET ecosystem and exploring agentic AI patterns, AgentMemory for .NET provides a production-grade memory foundation without the complexity of building custom graph-backed memory from scratch.
The SDK and documentation are available via NuGet and the Neo4j AgentMemory GitHub repository.