.NET: accept JSON string inline skill args#6214
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 inline skill script arguments provided as a JSON-encoded string (in addition to a JSON object), by attempting to parse string-valued JsonElement arguments into JSON before validating they form an object.
Changes:
- In
ConvertToFunctionArguments, when the incomingJsonElementis aString, parse it as JSON and use the resulting root element; throwInvalidOperationExceptionon parse failure. - Clone
JsonElementproperty values when sourced from the locally-parsedJsonDocumentso they remain valid after the document is disposed infinally. - Add two unit tests covering the JSON-string-of-object happy path and the invalid-JSON-string error path.
Reviewed changes
Copilot reviewed 2 out of 2 changed files in this pull request and generated no comments.
| File | Description |
|---|---|
| dotnet/src/Microsoft.Agents.AI/Skills/Programmatic/AgentInlineSkillScript.cs | Accept JSON-string arguments by parsing them, with cloning + disposal to manage document lifetime. |
| dotnet/tests/Microsoft.Agents.AI.UnitTests/AgentSkills/AgentInlineSkillScriptTests.cs | Tests for parsed-string arguments and invalid-JSON-string error. |
fb5e102 to
1f10d61
Compare
|
Rebased on current Validated: dotnet build .\tests\Microsoft.Agents.AI.UnitTests\Microsoft.Agents.AI.UnitTests.csproj -f net10.0 -c Debug --tl:off
dotnet test --project .\tests\Microsoft.Agents.AI.UnitTests\Microsoft.Agents.AI.UnitTests.csproj -f net10.0 -c Debug --no-build -v Normal --report-xunit-trx --ignore-exit-code 8 -- --filter-class Microsoft.Agents.AI.UnitTests.AgentSkills.AgentInlineSkillScriptTests
git diff --check upstream/main...HEADAll passed after the rebase. |
1f10d61 to
c9de697
Compare
|
Rebased this branch on current Validation on Windows: |
c9de697 to
79694c7
Compare
|
Rebased this branch onto current Validation on Windows: I initially tried the |
79694c7 to
cb33c96
Compare
|
Rebased this branch onto current Validation run locally from
I used |
cb33c96 to
4435e35
Compare
|
Rebased this branch onto current main and pushed the updated head $head. Validation run locally from dotnet/:
|
0f1e9cb to
2f67358
Compare
2f67358 to
8272455
Compare
Fixes #6020.
Summary
To verify
dotnet restore tests\Microsoft.Agents.AI.UnitTests\Microsoft.Agents.AI.UnitTests.csprojdotnet test --project tests\Microsoft.Agents.AI.UnitTests\Microsoft.Agents.AI.UnitTests.csproj -- --filter-class Microsoft.Agents.AI.UnitTests.AgentSkills.AgentInlineSkillScriptTestsdotnet build src\Microsoft.Agents.AI\Microsoft.Agents.AI.csproj --no-restoredotnet format agent-framework-dotnet.slnx --include src\Microsoft.Agents.AI\Skills\Programmatic\AgentInlineSkillScript.cs tests\Microsoft.Agents.AI.UnitTests\AgentSkills\AgentInlineSkillScriptTests.cs --verify-no-changesgit diff --check