Uh oh!
There was an error while loading. Please reload this page.
.NET: added Mem0Sharp integration for in-memory storage in agent samples. - #7792
Conversation
Jay Khawaja (jihadkhawaja)
commented
Aug 20, 2026
@microsoft-github-policy-service agree |
There was a problem hiding this comment.
Pull request overview
Adds a Mem0Sharp-based in-memory provider sample demonstrating memory sharing across agent sessions.
Changes:
- Adds the Mem0Sharp provider and runnable sample.
- Documents configuration and persistence alternatives.
- Registers the dependency and sample project.
Reviewed changes
Copilot reviewed 7 out of 7 changed files in this pull request and generated 4 comments.
Show a summary per file
| File | Description |
|---|---|
AgentWithMemory/README.md | Links the new sample. |
Step09.../README.md | Documents setup and storage providers. |
Step09.../Program.cs | Demonstrates cross-session recall. |
Step09.../Mem0SharpProvider.cs | Implements memory storage and retrieval. |
Step09...csproj | Defines dependencies and framework reference. |
Directory.Packages.props | Pins Mem0Sharp 0.2.1. |
agent-framework-dotnet.slnx | Registers the sample project. |
Suppressed comments (2)
dotnet/samples/02-agents/AgentWithMemory/AgentWithMemory_Step09_MemoryUsingMem0Sharp/Mem0SharpProvider.cs:28
GetAllAsyncinjects every memory for the user on every invocation. With the persistent stores documented for this provider, prompt size and retrieval cost grow without bound and unrelated memories are labeled as relevant; use the current external request text to call Mem0Sharp's boundedSearchAsyncinstead.
var memories = await memory.GetAllAsync(
new MemoryFilter(UserId: userId),
cancellationToken: cancellationToken);
dotnet/samples/02-agents/AgentWithMemory/AgentWithMemory_Step09_MemoryUsingMem0Sharp/Mem0SharpProvider.cs:34
- These memories originate verbatim from user messages, but placing them in
Instructionspromotes that untrusted text to the model's instruction channel. A user can persist an instruction in one session and have it override behavior in later sessions. Return the recalled text as a user-role context message instead, matching the repository's built-in memory providers.
Instructions = $"Relevant memories for this user:\n{string.Join(Environment.NewLine, memories.Select(item => $"- {item.Text}"))}",
💡 Add a code-review agent skill for context-aware, tailored reviews. Learn more in the docs.
Uh oh!
There was an error while loading. Please reload this page.
Uh oh!
There was an error while loading. Please reload this page.
Uh oh!
There was an error while loading. Please reload this page.
Uh oh!
There was an error while loading. Please reload this page.
Hi Jay Khawaja (@jihadkhawaja) Thanks for the contribution. Please make this change as a README.md only file that points to your MAF sample in the original repo. https://github.com/jihadkhawaja/mem0sharp/blob/main/samples/AgentFrameworkMemory/README.md Additionally would be interesting to make your library also multi TFM |
Roger Barreto (@rogerbarreto) done, Also added support for multi TFM (net8,9 and netstandard 2.0), thanks! |
#7467