Repository navigation
.NET: Skip empty Foundry memory context messages #8932
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Merged
westey (westey-m)
merged 3 commits into
microsoft:main
from
quifox:fix/foundry-memory-empty-results
Oct 2, 2026
Merged
Changes from all commits
Commits
Show all changes
3 commits
Select commit
Hold shift + click to select a range
File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
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
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
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
86 changes: 86 additions & 0 deletions
86
dotnet/tests/Microsoft.Agents.AI.Foundry.UnitTests/Memory/TestableAIProjectClientTests.cs
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
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,86 @@ | ||
| // Copyright (c) Microsoft. All rights reserved. | ||
|
|
||
| using System; | ||
| using System.Net; | ||
| using System.Net.Http; | ||
| using System.Threading.Tasks; | ||
| using Azure.AI.Projects.Memory; | ||
| using OpenAI.Responses; | ||
|
|
||
| namespace Microsoft.Agents.AI.Foundry.UnitTests.Memory; | ||
|
|
||
| /// <summary>Verifies that the mock transport handles requests generated by the memory SDK.</summary> | ||
| public sealed class TestableAIProjectClientTests | ||
| { | ||
| /// <summary>Verifies the update action route and its accepted response.</summary> | ||
| [Fact] | ||
| public async Task UpdateMemoriesAsync_MatchesSdkRequestAsync() | ||
| { | ||
| // Arrange | ||
| using TestableAIProjectClient testClient = new(); | ||
| MemoryUpdateOptions options = new("test-scope"); | ||
| options.Items.Add(ResponseItem.CreateUserMessageItem("I prefer concise answers.")); | ||
|
|
||
| // Act | ||
| var result = await testClient.Client.MemoryStores.UpdateMemoriesAsync("test-store", options); | ||
|
|
||
| // Assert | ||
| Assert.Equal("test-update-id", result.Value.UpdateId); | ||
| Assert.Equal((int)HttpStatusCode.Accepted, result.GetRawResponse().Status); | ||
| Assert.Equal(HttpMethod.Post, testClient.Handler.LastRequestMethod); | ||
| Assert.Equal("/api/projects/test-project/memory_stores/test-store:update_memories", new Uri(testClient.Handler.LastRequestUri!).AbsolutePath); | ||
| } | ||
|
|
||
| /// <summary>Verifies that deleting a scope uses POST and returns its result.</summary> | ||
| [Fact] | ||
| public async Task DeleteScopeAsync_MatchesSdkRequestAsync() | ||
| { | ||
| // Arrange | ||
| using TestableAIProjectClient testClient = new(); | ||
|
|
||
| // Act | ||
| var result = await testClient.Client.MemoryStores.DeleteScopeAsync("test-store", "test-scope"); | ||
|
|
||
| // Assert | ||
| Assert.True(result.Value.IsDeleted); | ||
| Assert.Equal("test-scope", result.Value.Scope); | ||
| Assert.Equal((int)HttpStatusCode.OK, result.GetRawResponse().Status); | ||
| Assert.Equal(HttpMethod.Post, testClient.Handler.LastRequestMethod); | ||
| Assert.Equal("/api/projects/test-project/memory_stores/test-store:delete_scope", new Uri(testClient.Handler.LastRequestUri!).AbsolutePath); | ||
| } | ||
|
|
||
| /// <summary>Verifies the collection route used to create a memory store.</summary> | ||
| [Fact] | ||
| public async Task CreateMemoryStoreAsync_MatchesSdkRequestAsync() | ||
| { | ||
| // Arrange | ||
| using TestableAIProjectClient testClient = new(); | ||
| MemoryStoreDefaultDefinition definition = new("chat-model", "embedding-model"); | ||
|
|
||
| // Act | ||
| var result = await testClient.Client.MemoryStores.CreateMemoryStoreAsync("test-store", definition); | ||
|
|
||
| // Assert | ||
| Assert.Equal("test-store", result.Value.Name); | ||
| Assert.Equal((int)HttpStatusCode.OK, result.GetRawResponse().Status); | ||
| Assert.Equal(HttpMethod.Post, testClient.Handler.LastRequestMethod); | ||
| Assert.Equal("/api/projects/test-project/memory_stores", new Uri(testClient.Handler.LastRequestUri!).AbsolutePath); | ||
| } | ||
|
|
||
| /// <summary>Verifies that retrieving a memory store uses the configured mock result.</summary> | ||
| [Fact] | ||
| public async Task GetMemoryStoreAsync_MatchesSdkRequestAsync() | ||
| { | ||
| // Arrange | ||
| using TestableAIProjectClient testClient = new(getStoreStatusCode: HttpStatusCode.OK); | ||
|
|
||
| // Act | ||
| var result = await testClient.Client.MemoryStores.GetMemoryStoreAsync("test-store"); | ||
|
|
||
| // Assert | ||
| Assert.Equal("test-store", result.Value.Name); | ||
| Assert.Equal((int)HttpStatusCode.OK, result.GetRawResponse().Status); | ||
| Assert.Equal(HttpMethod.Get, testClient.Handler.LastRequestMethod); | ||
| Assert.Equal("/api/projects/test-project/memory_stores/test-store", new Uri(testClient.Handler.LastRequestUri!).AbsolutePath); | ||
| } | ||
| } |
Oops, something went wrong.
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.
Uh oh!
There was an error while loading. Please reload this page.