Skip to content

.NET: Expand coverage for Microsoft.Agents.AI.Hosting.OpenAI - #10589

Merged
Vincent Biret (baywet) merged 2 commits into
mainfrom
test/coverage-round3-openai
Dec 3, 2026
Merged

Vincent Biret (baywet) merged 2 commits into
mainfrom
test/coverage-round3-openai

Conversation

@baywet

Copy link
Copy Markdown
Member

Motivation & Context

Protect the Chat Completions and Responses wire contracts for defaults, multipart message content, tools, and conversation references.

Description & Review Guide

  • What are the major changes? Verify zero-usage JSON, invalid response formats, function and custom tool option mapping, image and audio media-type normalization, and conversation reference normalization and validation.
  • What is the impact of these changes? Test-only; no implementation or samples change. In paired local .NET 11 Release runs, the target assembly increased from 2101/2420 to 2137/2420 covered lines and from 945/1351 to 982/1351 covered branches.
  • What do you want reviewers to focus on? Check that media normalization preserves the address or bytes and that conversation references preserve their identifier in both accepted wire shapes.

Validated from the dotnet directory with GITHUB_ACTIONS=true for the test run ($root is the worktree and $dest is the results directory):

  • dotnet test --project tests\Microsoft.Agents.AI.Hosting.OpenAI.UnitTests\Microsoft.Agents.AI.Hosting.OpenAI.UnitTests.csproj -f net11.0 -c Release --no-restore -p:CopilotSkipCliDownload=true --coverage --coverage-output-format cobertura --coverage-settings "$root\dotnet\tests\coverage.runsettings" --results-directory $dest — passed: 687 passed, 1 skipped, 0 failed.
  • dotnet format tests\Microsoft.Agents.AI.Hosting.OpenAI.UnitTests\Microsoft.Agents.AI.Hosting.OpenAI.UnitTests.csproj --no-restore --verify-no-changes --severity warn --include tests\Microsoft.Agents.AI.Hosting.OpenAI.UnitTests\OpenAIChatCompletionsSerializationTests.cs tests\Microsoft.Agents.AI.Hosting.OpenAI.UnitTests\OpenAIResponsesSerializationTests.cs — passed.

Related Issue

N/A - trivial change. This adds regression assertions for existing behavior without changing the product contract.

AI Assistance

  • No material AI assistance was used.
  • This is an AI-assisted contribution. I reviewed, understood, and verified all submitted content and accept responsibility for it.

AI assistance details: Copilot identified coverage gaps, wrote the tests, helped validate them, and prepared this description. The human contributor review and attestation remain pending.

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 links to an agreed issue with no competing open PR, or the Related Issue section documents a trivial-change or repository-automation exception.
  • 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.

…t validation

Co-authored-by: Copilot <223556219+Copilot@users.noreply.github.com>
Co-authored-by: Copilot <223556219+Copilot@users.noreply.github.com>
Copilot AI balanced review requested due to automatic review settings December 3, 2026 15:15
@github-actions github-actions Bot added the .NET Usage: [Issues, PRs], Target: .Net label Dec 3, 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.

🟢 Approval recommended

The regression-test changes have no active review issues.

No open issues 🎉

What changed in this PR

Expands regression coverage for .NET OpenAI hosting wire contracts without changing production code or samples.

Changes:

  • Tests image and audio normalization while preserving URLs and bytes.
  • Verifies zero-token usage output, tool declaration mapping, and invalid response formats.
  • Covers conversation reference normalization and invalid shapes.
File Description
dotnet/​tests/​Microsoft.Agents.AI.Hosting.OpenAI.UnitTests/​OpenAIResponsesSerializationTests.cs Tests conversation reference round trips and array rejection.
dotnet/​tests/​Microsoft.Agents.AI.Hosting.OpenAI.UnitTests/​OpenAIChatCompletionsSerializationTests.cs Tests media normalization, default usage, tool mapping, and response-format validation.

Review effort: Balanced

@github-code-quality

Copy link
Copy Markdown
Contributor

Code coverage overview

Languages: C#

C# / code-coverage/dotnet

main 1b1e143 test/coverage-round3... 754bb4b +/-
91% 92% +1%
View coverage of the 10 most impacted files.
File main 1b1e143 test/coverage-round3... 754bb4b +/-
/home/runner/wo...SessionStore.cs 100% 79% -21%
/home/runner/wo...ostedService.cs 82% 87% +5%
/home/runner/wo...dTraceClient.cs 92% 100% +8%
/home/runner/wo...dAgentSource.cs 89% 100% +11%
/home/runner/wo...piExtensions.cs 84% 100% +16%
/home/runner/wo...pletionUsage.cs 0% 47% +47%
/home/runner/wo...onExtensions.cs 37% 100% +63%
/home/runner/wo...foExtensions.cs 28% 95% +67%
/home/runner/wo...ueExtensions.cs 14% 100% +86%
/home/runner/wo...ryExtensions.cs 0% 100% +100%

ℹ️ Calculations represent line coverage. Results may change as calculations are updated.

@baywet
Vincent Biret (baywet) added this pull request to the merge queue Dec 3, 2026
Merged via the queue into main with commit 89cafb8 Dec 3, 2026
37 checks passed
@baywet
Vincent Biret (baywet) deleted the test/coverage-round3-openai branch December 3, 2026 17:20

This branch was previously deployed

1 inactive deployment
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