NAMS Phase 10d: session-restore asserted live test#144
Merged
Conversation
Formalizes what AgentMemory.Sample.NamsAgent's console demo only showed informally: that a MAF AgentSession's NAMS conversation identity survives SerializeSessionAsync/DeserializeSessionAsync. Drives a real ChatClientAgent (stubbed model only) against the live NAMS SaaS via a real, DI-resolved NamsMemoryContextProvider. A probe of the real serialized-session JSON showed ChatClientAgent's own state-bag serialization already carries the memory identity through automatically (alongside its own InMemoryChatHistoryProvider turn history), so this adds two tests: the documented re-apply-identity-after-restore recipe, and a second proving the state bag survives restore even without re-applying it. Extends NamsLiveFixture with AddAgentMemoryFramework()/ AddNamsAgentMemoryFramework() (additive) and adds the Microsoft.Agents.AI package plus a project reference to AgentMemory.AgentFramework.Nams. Co-Authored-By: Claude Sonnet 5 <noreply@anthropic.com>
Fix a HIGH-severity vacuousness bug: the "with re-applied identity" test re-stamped the restored session using the same closed-over identity values already used before serialization, so it could never actually prove restore preserved anything -- reintroducing, one layer down, the exact triviality the design was meant to avoid. Fixed by reading the restored session's identity back via GetMemoryIdentity() and asserting it independently BEFORE re-applying WithMemoryIdentity. Also: extract PollUntilAsync into a shared NamsLiveTestHelpers (was duplicated verbatim from NamsLiveConnectivityTests.cs), and switch UniqueIds() to a UniqueIdentity() returning NamsConversationIdentity directly with a [CallerMemberName] embedded in UserId for orphan tracing, matching sibling test files' conventions. 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.Sample.NamsAgent's console demo only showed informally: that a MAFAgentSession's NAMS conversation identity survivesSerializeSessionAsync/DeserializeSessionAsync.ChatClientAgent(viaAsAIAgent) wired to a REAL, DI-resolvedNamsMemoryContextProvideragainst the live NAMS SaaS — only the model call is stubbed (NSubstituteIChatClient, canned response), so there's no real LLM dependency, but genuine MAF session-serialization behavior is exercised.ChatClientAgent's own state-bag serialization already embeds the memory identity (user_id/session_id/conversation_id/application_id) alongside its own turn history — so this adds two tests: the sample's documented "re-apply identity after restore" recipe, and a second proving the identity survives restore even without re-applying it.NamsLiveFixturewithAddAgentMemoryFramework()/AddNamsAgentMemoryFramework()(additive; verified non-breaking for all 15 pre-existing NAMS live tests) and adds theMicrosoft.Agents.AIpackage + a project reference toAgentMemory.AgentFramework.Nams.See
docs/reviews/NAMS_Phase10d_SessionRestoreTest_PlanningAndImplementationPlan.mdfor full design reasoning, including why the tests deliberately do NOT assert on the stub chat client's received messages (MAF's own built-in chat history would make that ambiguous), and the self-review findings/fixes below.Self-review
2 parallel independent reviewers found and fixed:
GetMemoryIdentity()independently, before re-applying it.[CallerMemberName]orphan-tracing, duplicatedPollUntilAsync, minor redundancy) — all fixed.Test plan
dotnet build AgentMemory.slnx -c Release— 0 warnings, 0 errorsdotnet test tests/AgentMemory.Tests.Unit— 3262/3262 greendotnet test tests/AgentMemory.Tests.Integration --filter "FullyQualifiedName~Nams"— 17/17 live against real NAMS SaaS (15 previous + 2 new)🤖 Generated with Claude Code