Skip to content

Surface OpenAI-compatible reasoning_content as TextReasoningContent#7295

Merged
stephentoub merged 2 commits intodotnet:mainfrom
stephentoub:reasoning_content
Feb 13, 2026
Merged

Surface OpenAI-compatible reasoning_content as TextReasoningContent#7295
stephentoub merged 2 commits intodotnet:mainfrom
stephentoub:reasoning_content

Conversation

@stephentoub
Copy link
Member

@stephentoub stephentoub commented Feb 13, 2026

Microsoft Reviewers: Open in CodeFlow

@stephentoub stephentoub requested a review from a team as a code owner February 13, 2026 05:19
Copilot AI review requested due to automatic review settings February 13, 2026 05:19
@stephentoub stephentoub added the area-ai Microsoft.Extensions.AI libraries label Feb 13, 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

This PR adds support for surfacing reasoning_content from OpenAI-compatible API providers (such as DeepSeek, vLLM, and OpenRouter) as TextReasoningContent in the Microsoft.Extensions.AI.OpenAI library. These providers expose reasoning information through non-standard JSON fields that are not part of the official OpenAI API schema, requiring extraction via JsonPatch.

Changes:

  • Added logic to extract reasoning_content from non-standard JSON response fields using JsonPatch for both streaming and non-streaming completions
  • Surface the extracted reasoning content as TextReasoningContent instances in the chat response
  • Added comprehensive tests covering both streaming and non-streaming scenarios with realistic response data

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/OpenAIChatClient.cs Added TryGetReasoningDelta and TryGetReasoningMessage helper methods to extract reasoning content from JSON patches, and integrated them into streaming and non-streaming response processing
test/Libraries/Microsoft.Extensions.AI.OpenAI.Tests/OpenAIChatClientTests.cs Added two test methods with realistic response payloads to verify reasoning content extraction works correctly in both streaming and non-streaming modes

@stephentoub stephentoub enabled auto-merge (squash) February 13, 2026 14:07
@stephentoub stephentoub merged commit ef7448d into dotnet:main Feb 13, 2026
6 checks passed
@github-actions github-actions bot locked and limited conversation to collaborators Mar 16, 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.

3 participants