From b85d427eea490a154ef479ff1a84f8785f512a79 Mon Sep 17 00:00:00 2001 From: SergeyMenshykh Date: Mon, 7 Sep 2026 11:27:07 +0100 Subject: [PATCH] Improve inline skill argument error Point users to the custom argument marshaler when a model supplies inline skill arguments in an unsupported JSON format. Co-authored-by: Copilot App <223556219+Copilot@users.noreply.github.com> Copilot-Session: 406e0b5c-da2c-40f2-9232-4ff2742aad2c --- .../Skills/Programmatic/AgentInlineSkillScript.cs | 3 ++- .../AgentSkills/SkillScriptArgumentMarshalerTests.cs | 1 + 2 files changed, 3 insertions(+), 1 deletion(-) diff --git a/dotnet/src/Microsoft.Agents.AI/Skills/Programmatic/AgentInlineSkillScript.cs b/dotnet/src/Microsoft.Agents.AI/Skills/Programmatic/AgentInlineSkillScript.cs index b640e08d8e6..cce582b1be4 100644 --- a/dotnet/src/Microsoft.Agents.AI/Skills/Programmatic/AgentInlineSkillScript.cs +++ b/dotnet/src/Microsoft.Agents.AI/Skills/Programmatic/AgentInlineSkillScript.cs @@ -99,7 +99,8 @@ private static AIFunctionArguments ConvertToFunctionArguments(JsonElement? argum if (arguments.Value.ValueKind != JsonValueKind.Object) { throw new InvalidOperationException( - $"Inline skill scripts expect arguments as a JSON object but received a JSON element of kind '{arguments.Value.ValueKind}'."); + $"Inline skill scripts expect arguments as a JSON object but received a JSON element of kind '{arguments.Value.ValueKind}'. " + + "Configure a custom argument marshaler on the skill to handle other argument formats."); } var dict = new Dictionary(); diff --git a/dotnet/tests/Microsoft.Agents.AI.UnitTests/AgentSkills/SkillScriptArgumentMarshalerTests.cs b/dotnet/tests/Microsoft.Agents.AI.UnitTests/AgentSkills/SkillScriptArgumentMarshalerTests.cs index 325ba3f826c..bfc39ec3add 100644 --- a/dotnet/tests/Microsoft.Agents.AI.UnitTests/AgentSkills/SkillScriptArgumentMarshalerTests.cs +++ b/dotnet/tests/Microsoft.Agents.AI.UnitTests/AgentSkills/SkillScriptArgumentMarshalerTests.cs @@ -99,6 +99,7 @@ public async Task DefaultMarshaler_StringArguments_ThrowsAsync() var ex = await Assert.ThrowsAsync( () => script.RunAsync(skill, element, null, CancellationToken.None)); Assert.Contains("String", ex.Message); + Assert.Contains("custom argument marshaler", ex.Message); } [Fact]