agent-framework icon indicating copy to clipboard operation
agent-framework copied to clipboard

.NET: fix: tolerate raw AGUI tool result strings

Open he-yufeng opened this issue 6 months ago • 4 comments

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-restore
  • dotnet 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
  • dotnet\tests\Microsoft.Agents.AI.AGUI.UnitTests\bin\Debug\net472\Microsoft.Agents.AI.AGUI.UnitTests.exe --filter-class Microsoft.Agents.AI.AGUI.UnitTests.ChatResponseUpdateAGUIExtensionsTests --no-progress
  • dotnet dotnet\tests\Microsoft.Agents.AI.AGUI.UnitTests\bin\Debug\net10.0\Microsoft.Agents.AI.AGUI.UnitTests.dll --no-progress
  • dotnet\tests\Microsoft.Agents.AI.AGUI.UnitTests\bin\Debug\net472\Microsoft.Agents.AI.AGUI.UnitTests.exe --no-progress
  • dotnet 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-restore
  • git diff --check

he-yufeng avatar May 31 '26 08:05 he-yufeng

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.

he-yufeng avatar Jun 02 '26 19:06 he-yufeng

Rebased this PR onto the latest upstream main and re-ran the focused validation.

Validation:

  • git diff --check upstream/main..HEAD
  • dotnet build .\dotnet\tests\Microsoft.Agents.AI.AGUI.UnitTests\Microsoft.Agents.AI.AGUI.UnitTests.csproj -f net10.0 -c Debug --tl:off
  • dotnet .\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)

he-yufeng avatar Jun 06 '26 20:06 he-yufeng

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/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

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.

he-yufeng avatar Jun 12 '26 03:06 he-yufeng

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

he-yufeng avatar Jun 12 '26 11:06 he-yufeng

Is this fix approved? In which release this is planned ?

Mohanr1122 avatar Jun 24 '26 00:06 Mohanr1122

#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.

he-yufeng avatar Jul 12 '26 01:07 he-yufeng