Skip to content

AI: Remove obsolete OpenAI JsonPatch workaround - #7815

Merged
jozkee merged 2 commits into
mainfrom
agents/azure-streaming-null-delta-issue-7790
Oct 12, 2026
Merged

jozkee merged 2 commits into
mainfrom
agents/azure-streaming-null-delta-issue-7790

Conversation

@jozkee

@jozkee jozkee commented Oct 7, 2026 •

Copy link
Copy Markdown
Member

OpenAI 2.14.0 includes the upstream bounds-check fix for openai/openai-dotnet#1281, so this removes the now-obsolete manual reasoning-content JSON traversal and restores direct JsonPatch lookups; relying on the corrected SDK traversal fixes the scenario reported in #7790, where Azure asynchronous content-filter chunks contain a choice with no delta, and supersedes the guard-based approach proposed in #7792. A focused SSE regression test now covers text, stop, the annotation-only null-delta chunk, and trailing usage. Fixes #7790.

OpenAI 2.14.0 includes the upstream bounds-check fix, so direct JsonPatch lookups now safely handle empty choices and null deltas. Removing the manual JSON traversal fixes Azure asynchronous content-filter chunks that contain no delta. Fixes #7790.

Co-authored-by: Copilot <223556219+Copilot@users.noreply.github.com>
@jozkee
jozkee requested a review from a team as a code owner October 7, 2026 21:52
Copilot AI balanced review requested due to automatic review settings October 7, 2026 21:52
@github-actions github-actions Bot added the area-ai Microsoft.Extensions.AI libraries label Oct 7, 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.

🟡 Changes recommended

The null-delta regression needs checked-in automated coverage.

1 open finding
What changed in this PR

Removes the obsolete OpenAI JsonPatch workaround while safely handling empty choices and null-delta Azure chunks.

Changes:

  • Restores direct reasoning-content patch lookups.
  • Removes manual JSON traversal.
File Description
OpenAIChatClient.cs Simplifies reasoning-content extraction using fixed OpenAI 2.14.0 APIs.

🧠 Review effort: Balanced

@dotnet-comment-bot

Copy link
Copy Markdown
Collaborator

‼️ Found issues ‼️

Project Coverage Type Expected Actual
Microsoft.Extensions.Diagnostics.Testing Line 99 98.65 🔻
Microsoft.Extensions.Telemetry Line 93 92.53 🔻
Microsoft.Extensions.AI.OpenAI Line 75 68.22 🔻
Microsoft.Extensions.AI.OpenAI Branch 75 57.39 🔻
Microsoft.Extensions.DataIngestion.MarkItDown Line 75 4.46 🔻
Microsoft.Extensions.DataIngestion.MarkItDown Branch 75 0 🔻
Microsoft.Extensions.Diagnostics.ResourceMonitoring Line 99 96.03 🔻
Microsoft.Extensions.Diagnostics.ResourceMonitoring Branch 99 92.76 🔻
Microsoft.Extensions.Diagnostics.ResourceMonitoring.Kubernetes Line 99 97.73 🔻
Microsoft.Extensions.ServiceDiscovery.Dns Line 75 69.93 🔻
Microsoft.Extensions.ServiceDiscovery.Abstractions Line 75 42.11 🔻
Microsoft.Extensions.ServiceDiscovery.Abstractions Branch 75 42.86 🔻
Microsoft.Extensions.ServiceDiscovery Line 75 68.57 🔻
Microsoft.Extensions.ServiceDiscovery Branch 75 71.43 🔻
Microsoft.Extensions.ServiceDiscovery.Yarp Line 75 73.85 🔻
Microsoft.Extensions.ServiceDiscovery.Yarp Branch 75 70 🔻
Microsoft.Extensions.VectorData.Abstractions Line 75 37.39 🔻
Microsoft.Extensions.VectorData.Abstractions Branch 75 22.73 🔻

🎉 Good job! The coverage increased 🎉
Update MinCodeCoverage in the project files.

Project Expected Actual
Microsoft.Extensions.Http.Diagnostics 94 95
Microsoft.Gen.BuildMetadata 97 100
Microsoft.Gen.MetadataExtractor 57 73
Microsoft.Gen.MetricsReports 67 69
Microsoft.Extensions.AI.Abstractions 82 86
Microsoft.Extensions.AI.Evaluation.NLP 0 78
Microsoft.Extensions.Caching.Hybrid 82 84
Microsoft.Extensions.DataIngestion 75 89
Microsoft.Extensions.DataIngestion.Markdig 75 90
Microsoft.Extensions.Http.Resilience 97 100

Full code coverage report: https://dev.azure.com/dnceng-public/public/_build/results?buildId=1627071&view=codecoverage-tab

Verify Azure annotation-only streaming chunks do not interrupt enumeration and that trailing usage remains available.

Co-authored-by: Copilot <223556219+Copilot@users.noreply.github.com>
@jozkee
jozkee requested review from jeffhandley and a lite review from Copilot October 8, 2026 19:04

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.

🟢 Approval recommended

No unresolved issues were identified, and the changes include targeted regression coverage.

0 open findings

1 resolved since last review

🧠 Review effort: Lite

@dotnet-comment-bot

Copy link
Copy Markdown
Collaborator

‼️ Found issues ‼️

Project Coverage Type Expected Actual
Microsoft.Extensions.Diagnostics.Testing Line 99 98.65 🔻
Microsoft.Extensions.Telemetry Line 93 92.8 🔻
Microsoft.Extensions.AI.OpenAI Line 75 68.22 🔻
Microsoft.Extensions.AI.OpenAI Branch 75 57.39 🔻
Microsoft.Extensions.DataIngestion.MarkItDown Line 75 4.46 🔻
Microsoft.Extensions.DataIngestion.MarkItDown Branch 75 0 🔻
Microsoft.Extensions.Diagnostics.ResourceMonitoring Line 99 96.03 🔻
Microsoft.Extensions.Diagnostics.ResourceMonitoring Branch 99 92.76 🔻
Microsoft.Extensions.Diagnostics.ResourceMonitoring.Kubernetes Line 99 97.73 🔻
Microsoft.Extensions.ServiceDiscovery.Dns Line 75 71.61 🔻
Microsoft.Extensions.ServiceDiscovery Line 75 67.21 🔻
Microsoft.Extensions.ServiceDiscovery Branch 75 71.43 🔻
Microsoft.Extensions.ServiceDiscovery.Abstractions Line 75 42.11 🔻
Microsoft.Extensions.ServiceDiscovery.Abstractions Branch 75 42.86 🔻
Microsoft.Extensions.ServiceDiscovery.Yarp Line 75 73.85 🔻
Microsoft.Extensions.ServiceDiscovery.Yarp Branch 75 70 🔻
Microsoft.Extensions.VectorData.Abstractions Line 75 37.39 🔻
Microsoft.Extensions.VectorData.Abstractions Branch 75 22.73 🔻

🎉 Good job! The coverage increased 🎉
Update MinCodeCoverage in the project files.

Project Expected Actual
Microsoft.Extensions.Http.Diagnostics 94 95
Microsoft.Gen.BuildMetadata 97 100
Microsoft.Gen.MetadataExtractor 57 73
Microsoft.Gen.MetricsReports 67 69
Microsoft.Extensions.AI.Abstractions 82 86
Microsoft.Extensions.AI.Evaluation.NLP 0 78
Microsoft.Extensions.Caching.Hybrid 82 89
Microsoft.Extensions.DataIngestion 75 89
Microsoft.Extensions.DataIngestion.Markdig 75 90
Microsoft.Extensions.Http.Resilience 97 100

Full code coverage report: https://dev.azure.com/dnceng-public/public/_build/results?buildId=1628570&view=codecoverage-tab

@valkiara valkiara 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.

Reviewed 4047f52. OpenAI 2.14.0 is already pinned in eng/packages/General.props, so the direct lookups use the SDK version with the upstream fix.

Ran the adapter test project on net10.0: 391 passed, 163 skipped with live integration tests disabled. I also ran five local cases with an annotation before text: empty choices, a missing delta, an explicit null delta, an empty delta, and null reasoning_content. All completed with text, the stop reason, and trailing usage preserved. The existing streaming and non-streaming reasoning tests passed too.

No issues found in the changed paths.

@jozkee
jozkee merged commit 12d337a into main Oct 12, 2026
6 checks passed
@jozkee
jozkee deleted the agents/azure-streaming-null-delta-issue-7790 branch October 12, 2026 20:51
evgenyfedorov2 pushed a commit to evgenyfedorov2/dotnet-extensions that referenced this pull request Oct 15, 2026
* Remove obsolete OpenAI JsonPatch workaround

OpenAI 2.14.0 includes the upstream bounds-check fix, so direct JsonPatch lookups now safely handle empty choices and null deltas. Removing the manual JSON traversal fixes Azure asynchronous content-filter chunks that contain no delta. Fixes dotnet#7790.

Co-authored-by: Copilot <223556219+Copilot@users.noreply.github.com>

* Add regression test for null-delta filter chunks

Verify Azure annotation-only streaming chunks do not interrupt enumeration and that trailing usage remains available.

Co-authored-by: Copilot <223556219+Copilot@users.noreply.github.com>

---------

Co-authored-by: Copilot <223556219+Copilot@users.noreply.github.com>

(cherry picked from commit 12d337a)

Co-authored-by: Copilot App <223556219+Copilot@users.noreply.github.com>
Copilot-Session: 7f884d96-e2eb-429c-8e19-827062cdb05c
@github-actions github-actions Bot locked and limited conversation to collaborators Nov 12, 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.

[Microsoft.Extensions.AI.OpenAI] Streaming throws on Azure content-filter chunks with null delta (10.10.1)

5 participants