samples: add AgentMemory (Neo4j-agent memory reimplemented in NET ) shopping assistant sample#7096
Merged
westey-m merged 14 commits intoJul 16, 2026
Merged
Conversation
…ory 1.0.1) The .NET port of the official Neo4j Agent Memory "retail assistant" example (neo4j-labs/agent-memory examples/microsoft_agent_retail_assistant, referenced from the Learn integration page), which is currently Python-only. Wires Neo4jMemoryContextProvider (AIContextProvider), MemoryToolFactory memory tools, and a ProductCatalog of retail tools over a Neo4j :Product graph, via the published AgentMemory + AgentMemory.AgentFramework 1.0.1 NuGet packages. Lives at the repo root rather than under dotnet/samples/: that tree is .NET 10 + Central Package Management + Microsoft.Agents.AI ~1.13 with source ProjectReferences, while AgentMemory currently targets net9.0 + Microsoft.Agents.AI 1.9.0. A repo-native version needs AgentMemory bumped to track the newer Agents.AI/Extensions.AI line first. Cross-linked from dotnet/samples/02-agents/AgentWithMemory/README.md as a "See also" entry, same pattern already used for the cross-folder Custom Memory Implementation link. Verified: dotnet build succeeds (0 warnings, 0 errors) against the published packages, proving the AgentMemory public surface is package-consumable. Matches sibling AgentWithMemory samples' conventions (BOM + copyright file header on .cs files, README sections: Features Demonstrated / Prerequisites / Environment Variables / Run the Sample / Expected Output). Co-Authored-By: Claude Sonnet 5 <noreply@anthropic.com>
Relocates the standalone shopping-assistant sample from the repo root into dotnet/samples/02-agents/AgentWithMemory/AgentWithMemory_Step06_MemoryUsingAgentMemory, following that folder's naming/README/solution conventions. Renames its identity from "Neo4j" to "AgentMemory" (the library it actually demonstrates) since this is a community .NET port, not an officially recognized Neo4j integration - Neo4j is still referenced where it's a genuine technical detail (the graph backing store, env vars, Cypher). Adds empty Directory.Build.props/targets markers so it stays isolated from the repo's net10.0/CPM build, and registers it (skipped, like the Mem0 sample) in the CI sample-verification list since it needs a live Neo4j instance. Co-Authored-By: Claude Sonnet 5 <noreply@anthropic.com>
2 tasks
westey-m
reviewed
Jul 14, 2026
westey-m
reviewed
Jul 14, 2026
Co-authored-by: westey <164392973+westey-m@users.noreply.github.com>
westey-m
reviewed
Jul 14, 2026
…6_MemoryUsingAgentMemory/AgentWithMemory_Step06_MemoryUsingAgentMemory.csproj Co-authored-by: westey <164392973+westey-m@users.noreply.github.com>
westey-m
reviewed
Jul 14, 2026
westey-m
reviewed
Jul 14, 2026
westey-m
reviewed
Jul 14, 2026
westey-m
reviewed
Jul 14, 2026
Contributor
Author
|
@westey-m all ready! |
westey-m
reviewed
Jul 15, 2026
westey-m
reviewed
Jul 15, 2026
westey-m
reviewed
Jul 15, 2026
Contributor
Author
|
@westey-m all ready! |
Contributor
Author
|
fixing something - do not merge - yet! |
WithMemoryOwnerScoping(sp) (1.1.0) already removed the need to manually wrap agent.RunAsync in ownerContext.BeginOwnerScope(userId). This picks up 1.2.0's ExposeMemoryToolsFromContextProvider option, so Neo4jMemoryContextProvider now appends the memory tools to AIContext.Tools itself on every model call — no more separate MemoryToolFactory wiring, AIContextProviders = [memoryProvider] is enough. Addresses westey-m's PR review suggestion. Co-Authored-By: Claude Sonnet 5 <noreply@anthropic.com>
Contributor
Author
|
And done!! all points FULLY addressed :) - some at origin |
peibekwe
reviewed
Jul 16, 2026
peibekwe
reviewed
Jul 16, 2026
Contributor
|
@joslat - part of the description mentions that this "ships standalone", but there are no |
peibekwe
approved these changes
Jul 16, 2026
Contributor
Author
|
@peibekwe comments addressed, thanks for looking into it :) |
…to net10.0 Directory.Build.props sets a repo-wide TargetFrameworks (plural) list before this project's own properties are evaluated, and the SDK decides multi-targeting from that plural property at Sdk.props time. The prior singular TargetFramework=net10.0 override didn't take effect early enough, so restore still ran against net9.0/net8.0/netstandard2.0/net472 too - frameworks the published AgentMemory 1.2.0 packages don't support (NU1202), plus surfaced an OpenTelemetry.Api advisory as an error (NU1902) since TreatWarningsAsErrors is on repo-wide. Co-Authored-By: Claude Sonnet 5 <noreply@anthropic.com>
westey-m
approved these changes
Jul 16, 2026
joslat
added a commit
to joslat/semantic-kernel-docs
that referenced
this pull request
Jul 16, 2026
…s index - List the Neo4j Memory Provider under the C# Memory AI Context Providers table in integrations/index.md (previously only linked from the Python pivot), per westey-m's review comment. - Update the C# usage sample to use AddNeo4jAgentMemory's configureMemory/ configureNeo4j overload (the prior single-arg call didn't resolve without an extra import), drop the now-redundant AddAgentMemoryCore/IClock/ IIdGenerator registrations AddNeo4jAgentMemory already wires up, and pass configureLlm so AutoExtractOnPersist isn't a silent no-op. - Wrap the agent in .WithMemoryOwnerScoping(services) instead of a manual BeginOwnerScope around RunAsync, matching the scoping fix from microsoft/agent-framework#7096 (BeginOwnerScope doesn't reliably cover the tool-calling loop). - Fix NEO4J_USER -> NEO4J_USERNAME and overstated .NET 9.0 -> 8.0 prerequisite to match the sibling Neo4j GraphRAG page and the library's actual multi-targeting. Co-Authored-By: Claude Sonnet 5 <noreply@anthropic.com>
The sample opts out of central package management, so it was pulling in OpenTelemetry.Api 1.12.0 transitively (via Microsoft.Agents.AI), which has a known moderate-severity vulnerability (GHSA-g94r-2vxg-569j). The repo treats NuGet audit warnings as errors, so restore failed outright and took down every dotnet-build matrix leg plus check-format. Pinned OpenTelemetry.Api to 1.15.3, matching Directory.Packages.props. With restore succeeding, previously-masked analyzer/format issues surfaced and are fixed too: RCS1118 (const local for immutable Cypher queries), CA1859 (List<IRecord> param instead of IReadOnlyList<IRecord>), and IDE1006 naming violations (s_seed field prefix, PascalCase Cypher/Shopper consts). Verified locally with the same mcr.microsoft.com/dotnet/sdk:10.0 image CI uses: dotnet build --warnaserror and dotnet format --verify-no-changes both pass clean, and a full solution build completed ~24 min with zero errors. Co-Authored-By: Claude Sonnet 5 <noreply@anthropic.com>
westey-m
approved these changes
Jul 16, 2026
Contributor
Author
|
cannot merge anymore... :'( |
westey-m
pushed a commit
to MicrosoftDocs/semantic-kernel-docs
that referenced
this pull request
Jul 16, 2026
* docs: add C# usage for the Neo4j Memory Provider Fills in the C# zone of the Neo4j Memory Provider page, previously just a "not yet available" placeholder, with Prerequisites/Installation/Usage/Key features/Resources sections mirroring the Python zone's structure. Documents the AgentMemory / AgentMemory.AgentFramework NuGet packages (a community .NET port of the Neo4j Labs memory provider, not an official Neo4j Labs package) and links to its source repo and the upcoming Agent Framework retail-assistant sample. Co-Authored-By: Claude Sonnet 5 <noreply@anthropic.com> * Address PR review: fix C# sample and link Neo4j Memory in integrations index - List the Neo4j Memory Provider under the C# Memory AI Context Providers table in integrations/index.md (previously only linked from the Python pivot), per westey-m's review comment. - Update the C# usage sample to use AddNeo4jAgentMemory's configureMemory/ configureNeo4j overload (the prior single-arg call didn't resolve without an extra import), drop the now-redundant AddAgentMemoryCore/IClock/ IIdGenerator registrations AddNeo4jAgentMemory already wires up, and pass configureLlm so AutoExtractOnPersist isn't a silent no-op. - Wrap the agent in .WithMemoryOwnerScoping(services) instead of a manual BeginOwnerScope around RunAsync, matching the scoping fix from microsoft/agent-framework#7096 (BeginOwnerScope doesn't reliably cover the tool-calling loop). - Fix NEO4J_USER -> NEO4J_USERNAME and overstated .NET 9.0 -> 8.0 prerequisite to match the sibling Neo4j GraphRAG page and the library's actual multi-targeting. Co-Authored-By: Claude Sonnet 5 <noreply@anthropic.com> --------- Co-authored-by: Claude Sonnet 5 <noreply@anthropic.com>
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Summary
AgentMemory is a native .NET reimplementation of the graph-native agent memory, inspired by Neo4j Agent Memory and verified against its compatibility kit.
It:
dotnet/samples/02-agents/AgentWithMemory/AgentWithMemory_Step06_MemoryUsingAgentMemory, following that folder's naming/README/solution conventions (AgentWithMemory_StepNN_...).AgentMemorylibrary's Microsoft Agent Framework adapter (Neo4jMemoryContextProvider,MemoryToolFactory) for durable, graph-backed memory: the agent learns a shopper's preferences and recommends products via Neo4j graph traversal, with memory persisting across brand-new sessions.AgentMemoryNuGet packages (which targetMicrosoft.Agents.AI1.9.0) rather than this repo's source projects, so it targetsnet9.0with explicit package versions. EmptyDirectory.Build.props/Directory.Build.targetsmarkers keep it isolated from the repo'snet10.0/ Central-Package-Management build (verified it restores/builds cleanly in isolation).eng/verify-samples/AgentsSamples.cs) with aSkipReason, matching the existing Mem0 sample, since it requires a live Neo4j instance.Test plan
dotnet buildsucceeds for the new project in isolation (confirmedDirectory.Build.props/targetsmarkers correctly block inheritance of the repo'snet10.0/CPM settings —TargetFrameworks,TreatWarningsAsErrorsevaluate empty/false as expected).