.NET: accept stringified inline skill arguments#6033
Conversation
There was a problem hiding this comment.
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.Stringarguments as JSON (when they contain JSON text) before converting toAIFunctionArguments. - 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. |
| catch (JsonException) | ||
| { | ||
| arguments = arguments.Value; |
| } | ||
| catch (JsonException) | ||
| { | ||
| arguments = arguments.Value; |
| 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}\""); |
971b474 to
ac29fcd
Compare
|
Rebased onto current main; no code changes beyond the rebase.\n\nValidation on Windows:\n- dotnet build dotnet\tests\Microsoft.Agents.AI.UnitTests\Microsoft.Agents.AI.UnitTests.csproj -f net10.0 --no-restore\n- dotnet run --project dotnet\tests\Microsoft.Agents.AI.UnitTests\Microsoft.Agents.AI.UnitTests.csproj -f net10.0 --no-restore -- --filter-class '*AgentInlineSkillScriptTests' --no-progress -> 20 passed\n- dotnet build dotnet\tests\Microsoft.Agents.AI.UnitTests\Microsoft.Agents.AI.UnitTests.csproj -f net472 --no-restore\n- dotnet\tests\Microsoft.Agents.AI.UnitTests\bin\Debug\net472\Microsoft.Agents.AI.UnitTests.exe --filter-class '*AgentInlineSkillScriptTests' --no-progress -> 20 passed\n- dotnet format dotnet\agent-framework-dotnet.slnx --verify-no-changes --include dotnet\src\Microsoft.Agents.AI\Skills\Programmatic\AgentInlineSkillScript.cs dotnet\tests\Microsoft.Agents.AI.UnitTests\AgentSkills\AgentInlineSkillScriptTests.cs\n- git diff --check upstream/main..HEAD |
Summary
Fixes #6020.
To verify
Note: dotnet test still hits the existing Microsoft.Testing.Platform/VSTest runner error on .NET 10 SDK, so I used the project runner directly.