Skip to content

.NET: Add AsIChatClientWithStoredOutputDisabled for ProjectResponsesClient#4911

Merged
rogerbarreto merged 2 commits intomicrosoft:mainfrom
rogerbarreto:issues/use-serverstore-middleware
Mar 26, 2026
Merged

.NET: Add AsIChatClientWithStoredOutputDisabled for ProjectResponsesClient#4911
rogerbarreto merged 2 commits intomicrosoft:mainfrom
rogerbarreto:issues/use-serverstore-middleware

Conversation

@rogerbarreto
Copy link
Member

@rogerbarreto rogerbarreto commented Mar 25, 2026

Motivation and Context

Azure AI consumers using ProjectResponsesClient (from Azure.AI.Extensions.OpenAI) had no direct way to disable server-side response storage without taking a dependency on the Microsoft.Agents.AI.OpenAI package. The existing AsIChatClientWithStoredOutputDisabled() extension only targeted the base ResponsesClient type in the OpenAI package.

This change adds a matching extension method for ProjectResponsesClient in the Microsoft.Agents.AI.AzureAI package, enabling Azure AI consumers to disable server-side storage natively.

Description

New extension method:

  • ProjectResponsesClientExtensions.AsIChatClientWithStoredOutputDisabled() in Azure.AI.Extensions.OpenAI namespace
  • Mirrors the existing ResponsesClient extension from the OpenAI package
  • Sets StoredOutputEnabled = false on CreateResponseOptions
  • Preserves/wraps any existing RawRepresentationFactory configuration (e.g., model defaults from AsIChatClient)
  • Includes ReasoningEncryptedContent by default for stateless multi-turn conversations
  • Optional deploymentName parameter (model is no longer required since AsIChatClient() accepts optional model)
  • Experimental attributes match existing OpenAI counterpart: [Experimental(OPENAI001)] on class, [Experimental(MAAI001)] on method

Doc fix:

  • Updated OpenAIResponseClientExtensions.AsIChatClientWithStoredOutputDisabled doc to remove "Required when using a plain ResponsesClient" for the model parameter

Tests:

  • 6 new unit tests in Microsoft.Agents.AI.AzureAI.UnitTests covering:
    • Null guard (ArgumentNullException)
    • Inner client accessibility via GetService<ResponsesClient>()
    • StoredOutputEnabled = false with reasoning encrypted content (default)
    • Explicit includeReasoningEncryptedContent: true
    • includeReasoningEncryptedContent: false excludes reasoning content
    • Optional deploymentName parameter
  • Test helper uses reflection over _configureOptions field, matching the existing pattern in OpenAIResponseClientExtensionsTests

Contribution Checklist

  • The code builds clean without any errors or warnings
  • The PR follows the Contribution Guidelines
  • All unit tests pass, and I have added new tests where possible
  • Is this a breaking change? If yes, add "[BREAKING]" prefix to the title of the PR.

Copilot AI review requested due to automatic review settings March 25, 2026 18:59
@github-actions github-actions bot changed the title Add AsIChatClientWithStoredOutputDisabled for ProjectResponsesClient .NET: Add AsIChatClientWithStoredOutputDisabled for ProjectResponsesClient Mar 25, 2026
Copy link
Contributor

Copilot AI left a comment

Choose a reason for hiding this comment

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

Pull request overview

Adds a ProjectResponsesClient-specific AsIChatClientWithStoredOutputDisabled extension so Azure AI consumers can disable server-side response storage without taking a dependency on Microsoft.Agents.AI.OpenAI, plus adds unit tests and adjusts related XML docs.

Changes:

  • Added ProjectResponsesClientExtensions.AsIChatClientWithStoredOutputDisabled(...) in Azure.AI.Extensions.OpenAI.
  • Added unit tests validating null-guarding, service chain access, and CreateResponseOptions settings.
  • Updated XML doc text for the existing OpenAIResponseClientExtensions method parameter description.

Reviewed changes

Copilot reviewed 3 out of 3 changed files in this pull request and generated 4 comments.

File Description
dotnet/tests/Microsoft.Agents.AI.AzureAI.UnitTests/ProjectResponsesClientExtensionsTests.cs Adds unit tests for the new extension behavior and configuration.
dotnet/src/Microsoft.Agents.AI.OpenAI/Extensions/OpenAIResponseClientExtensions.cs Tweaks XML docs to remove potentially outdated “required model” wording.
dotnet/src/Microsoft.Agents.AI.AzureAI/ProjectResponsesClientExtensions.cs Introduces the new extension method for ProjectResponsesClient to disable stored output and optionally include reasoning encrypted content.

rogerbarreto and others added 2 commits March 25, 2026 20:28
Add extension method on ProjectResponsesClient in Microsoft.Agents.AI.AzureAI
package (Azure.AI.Extensions.OpenAI namespace) mirroring the existing extension
on ResponsesClient in the OpenAI package. This enables Azure AI consumers to
disable server-side response storage without depending on the OpenAI package.

- New ProjectResponsesClientExtensions class with AsIChatClientWithStoredOutputDisabled
- Optional deploymentName parameter (model is no longer required)
- Updated OpenAI counterpart doc to remove 'Required' wording for model param
- Added unit tests covering null guard, inner client accessibility,
  StoredOutputEnabled=false, and reasoning encrypted content inclusion/exclusion

Co-authored-by: Copilot <223556219+Copilot@users.noreply.github.com>
Address PR review feedback: wrap/chain the existing factory instead of
replacing it, so upstream configuration (e.g., deploymentName/model defaults
from AsIChatClient) is preserved.

Co-authored-by: Copilot <223556219+Copilot@users.noreply.github.com>
@rogerbarreto rogerbarreto added this pull request to the merge queue Mar 26, 2026
Merged via the queue into microsoft:main with commit 84fe6c4 Mar 26, 2026
21 checks passed
@rogerbarreto rogerbarreto self-assigned this Mar 26, 2026
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

Projects

Status: Done

Development

Successfully merging this pull request may close these issues.

6 participants