Skip to content

Fix OpenAIResponsesChatClient to respect "store":false in responses#7417

Merged
stephentoub merged 1 commit intodotnet:mainfrom
stephentoub:fixstorefalse
Mar 20, 2026
Merged

Fix OpenAIResponsesChatClient to respect "store":false in responses#7417
stephentoub merged 1 commit intodotnet:mainfrom
stephentoub:fixstorefalse

Conversation

@stephentoub
Copy link
Copy Markdown
Member

@stephentoub stephentoub commented Mar 19, 2026

Fixes #7406

Microsoft Reviewers: Open in CodeFlow

@stephentoub stephentoub requested a review from jozkee March 19, 2026 21:32
@stephentoub stephentoub requested a review from a team as a code owner March 19, 2026 21:32
Copilot AI review requested due to automatic review settings March 19, 2026 21:32
@stephentoub stephentoub enabled auto-merge (squash) March 19, 2026 21:33
@github-actions github-actions Bot added the area-ai Microsoft.Extensions.AI libraries label Mar 19, 2026
Copy link
Copy Markdown
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

This PR updates OpenAIResponsesChatClient so that ConversationId is set to null when the actual OpenAI Responses API result indicates "store": false, even if the request options didn’t explicitly disable stored output. This aligns the abstraction with provider behavior (e.g., OpenRouter) and prevents consumers from assuming a resumable/stored conversation when it isn’t.

Changes:

  • Update non-streaming response conversion to null out ConversationId when the response’s "store" field is false.
  • Update streaming response processing to track "store": false across events and consistently emit ConversationId = null.
  • Add test coverage for both non-streaming and streaming cases where the response (not the request) contains "store": false.

Reviewed changes

Copilot reviewed 2 out of 2 changed files in this pull request and generated no comments.

File Description
src/Libraries/Microsoft.Extensions.AI.OpenAI/OpenAIResponsesChatClient.cs Derives ConversationId based on both request options and the response’s "store" field (via Patch).
test/Libraries/Microsoft.Extensions.AI.OpenAI.Tests/OpenAIResponseClientTests.cs Adds regression tests ensuring ConversationId is null when the response includes "store": false (streaming + non-streaming).

@stephentoub stephentoub merged commit c6aec84 into dotnet:main Mar 20, 2026
12 checks passed
jozkee pushed a commit to jozkee/extensions that referenced this pull request Apr 3, 2026
@github-actions github-actions Bot locked and limited conversation to collaborators Apr 20, 2026
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.

Labels

area-ai Microsoft.Extensions.AI libraries

Projects

None yet

Development

Successfully merging this pull request may close these issues.

UseFunctionCalling extension include whole previous chat history

4 participants