Skip to content

.NET: fix: preserve Responses logprobs field#5860

Open
he-yufeng wants to merge 1 commit into
microsoft:mainfrom
he-yufeng:fix/openai-hosting-logprobs
Open

.NET: fix: preserve Responses logprobs field#5860
he-yufeng wants to merge 1 commit into
microsoft:mainfrom
he-yufeng:fix/openai-hosting-logprobs

Conversation

@he-yufeng
Copy link
Copy Markdown
Contributor

Summary

  • add the missing logprobs field to the Responses CreateResponse and Response models
  • keep logprobs alongside top_logprobs during JSON deserialize / reserialize round trips
  • cover request and response payloads in OpenAI hosting serialization tests

Fixes #5854.

To verify

  • dotnet test --project tests\Microsoft.Agents.AI.Hosting.OpenAI.UnitTests\Microsoft.Agents.AI.Hosting.OpenAI.UnitTests.csproj -f net10.0 --no-restore --filter-class Microsoft.Agents.AI.Hosting.OpenAI.UnitTests.OpenAIResponsesSerializationTests
  • dotnet build src\Microsoft.Agents.AI.Hosting.OpenAI\Microsoft.Agents.AI.Hosting.OpenAI.csproj -f net10.0 --no-restore --tl:off
  • dotnet build tests\Microsoft.Agents.AI.Hosting.OpenAI.UnitTests\Microsoft.Agents.AI.Hosting.OpenAI.UnitTests.csproj -f net10.0 --no-restore --tl:off
  • dotnet format src\Microsoft.Agents.AI.Hosting.OpenAI\Microsoft.Agents.AI.Hosting.OpenAI.csproj --verify-no-changes --no-restore
  • dotnet format tests\Microsoft.Agents.AI.Hosting.OpenAI.UnitTests\Microsoft.Agents.AI.Hosting.OpenAI.UnitTests.csproj --verify-no-changes --no-restore

Copilot AI review requested due to automatic review settings May 14, 2026 19:07
@moonbox3 moonbox3 added the .NET label May 14, 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

Note

Copilot was unable to run its full agentic suite in this review.

This PR fixes loss of the logprobs field during .NET Responses request/response JSON serialization round-trips by adding the missing model properties and extending serialization tests to cover the behavior.

Changes:

  • Add nullable logprobs to CreateResponse and Response models.
  • Add unit tests to validate logprobs + top_logprobs deserialize/reserialize round trips.

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.Hosting.OpenAI.UnitTests/OpenAIResponsesSerializationTests.cs Adds round-trip serialization tests for logprobs and top_logprobs in request/response payloads.
dotnet/src/Microsoft.Agents.AI.Hosting.OpenAI/Responses/Models/Response.cs Adds Logprobs JSON-mapped property to preserve response payload field.
dotnet/src/Microsoft.Agents.AI.Hosting.OpenAI/Responses/Models/CreateResponse.cs Adds Logprobs JSON-mapped property to preserve request payload field.

Comment on lines +212 to +214
Assert.NotNull(request);
Assert.True(request.Logprobs);
Assert.Equal(3, request.TopLogprobs);
Comment on lines +591 to +593
Assert.NotNull(response);
Assert.True(response.Logprobs);
Assert.Equal(3, response.TopLogprobs);
}

[Fact]
public void Deserialize_CreateRequestWithLogprobs_RoundTripsFields()
}
""";

CreateResponse? request = JsonSerializer.Deserialize(Json, OpenAIHostingJsonContext.Default.CreateResponse);
@he-yufeng he-yufeng force-pushed the fix/openai-hosting-logprobs branch from bbfbec0 to 8a09b0f Compare May 15, 2026 05:53
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

Projects

None yet

Development

Successfully merging this pull request may close these issues.

.NET: [Bug]: Azure.AI.AgentServer.Responses.PayloadValidationException: Required property 'logprobs' is missing

3 participants