Skip to content

.NET: [Bug]: Approval response false throwing error in AGUI Client #6220

Closed

Description

@Mohanr1122

Description

if we sending approval response as false, getting error "System.Text.Json.JsonException: ''T' is an invalid start of a value. Path: $ | LineNumber: 0 | BytePositionInLine: 0.'" in AGUI Client

Image

Code Sample

Error Messages / Stack Traces

System.Text.Json.JsonException
  HResult=0x80131500
  Message='T' is an invalid start of a value. Path: $ | LineNumber: 0 | BytePositionInLine: 0.
  Source=System.Text.Json
  StackTrace:
   at System.Text.Json.ThrowHelper.ReThrowWithPath(ReadStack& state, JsonReaderException ex)
   at System.Text.Json.Serialization.JsonConverter`1.ReadCore(Utf8JsonReader& reader, T& value, JsonSerializerOptions options, ReadStack& state)
   at System.Text.Json.Serialization.Metadata.JsonTypeInfo`1.Deserialize(Utf8JsonReader& reader, ReadStack& state)
   at System.Text.Json.Serialization.Metadata.JsonTypeInfo`1.DeserializeAsObject(Utf8JsonReader& reader, ReadStack& state)
   at System.Text.Json.JsonSerializer.ReadFromSpanAsObject(ReadOnlySpan`1 utf8Json, JsonTypeInfo jsonTypeInfo, Nullable`1 actualByteCount)
   at System.Text.Json.JsonSerializer.ReadFromSpanAsObject(ReadOnlySpan`1 json, JsonTypeInfo jsonTypeInfo)
   at System.Text.Json.JsonSerializer.Deserialize(String json, JsonTypeInfo jsonTypeInfo)
   at Microsoft.Agents.AI.AGUI.Shared.ChatResponseUpdateAGUIExtensions.DeserializeResultIfAvailable(ToolCallResultEvent toolCallResult, JsonSerializerOptions options)
   at Microsoft.Agents.AI.AGUI.Shared.ChatResponseUpdateAGUIExtensions.ToolCallBuilder.EmitToolCallResult(ToolCallResultEvent toolCallResult, JsonSerializerOptions options)
   at Microsoft.Agents.AI.AGUI.Shared.ChatResponseUpdateAGUIExtensions.<AsChatResponseUpdatesAsync>d__2.MoveNext()
   at Microsoft.Agents.AI.AGUI.Shared.ChatResponseUpdateAGUIExtensions.<AsChatResponseUpdatesAsync>d__2.MoveNext()
   at Microsoft.Agents.AI.AGUI.Shared.ChatResponseUpdateAGUIExtensions.<AsChatResponseUpdatesAsync>d__2.System.Threading.Tasks.Sources.IValueTaskSource<System.Boolean>.GetResult(Int16 token)
   at Microsoft.Agents.AI.AGUI.AGUIChatClient.AGUIChatClientHandler.<GetStreamingResponseAsync>d__9.MoveNext()
   at Microsoft.Agents.AI.AGUI.AGUIChatClient.AGUIChatClientHandler.<GetStreamingResponseAsync>d__9.MoveNext()
   at Microsoft.Agents.AI.AGUI.AGUIChatClient.AGUIChatClientHandler.<GetStreamingResponseAsync>d__9.System.Threading.Tasks.Sources.IValueTaskSource<System.Boolean>.GetResult(Int16 token)
   at Microsoft.Extensions.AI.FunctionInvokingChatClient.<GetStreamingResponseAsync>d__42.MoveNext()
   at Microsoft.Extensions.AI.FunctionInvokingChatClient.<GetStreamingResponseAsync>d__42.MoveNext()
   at Microsoft.Extensions.AI.FunctionInvokingChatClient.<GetStreamingResponseAsync>d__42.System.Threading.Tasks.Sources.IValueTaskSource<System.Boolean>.GetResult(Int16 token)
   at Microsoft.Agents.AI.AGUI.AGUIChatClient.<GetStreamingResponseAsync>d__4.MoveNext()
   at Microsoft.Agents.AI.AGUI.AGUIChatClient.<GetStreamingResponseAsync>d__4.MoveNext()
   at Microsoft.Agents.AI.AGUI.AGUIChatClient.<GetStreamingResponseAsync>d__4.System.Threading.Tasks.Sources.IValueTaskSource<System.Boolean>.GetResult(Int16 token)
   at Microsoft.Agents.AI.ChatClientAgent.<RunCoreStreamingAsync>d__29.MoveNext()
   at Microsoft.Agents.AI.ChatClientAgent.<RunCoreStreamingAsync>d__29.MoveNext()
   at Microsoft.Agents.AI.ChatClientAgent.<RunCoreStreamingAsync>d__29.MoveNext()
   at Microsoft.Agents.AI.ChatClientAgent.<RunCoreStreamingAsync>d__29.System.Threading.Tasks.Sources.IValueTaskSource<System.Boolean>.GetResult(Int16 token)
   at Microsoft.Agents.AI.AIAgent.<RunStreamingAsync>d__33.MoveNext()
   at Microsoft.Agents.AI.AIAgent.<RunStreamingAsync>d__33.MoveNext()
   at Microsoft.Agents.AI.AIAgent.<RunStreamingAsync>d__33.System.Threading.Tasks.Sources.IValueTaskSource<System.Boolean>.GetResult(Int16 token)
   at ServerFunctionApprovalClientAgent.<RunCoreStreamingAsync>d__3.MoveNext() in \agent-framework-main\dotnet\samples\02-agents\AGUI\Step04_HumanInLoop\Client\ServerFunctionApprovalClientAgent.cs:line 45
   at ServerFunctionApprovalClientAgent.<RunCoreStreamingAsync>d__3.MoveNext() in agent-framework-main\dotnet\samples\02-agents\AGUI\Step04_HumanInLoop\Client\ServerFunctionApprovalClientAgent.cs:line 45
   at ServerFunctionApprovalClientAgent.<RunCoreStreamingAsync>d__3.System.Threading.Tasks.Sources.IValueTaskSource<System.Boolean>.GetResult(Int16 token)
   at Microsoft.Agents.AI.AIAgent.<RunStreamingAsync>d__33.MoveNext()
   at Microsoft.Agents.AI.AIAgent.<RunStreamingAsync>d__33.MoveNext()
   at Microsoft.Agents.AI.AIAgent.<RunStreamingAsync>d__33.System.Threading.Tasks.Sources.IValueTaskSource<System.Boolean>.GetResult(Int16 token)
   at Program.<<Main>$>d__0.MoveNext() in agent-framework-main (1)\agent-framework-main\dotnet\samples\02-agents\AGUI\Step04_HumanInLoop\Client\Program.cs:line 55
   at Program.<<Main>$>d__0.MoveNext() in agent-framework-main (1)\agent-framework-main\dotnet\samples\02-agents\AGUI\Step04_HumanInLoop\Client\Program.cs:line 55

  This exception was originally thrown at this call stack:
    [External Code]

Inner Exception 1:
JsonReaderException: 'T' is an invalid start of a value. LineNumber: 0 | BytePositionInLine: 0.

Package Versions

Microsoft.Agents.AI 1.6.2

.NET Version

No response

Additional Context

No response

Activity

  1. added theissue type on May 31, 2026
  2. added
    bugUsage: [Issues], Target: all issues (Legacy, prefer issue type: bug)
    .NETUsage: [Issues, PRs], Target: .Net
    on May 31, 2026
  3. added
    reproducedUsage: [Issues], Target: all issues that can be reproduced by the triage workflow
    on May 31, 2026
  4. github-actions commented on May 31, 2026

    @github-actions
    Contributor

    🤖 Automated triage reproduction notes (agent-authored — trust but verify)

    Agent analysis

    Repro: DeserializeResultIfAvailable() in dotnet/src/Microsoft.Agents.AI.AGUI/Shared/ChatResponseUpdateAGUIExtensions.cs:431 throws JsonException when ToolCallResultEvent.Content is a non-JSON string like "True" or "False". The mismatch is with SerializeResultContent() at line 742 which passes strings through as-is (string str => str) without JSON-encoding them. Minimal repro: send a ToolCallResultEvent with Content="True" through AsChatResponseUpdatesAsync; the fix should either JSON-encode strings in SerializeResultContent or gracefully handle non-JSON strings in DeserializeResultIfAvailable (e.g., wrap as a JSON string or return the raw string).

    • Failing test: dotnet/tests/Microsoft.Agents.AI.AGUI.UnitTests/ToolCallResultDeserializationTests.cs
    • Files examined: dotnet/src/Microsoft.Agents.AI.AGUI/Shared/ChatResponseUpdateAGUIExtensions.cs, dotnet/src/Microsoft.Agents.AI.AGUI/Shared/ToolCallResultEvent.cs, dotnet/samples/02-agents/AGUI/Step04_HumanInLoop/Client/ServerFunctionAprovalClientAgent.cs, dotnet/samples/02-agents/AGUI/Step04_HumanInLoop/ServerFunctionApprovalServerAgent.cs, dotnet/tests/Microsoft.Agents.AI.AGUI.UnitTests/AGUIChatClientTests.cs
    • Tests run: ToolCallResultDeserializationTests.ToolCallResult_WithBooleanToStringContent_ThrowsJsonException(True), ToolCallResultDeserializationTests.ToolCallResult_WithBooleanToStringContent_ThrowsJsonException(False), ToolCallResultDeserializationTests.ToolCallResult_WithValidJsonContent_DoesNotThrow(true), ToolCallResultDeserializationTests.ToolCallResult_WithValidJsonContent_DoesNotThrow(false), ToolCallResultDeserializationTests.ToolCallResult_WithValidJsonContent_DoesNotThrow(json_object), ToolCallResultDeserializationTests.ToolCallResult_WithValidJsonContent_DoesNotThrow(json_string), ToolCallResultDeserializationTests.SerializeResultContent_WithStringResult_ProducesInvalidJsonForDeserialization
    • Reported version: 1.6.2
    • Current version: 1.8.0
  5. Mohanr1122 commented on May 31, 2026

    @Mohanr1122
    Author

    Same issue when adding handoffbuillder as agent

  6. removed
    triageUsage: [Issues], Target: All issues that still need to be triaged
    on Jun 9, 2026
  7. javiercn commented on Aug 18, 2026

    @javiercn
    Contributor

    This was resolved by the AGUI.Client migration in #6653. The old in-tree result deserializer that attempted to parse True/False as JSON was removed; current AGUI.Client carries the tool result content directly. Closing as resolved.

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

Metadata

Metadata

Labels

.NETUsage: [Issues, PRs], Target: .Netag-uiUsage: [Issues, PRs], Target: AG-UI protocol integrationbugUsage: [Issues], Target: all issues (Legacy, prefer issue type: bug)reproducedUsage: [Issues], Target: all issues that can be reproduced by the triage workflow

Type

Projects

Milestone

No milestone

Relationships

None yet

Development

No branches or pull requests

Issue actions