Skip to content

.NET: Forward AG-UI forwarded properties from chat options#6651

Open
jstar0 wants to merge 1 commit into
microsoft:mainfrom
jstar0:fix/agui-forwarded-properties-client
Open

.NET: Forward AG-UI forwarded properties from chat options#6651
jstar0 wants to merge 1 commit into
microsoft:mainfrom
jstar0:fix/agui-forwarded-properties-client

Conversation

@jstar0

@jstar0 jstar0 commented Jun 20, 2026

Copy link
Copy Markdown

Motivation & Context

AGUIChatClient currently builds RunAgentInput without copying AG-UI forwarded properties from ChatOptions.AdditionalProperties["ag_ui_forwarded_properties"], so client callers cannot populate the forwardedProps field in the request body.

This fixes #6600.

Description & Review Guide

  • What are the major changes?

    • Populate RunAgentInput.ForwardedProperties from ChatOptions.AdditionalProperties["ag_ui_forwarded_properties"] when the value is a JsonElement.
    • Add a regression test that verifies the serialized AG-UI run input includes the forwarded properties.
  • What is the impact of these changes?

    • AG-UI client requests now preserve the forwarded properties already supported by the server-side hosting path.
    • The change is limited to request construction and does not change public API shape.
  • What do you want reviewers to focus on?

    • Whether the client should only forward JsonElement values here, matching the existing RunAgentInput.ForwardedProperties shape.

Verification:

dotnet run --project dotnet/tests/Microsoft.Agents.AI.AGUI.UnitTests/Microsoft.Agents.AI.AGUI.UnitTests.csproj -f net10.0 -- --filter-method Microsoft.Agents.AI.AGUI.UnitTests.AGUIAgentTests.GetStreamingResponseAsync_ForwardsAdditionalPropertiesInRunInputAsync --output Normal --no-progress
dotnet run --project dotnet/tests/Microsoft.Agents.AI.AGUI.UnitTests/Microsoft.Agents.AI.AGUI.UnitTests.csproj -f net10.0 -- --output Normal --no-progress
dotnet build dotnet/src/Microsoft.Agents.AI.AGUI/Microsoft.Agents.AI.AGUI.csproj -f net10.0 -v minimal
dotnet build dotnet/tests/Microsoft.Agents.AI.AGUI.UnitTests/Microsoft.Agents.AI.AGUI.UnitTests.csproj -f net10.0 -v minimal
git diff --check

Related Issue

Fixes #6600

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 is linked to an issue and there is no other open PR for this issue (see Related Issue above).
  • 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.

Copilot AI review requested due to automatic review settings June 20, 2026 20:28
@moonbox3 moonbox3 added the .NET Issues related to the .NET codebase label Jun 20, 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.

Pull request overview

This PR fixes a gap in the .NET AGUIChatClient request construction by forwarding AG-UI “forwarded properties” from ChatOptions.AdditionalProperties into the RunAgentInput payload, aligning client behavior with the hosting/server-side path and unblocking scenarios that need forwardedProps in the request body.

Changes:

  • Populate RunAgentInput.ForwardedProperties from ChatOptions.AdditionalProperties["ag_ui_forwarded_properties"] when the value is a JsonElement.
  • Add a regression unit test that validates forwarded properties are present in the serialized run input.

Reviewed changes

Copilot reviewed 2 out of 2 changed files in this pull request and generated 1 comment.

File Description
dotnet/src/Microsoft.Agents.AI.AGUI/AGUIChatClient.cs Adds extraction of ag_ui_forwarded_properties from ChatOptions and wires it into RunAgentInput.
dotnet/tests/Microsoft.Agents.AI.AGUI.UnitTests/AGUIChatClientTests.cs Adds a regression test and request-capture plumbing to assert forwarded properties are sent.

Comment on lines +292 to +302
private static JsonElement ExtractForwardedPropertiesFromOptions(ChatOptions? options)
{
if (options?.AdditionalProperties is null ||
!options.AdditionalProperties.TryGetValue("ag_ui_forwarded_properties", out object? forwardedProperties) ||
forwardedProperties is not JsonElement jsonElement)
{
return default;
}

return jsonElement;
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

.NET Issues related to the .NET codebase

Projects

None yet

Development

Successfully merging this pull request may close these issues.

.NET: [Bug]: AGUIChatClient doesnt forward/populate AdditionalProperties

3 participants