From abcf955251142c2c8b46c0e40fde6df7aae0b34b Mon Sep 17 00:00:00 2001 From: "copilot-swe-agent[bot]" <198982749+Copilot@users.noreply.github.com> Date: Tue, 24 Mar 2026 16:08:36 +0000 Subject: [PATCH 1/2] Implement raw JsonElement argument handling Co-authored-by: kzu <169707+kzu@users.noreply.github.com> Agent-Logs-Url: https://github.com/kzu/agent-framework/sessions/ca9509f7-6318-4f1a-8ba2-17e4207bc7c4 --- .../GitHubCopilotAgent.cs | 21 ++++++---- .../GitHubCopilotAgentTests.cs | 41 +++++++++++-------- 2 files changed, 35 insertions(+), 27 deletions(-) diff --git a/dotnet/src/Microsoft.Agents.AI.GitHub.Copilot/GitHubCopilotAgent.cs b/dotnet/src/Microsoft.Agents.AI.GitHub.Copilot/GitHubCopilotAgent.cs index f34d3c252b..f7ddbfac01 100644 --- a/dotnet/src/Microsoft.Agents.AI.GitHub.Copilot/GitHubCopilotAgent.cs +++ b/dotnet/src/Microsoft.Agents.AI.GitHub.Copilot/GitHubCopilotAgent.cs @@ -494,15 +494,18 @@ internal AgentResponseUpdate ConvertToolCompleteToAgentResponseUpdate(ToolExecut arguments[property.Name] = property.Value.ValueKind switch { JsonValueKind.String => property.Value.GetString(), - JsonValueKind.True => true, - JsonValueKind.False => false, - JsonValueKind.Null => null, - JsonValueKind.Number => property.Value.TryGetInt64(out long l) - ? (object?)l - : property.Value.GetDouble(), - _ => property.Value.GetRawText() - }; - } + JsonValueKind.True => true, + JsonValueKind.False => false, + JsonValueKind.Null => null, + 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() + }; + } return arguments; } 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..c4409c3bdf 100644 --- a/dotnet/tests/Microsoft.Agents.AI.GitHub.Copilot.UnitTests/GitHubCopilotAgentTests.cs +++ b/dotnet/tests/Microsoft.Agents.AI.GitHub.Copilot.UnitTests/GitHubCopilotAgentTests.cs @@ -343,17 +343,18 @@ public void ConvertToolStartToAgentResponseUpdate_WithAllJsonValueKinds_Converts ToolCallId = "call-kinds", ToolName = "multi_type_tool", Arguments = JsonSerializer.SerializeToElement(new - { - strVal = "hello", - boolTrue = true, - boolFalse = false, - nullVal = (string?)null, - intVal = 100, - floatVal = 3.14, - objVal = new { nested = "value" } - }) - } - }; + { + strVal = "hello", + boolTrue = true, + boolFalse = false, + nullVal = (string?)null, + intVal = 100, + floatVal = 3.14, + objVal = new { nested = "value" }, + arrVal = new[] { 1, 2, 3 } + }) + } + }; // Act AgentResponseUpdate result = agent.ConvertToolStartToAgentResponseUpdate(toolStart); @@ -363,13 +364,17 @@ public void ConvertToolStartToAgentResponseUpdate_WithAllJsonValueKinds_Converts Assert.NotNull(content.Arguments); Assert.Equal("hello", content.Arguments["strVal"]); Assert.Equal(true, content.Arguments["boolTrue"]); - Assert.Equal(false, content.Arguments["boolFalse"]); - 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"]); - } + Assert.Equal(false, content.Arguments["boolFalse"]); + Assert.Null(content.Arguments["nullVal"]); + Assert.Equal(100L, content.Arguments["intVal"]); + Assert.Equal(3.14, (double)content.Arguments["floatVal"]!, 2); + 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] public void ConvertToolCompleteToAgentResponseUpdate_WithResult_ReturnsFunctionResultContent() From 501587ba192135c2c63736e549ec28dd467ad0f2 Mon Sep 17 00:00:00 2001 From: "copilot-swe-agent[bot]" <198982749+Copilot@users.noreply.github.com> Date: Tue, 24 Mar 2026 16:10:49 +0000 Subject: [PATCH 2/2] Fix test validation and preserve structured JSON args Co-authored-by: kzu <169707+kzu@users.noreply.github.com> Agent-Logs-Url: https://github.com/kzu/agent-framework/sessions/ca9509f7-6318-4f1a-8ba2-17e4207bc7c4 --- .../GitHubCopilotAgent.cs | 24 +++++----- .../GitHubCopilotAgentTests.cs | 46 +++++++++---------- 2 files changed, 35 insertions(+), 35 deletions(-) diff --git a/dotnet/src/Microsoft.Agents.AI.GitHub.Copilot/GitHubCopilotAgent.cs b/dotnet/src/Microsoft.Agents.AI.GitHub.Copilot/GitHubCopilotAgent.cs index f7ddbfac01..d66bdb91a7 100644 --- a/dotnet/src/Microsoft.Agents.AI.GitHub.Copilot/GitHubCopilotAgent.cs +++ b/dotnet/src/Microsoft.Agents.AI.GitHub.Copilot/GitHubCopilotAgent.cs @@ -494,18 +494,18 @@ internal AgentResponseUpdate ConvertToolCompleteToAgentResponseUpdate(ToolExecut arguments[property.Name] = property.Value.ValueKind switch { JsonValueKind.String => property.Value.GetString(), - JsonValueKind.True => true, - JsonValueKind.False => false, - JsonValueKind.Null => null, - 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() - }; - } + JsonValueKind.True => true, + JsonValueKind.False => false, + JsonValueKind.Null => null, + 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() + }; + } return arguments; } 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 c4409c3bdf..038453139d 100644 --- a/dotnet/tests/Microsoft.Agents.AI.GitHub.Copilot.UnitTests/GitHubCopilotAgentTests.cs +++ b/dotnet/tests/Microsoft.Agents.AI.GitHub.Copilot.UnitTests/GitHubCopilotAgentTests.cs @@ -343,18 +343,18 @@ public void ConvertToolStartToAgentResponseUpdate_WithAllJsonValueKinds_Converts ToolCallId = "call-kinds", ToolName = "multi_type_tool", Arguments = JsonSerializer.SerializeToElement(new - { - strVal = "hello", - boolTrue = true, - boolFalse = false, - nullVal = (string?)null, - intVal = 100, - floatVal = 3.14, - objVal = new { nested = "value" }, - arrVal = new[] { 1, 2, 3 } - }) - } - }; + { + strVal = "hello", + boolTrue = true, + boolFalse = false, + nullVal = (string?)null, + intVal = 100, + floatVal = 3.14, + objVal = new { nested = "value" }, + arrVal = new List { 1, 2, 3 } + }) + } + }; // Act AgentResponseUpdate result = agent.ConvertToolStartToAgentResponseUpdate(toolStart); @@ -364,17 +364,17 @@ public void ConvertToolStartToAgentResponseUpdate_WithAllJsonValueKinds_Converts Assert.NotNull(content.Arguments); Assert.Equal("hello", content.Arguments["strVal"]); Assert.Equal(true, content.Arguments["boolTrue"]); - Assert.Equal(false, content.Arguments["boolFalse"]); - Assert.Null(content.Arguments["nullVal"]); - Assert.Equal(100L, content.Arguments["intVal"]); - Assert.Equal(3.14, (double)content.Arguments["floatVal"]!, 2); - 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()); - } + Assert.Equal(false, content.Arguments["boolFalse"]); + Assert.Null(content.Arguments["nullVal"]); + Assert.Equal(100L, content.Arguments["intVal"]); + Assert.Equal(3.14, (double)content.Arguments["floatVal"]!, 2); + 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] public void ConvertToolCompleteToAgentResponseUpdate_WithResult_ReturnsFunctionResultContent()