diff --git a/dotnet/src/Microsoft.Agents.AI.GitHub.Copilot/GitHubCopilotAgent.cs b/dotnet/src/Microsoft.Agents.AI.GitHub.Copilot/GitHubCopilotAgent.cs index f34d3c252b..d66bdb91a7 100644 --- a/dotnet/src/Microsoft.Agents.AI.GitHub.Copilot/GitHubCopilotAgent.cs +++ b/dotnet/src/Microsoft.Agents.AI.GitHub.Copilot/GitHubCopilotAgent.cs @@ -500,6 +500,9 @@ internal AgentResponseUpdate ConvertToolCompleteToAgentResponseUpdate(ToolExecut JsonValueKind.Number => property.Value.TryGetInt64(out long l) ? (object?)l : property.Value.GetDouble(), + JsonValueKind.Object => property.Value.Clone(), + JsonValueKind.Array => property.Value.Clone(), + JsonValueKind.Undefined => null, _ => property.Value.GetRawText() }; } diff --git a/dotnet/tests/Microsoft.Agents.AI.GitHub.Copilot.UnitTests/GitHubCopilotAgentTests.cs b/dotnet/tests/Microsoft.Agents.AI.GitHub.Copilot.UnitTests/GitHubCopilotAgentTests.cs index f336b0f53e..038453139d 100644 --- a/dotnet/tests/Microsoft.Agents.AI.GitHub.Copilot.UnitTests/GitHubCopilotAgentTests.cs +++ b/dotnet/tests/Microsoft.Agents.AI.GitHub.Copilot.UnitTests/GitHubCopilotAgentTests.cs @@ -350,7 +350,8 @@ public void ConvertToolStartToAgentResponseUpdate_WithAllJsonValueKinds_Converts nullVal = (string?)null, intVal = 100, floatVal = 3.14, - objVal = new { nested = "value" } + objVal = new { nested = "value" }, + arrVal = new List { 1, 2, 3 } }) } }; @@ -367,8 +368,12 @@ public void ConvertToolStartToAgentResponseUpdate_WithAllJsonValueKinds_Converts Assert.Null(content.Arguments["nullVal"]); Assert.Equal(100L, content.Arguments["intVal"]); Assert.Equal(3.14, (double)content.Arguments["floatVal"]!, 2); - // Non-primitive values fall back to raw JSON text - Assert.IsType(content.Arguments["objVal"]); + JsonElement objValElement = Assert.IsType(content.Arguments["objVal"]); + Assert.Equal(JsonValueKind.Object, objValElement.ValueKind); + Assert.Equal("value", objValElement.GetProperty("nested").GetString()); + JsonElement arrValElement = Assert.IsType(content.Arguments["arrVal"]); + Assert.Equal(JsonValueKind.Array, arrValElement.ValueKind); + Assert.Equal(3, arrValElement.GetArrayLength()); } [Fact]