Skip to content

.NET: accept stringified inline skill arguments#6033

Open
he-yufeng wants to merge 1 commit into
microsoft:mainfrom
he-yufeng:fix/inline-skill-string-arguments
Open

.NET: accept stringified inline skill arguments#6033
he-yufeng wants to merge 1 commit into
microsoft:mainfrom
he-yufeng:fix/inline-skill-string-arguments

Conversation

@he-yufeng
Copy link
Copy Markdown
Contributor

Summary

  • Allow inline skill scripts to accept a JSON object that arrives as a stringified function-call arguments payload.
  • Keep the existing failure path for non-object arguments, including plain strings and arrays.
  • Add regression coverage for stringified object arguments.

Fixes #6020.

To verify

  • dotnet run --project dotnet/tests/Microsoft.Agents.AI.UnitTests/Microsoft.Agents.AI.UnitTests.csproj --framework net10.0 -c Release --no-restore -- --filter-class Microsoft.Agents.AI.UnitTests.AgentSkills.AgentInlineSkillScriptTests
  • dotnet/tests/Microsoft.Agents.AI.UnitTests/bin/Release/net472/Microsoft.Agents.AI.UnitTests.exe --filter-class Microsoft.Agents.AI.UnitTests.AgentSkills.AgentInlineSkillScriptTests
  • git diff --check

Note: dotnet test still hits the existing Microsoft.Testing.Platform/VSTest runner error on .NET 10 SDK, so I used the project runner directly.

Copilot AI review requested due to automatic review settings May 22, 2026 14:53
Copy link
Copy Markdown
Contributor

Copilot AI left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Pull request overview

Note

Copilot was unable to run its full agentic suite in this review.

Adds support for passing skill arguments as a JSON object encoded inside a JSON string, and validates the behavior with a new unit test.

Changes:

  • Parse JsonValueKind.String arguments as JSON (when they contain JSON text) before converting to AIFunctionArguments.
  • Add a unit test covering JSON-string-encoded object arguments.

Reviewed changes

Copilot reviewed 2 out of 2 changed files in this pull request and generated 4 comments.

File Description
dotnet/src/Microsoft.Agents.AI/Skills/Programmatic/AgentInlineSkillScript.cs Adds logic to parse string arguments as JSON before enforcing object-kind arguments.
dotnet/tests/Microsoft.Agents.AI.UnitTests/AgentSkills/AgentInlineSkillScriptTests.cs Adds a test ensuring JSON object text inside a JSON string is accepted and mapped to parameters.

Comment on lines +105 to +107
catch (JsonException)
{
arguments = arguments.Value;
}
catch (JsonException)
{
arguments = arguments.Value;
Comment on lines +52 to +53
using var argsDoc = JsonDocument.Parse("\"{\\\"a\\\":3,\\\"b\\\":7}\"");
var args = argsDoc.RootElement;
// Arrange
var script = new AgentInlineSkillScript("add", (int a, int b) => a + b);
var skill = new AgentInlineSkill("calc-skill", "Calc.", "Instructions.");
using var argsDoc = JsonDocument.Parse("\"{\\\"a\\\":3,\\\"b\\\":7}\"");
@moonbox3 moonbox3 added the .NET label May 22, 2026
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

Projects

None yet

Development

Successfully merging this pull request may close these issues.

.NET: [Bug]: Arguments valueKind is String instead of Object when calling AgentInlineSkillScript via functionCall

3 participants