Skip to content

.NET: fix: handle plain text AG-UI tool results#5817

Open
he-yufeng wants to merge 2 commits into
microsoft:mainfrom
he-yufeng:fix/agui-plain-text-tool-result
Open

.NET: fix: handle plain text AG-UI tool results#5817
he-yufeng wants to merge 2 commits into
microsoft:mainfrom
he-yufeng:fix/agui-plain-text-tool-result

Conversation

@he-yufeng
Copy link
Copy Markdown
Contributor

Summary

  • keep JSON tool-call results deserialized as before
  • fall back to the raw string when an AG-UI TOOL_CALL_RESULT content payload is plain text
  • add a regression test for handoff-style plain text results such as Transferred.

Fixes #5587

Validation

  • dotnet run --project dotnet\tests\Microsoft.Agents.AI.AGUI.UnitTests\Microsoft.Agents.AI.AGUI.UnitTests.csproj --framework net10.0 -- --filter-class Microsoft.Agents.AI.AGUI.UnitTests.ChatResponseUpdateAGUIExtensionsTests
  • dotnet run --project dotnet\tests\Microsoft.Agents.AI.AGUI.UnitTests\Microsoft.Agents.AI.AGUI.UnitTests.csproj --framework net10.0
  • dotnet format dotnet\agent-framework-dotnet.slnx --verify-no-changes --include dotnet\src\Microsoft.Agents.AI.AGUI\Shared\ChatResponseUpdateAGUIExtensions.cs dotnet\tests\Microsoft.Agents.AI.AGUI.UnitTests\ChatResponseUpdateAGUIExtensionsTests.cs
  • git diff --check

Copilot AI review requested due to automatic review settings May 13, 2026 16:19
@moonbox3 moonbox3 added the .NET label May 13, 2026
@github-actions github-actions Bot changed the title fix: handle plain text AG-UI tool results .NET: fix: handle plain text AG-UI tool results May 13, 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

Fixes a crash in the AG-UI client when a TOOL_CALL_RESULT event contains plain text content (e.g., Transferred. from handoff orchestration) that cannot be parsed as JSON. The deserializer now falls back to returning the raw string when JSON parsing fails.

Changes:

  • Wrap JsonSerializer.Deserialize in DeserializeResultIfAvailable with a try/catch on JsonException to fall back to the raw string.
  • Add a regression test for plain text tool call results.

Reviewed changes

Copilot reviewed 2 out of 2 changed files in this pull request and generated no comments.

File Description
dotnet/src/Microsoft.Agents.AI.AGUI/Shared/ChatResponseUpdateAGUIExtensions.cs Catches JsonException during tool call result deserialization and returns the raw string content.
dotnet/tests/Microsoft.Agents.AI.AGUI.UnitTests/ChatResponseUpdateAGUIExtensionsTests.cs Adds a regression test verifying plain text tool call results are preserved as a string.

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]: AGUI client crashes on non-JSON TOOL_CALL_RESULT content from handoff with JsonException ('T' is an invalid start of a value)

3 participants