Skip to content

.NET: [Bug]: AGUI client crashes on non-JSON TOOL_CALL_RESULT content from handoff with JsonException ('T' is an invalid start of a value) #5587

@statto1974

Description

@statto1974

Description

I’m seeing a crash in AGUI streaming when a workflow handoff emits a TOOL_CALL_RESULT with plain text content.

Environment

  1. Microsoft Agent Framework (latest main as of 2026-04-30)
  2. AGUI client via AGUIChatClient
  3. Workflow built with handoff builder and exposed via AGUI endpoint

Repro

  1. Build workflow with handoff orchestration.
  2. Consume endpoint with AGUIChatClient.
  3. Call RunStreamingAsync.
  4. Observe AGUI SSE events:
  • RUN_STARTED
  • TOOL_CALL_START (handoff_to_1)
  • TOOL_CALL_ARGS
  • TOOL_CALL_END
  • TOOL_CALL_RESULT with content: Transferred.

Actual
Client throws:
System.Text.Json.JsonException: 'T' is an invalid start of a value
at ChatResponseUpdateAGUIExtensions.DeserializeResultIfAvailable(ToolCallResultEvent ...)

Expected
Non-JSON tool result content should not crash deserialization.
Either:

treat content as raw string result, or
deserialize as JsonElement only when content is valid JSON.
Root cause candidate
In ChatResponseUpdateAGUIExtensions:

SerializeResultContent returns raw string for FunctionResultContent strings.
DeserializeResultIfAvailable always attempts JsonSerializer.Deserialize(... JsonElement ...) for non-empty content.
This fails for plain text like Transferred.
Suggested fix
Fallback to raw string when JsonElement deserialization fails.

Code Sample

Error Messages / Stack Traces

Package Versions

Microsoft.Agents.AI.AGUI: 1.3.0-preview.260423.1

.NET Version

NET 10.0

Additional Context

No response

Metadata

Metadata

Assignees

Labels

Type

Projects

No projects

Milestone

No milestone

Relationships

None yet

Development

No branches or pull requests

Issue actions