Skip to content

.NET: Skip empty Foundry memory context messages - #8932

Merged
westey (westey-m) merged 3 commits into
microsoft:mainfrom
quifox:fix/foundry-memory-empty-results
Oct 2, 2026
Merged

westey (westey-m) merged 3 commits into
microsoft:mainfrom
quifox:fix/foundry-memory-empty-results

Conversation

@quifox

@quifox quifox (quifox) commented Oct 1, 2026 •

Copy link
Copy Markdown
Contributor

Motivation & Context

A successful Foundry memory search with no usable memory text currently appends an empty user message. Empty results and results containing only blank content should retain the original input without an added memory turn.

Description & Review Guide

  • What are the major changes? Return an empty AIContext when the retrieved memories produce no text. Add public InvokingAsync tests for empty results, blank content, and a usable memory result, and align the fake transport with the SDK search route.
  • What is the impact of these changes? The original messages are preserved when no memory context is available. Usable memories continue to be appended. Error logging in the tests is strict so swallowed search errors cannot masquerade as successful empty results.
  • What do you want reviewers to focus on? Preservation of input messages, empty versus usable memory results, and test transport coverage.

The empty-result regressions fail before the fix and pass afterward. Validation: macOS arm64, .NET SDK 10.0.401; affected net10.0 unit project 489/489 passed. Combined verification with #8931 and #8933: full-solution build with zero warnings and errors; 9,067 unit tests passed, 69 skipped, 0 failed (including FeatureRegistry.UnitTests); formatting checks passed for all changed files. Tests use --culture en-US because five existing PowerFx-related tests depend on English diagnostics. External-service integration tests were not run.

Related Issue

No matching issue was found. The added regression tests reproduce the problem described above.

Contribution Checklist

  • The code builds clean without any errors or warnings
  • All unit tests pass, and I have added new tests where possible
  • The PR follows the Contribution Guidelines
  • This PR is linked to an issue and there is no other open PR for this issue (see Related Issue above).
  • This is not a breaking change. If it is a breaking change, add the breaking change label (or add "[BREAKING]" to the title prefix, before or after any language prefix) — a workflow keeps the label and title prefix in sync automatically.

Copilot AI balanced review requested due to automatic review settings October 1, 2026 08:49
@quifox
quifox (quifox) deployed to github-app-auth October 1, 2026 08:49 — with GitHub Actions Active
@quifox
quifox (quifox) deployed to github-app-auth October 1, 2026 08:50 — with GitHub Actions Active
@agent-framework-automation agent-framework-automation Bot added the .NET Usage: [Issues, PRs], Target: .Net label Oct 1, 2026

Copilot AI left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Copilot review overview

🟢 Approval recommended

The focused fix correctly preserves input context and is covered by success and regression tests.

Review effort: Balanced
Findings: None

What changed in this PR

Prevents Foundry memory searches with no usable content from adding an empty message.

Changes:

  • Return empty context for empty or blank memories.
  • Add regression tests for empty, blank, and usable results.
  • Update the fake transport to match the SDK search route.
File Description
FoundryMemoryProvider.cs Skips empty memory context messages.
FoundryMemoryProviderTests.cs Adds public invocation regression coverage.
TestableAIProjectClient.cs Corrects the mocked search endpoint.

💡 Add a code-review agent skill for context-aware, tailored reviews. Learn more in the docs.

@baywet Vincent Biret (baywet) left a comment

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Thanks for the contribution!

Comment thread dotnet/src/Microsoft.Agents.AI.Foundry/Memory/FoundryMemoryProvider.cs Outdated
@quifox
quifox (quifox) deployed to github-app-auth October 2, 2026 02:07 — with GitHub Actions Active
@westey-m
westey (westey-m) added this pull request to the merge queue Oct 2, 2026
Merged via the queue into microsoft:main with commit a2f4506 Oct 2, 2026
31 checks passed

This branch was successfully deployed

2 active deployments
github-app-auth — d5e44a97 Deployed Oct 2, 2026 by quifox via add_label #24232
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

.NET Usage: [Issues, PRs], Target: .Net

Projects

None yet

Development

Successfully merging this pull request may close these issues.

4 participants