.NET: fix: tolerate raw AGUI tool result strings
Fixes #6220.
The AGUI converter serialized FunctionResultContent string values as raw text. The inbound AGUI -> MEAI path then parsed every tool result as JSON, so raw string content such as Success: Function completed. or True could throw JsonException.
This patch makes outbound string tool results valid JSON strings, while keeping the inbound path tolerant of older or external raw string content. Existing JSON object, bool, and number payloads still deserialize as JsonElement.
To verify
dotnet build dotnet\tests\Microsoft.Agents.AI.AGUI.UnitTests\Microsoft.Agents.AI.AGUI.UnitTests.csproj --no-restoredotnet dotnet\tests\Microsoft.Agents.AI.AGUI.UnitTests\bin\Debug\net10.0\Microsoft.Agents.AI.AGUI.UnitTests.dll --filter-class Microsoft.Agents.AI.AGUI.UnitTests.ChatResponseUpdateAGUIExtensionsTests --no-progressdotnet\tests\Microsoft.Agents.AI.AGUI.UnitTests\bin\Debug\net472\Microsoft.Agents.AI.AGUI.UnitTests.exe --filter-class Microsoft.Agents.AI.AGUI.UnitTests.ChatResponseUpdateAGUIExtensionsTests --no-progressdotnet dotnet\tests\Microsoft.Agents.AI.AGUI.UnitTests\bin\Debug\net10.0\Microsoft.Agents.AI.AGUI.UnitTests.dll --no-progressdotnet\tests\Microsoft.Agents.AI.AGUI.UnitTests\bin\Debug\net472\Microsoft.Agents.AI.AGUI.UnitTests.exe --no-progressdotnet format dotnet\tests\Microsoft.Agents.AI.AGUI.UnitTests\Microsoft.Agents.AI.AGUI.UnitTests.csproj --include dotnet\src\Microsoft.Agents.AI.AGUI\Shared\ChatResponseUpdateAGUIExtensions.cs dotnet\tests\Microsoft.Agents.AI.AGUI.UnitTests\ChatResponseUpdateAGUIExtensionsTests.cs --verify-no-changes --no-restoregit diff --check
Rebased on current upstream/main and reran the scoped AGUI validation locally.
Validated:
dotnet build .\tests\Microsoft.Agents.AI.AGUI.UnitTests\Microsoft.Agents.AI.AGUI.UnitTests.csproj -f net10.0 -c Debug --tl:off
dotnet test --project .\tests\Microsoft.Agents.AI.AGUI.UnitTests\Microsoft.Agents.AI.AGUI.UnitTests.csproj -f net10.0 -c Debug --no-build -v Normal --report-xunit-trx --ignore-exit-code 8 -- --filter-class Microsoft.Agents.AI.AGUI.UnitTests.ChatResponseUpdateAGUIExtensionsTests
git diff --check upstream/main...HEAD
All passed after the rebase.
Rebased this PR onto the latest upstream main and re-ran the focused validation.
Validation:
git diff --check upstream/main..HEADdotnet build .\dotnet\tests\Microsoft.Agents.AI.AGUI.UnitTests\Microsoft.Agents.AI.AGUI.UnitTests.csproj -f net10.0 -c Debug --tl:offdotnet .\dotnet\tests\Microsoft.Agents.AI.AGUI.UnitTests\bin\Debug\net10.0\Microsoft.Agents.AI.AGUI.UnitTests.dll --filter-class Microsoft.Agents.AI.AGUI.UnitTests.ChatResponseUpdateAGUIExtensionsTests --no-progress(47 passed)
Rebased this branch onto current main and pushed the updated head b5e84a11.
Validation run locally from dotnet/:
dotnet build .\src\Microsoft.Agents.AI.AGUI\Microsoft.Agents.AI.AGUI.csproj -f net10.0 --tl:off-> passed, 0 warnings/errorsdotnet run --project .\tests\Microsoft.Agents.AI.AGUI.UnitTests\Microsoft.Agents.AI.AGUI.UnitTests.csproj -f net10.0-> passed, 219 testsgit diff --check upstream/main..HEAD-> passed
I used dotnet run --project for the xUnit v3/MTP test project because dotnet test is not usable with this checkout's current runner configuration on my Windows machine.
Rebased this branch onto current main and pushed the updated head $head.
Validation run locally from dotnet/:
- dotnet build .\src\Microsoft.Agents.AI.AGUI\Microsoft.Agents.AI.AGUI.csproj -f net10.0 --tl:off -> passed, 0 warnings/errors
- dotnet run --project .\tests\Microsoft.Agents.AI.AGUI.UnitTests\Microsoft.Agents.AI.AGUI.UnitTests.csproj -f net10.0 -> passed, 219 tests
- git diff --check upstream/main..HEAD -> passed
Is this fix approved? In which release this is planned ?
#6653 replaced the in-tree MAF AG-UI abstractions with the external AG-UI C# SDK and removed Microsoft.Agents.AI.AGUI/Shared/ entirely, including the ChatResponseUpdateAGUIExtensions.cs this changes — so there's nothing left to rebase onto. Closing. Thanks @Mohanr1122 for the review. If raw-string tool results are still mishandled, that now lives in the AGUI.Server SDK, and I'll follow up there.