Skip to content

.NET: accept JSON string inline skill args#6214

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

.NET: accept JSON string inline skill args#6214
he-yufeng wants to merge 1 commit into
microsoft:mainfrom
he-yufeng:fix/inline-skill-json-string-args

Conversation

@he-yufeng

Copy link
Copy Markdown
Contributor

Fixes #6020.

Summary

  • parse inline skill arguments when an OpenAI-compatible backend sends the function-call arguments as a JSON string containing an object
  • keep the existing fast-fail behavior for non-object arguments and invalid JSON strings
  • add regression coverage for the JSON-string object path and the invalid JSON string path

To verify

  • dotnet restore tests\Microsoft.Agents.AI.UnitTests\Microsoft.Agents.AI.UnitTests.csproj
  • dotnet test --project tests\Microsoft.Agents.AI.UnitTests\Microsoft.Agents.AI.UnitTests.csproj -- --filter-class Microsoft.Agents.AI.UnitTests.AgentSkills.AgentInlineSkillScriptTests
  • dotnet build src\Microsoft.Agents.AI\Microsoft.Agents.AI.csproj --no-restore
  • dotnet format agent-framework-dotnet.slnx --include src\Microsoft.Agents.AI\Skills\Programmatic\AgentInlineSkillScript.cs tests\Microsoft.Agents.AI.UnitTests\AgentSkills\AgentInlineSkillScriptTests.cs --verify-no-changes
  • git diff --check

Copilot AI review requested due to automatic review settings May 30, 2026 22:35

Copilot AI left a comment

Copy link
Copy Markdown
Contributor

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 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 incoming JsonElement is a String, parse it as JSON and use the resulting root element; throw InvalidOperationException on parse failure.
  • Clone JsonElement property values when sourced from the locally-parsed JsonDocument so they remain valid after the document is disposed in finally.
  • 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.

@he-yufeng

Copy link
Copy Markdown
Contributor Author

Rebased on current upstream/main and reran the scoped inline-skill validation locally.

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...HEAD

All passed after the rebase.

@he-yufeng he-yufeng force-pushed the fix/inline-skill-json-string-args branch from 1f10d61 to c9de697 Compare June 4, 2026 06:55
@he-yufeng

Copy link
Copy Markdown
Contributor Author

Rebased this branch on current microsoft:main and reran the scoped inline-skill validation.

Validation on Windows:

dotnet build .\tests\Microsoft.Agents.AI.UnitTests\Microsoft.Agents.AI.UnitTests.csproj -f net10.0 -c Debug --tl:off
# succeeded, 0 warnings, 0 errors

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
# 21 passed

git diff --check upstream/main...HEAD
# passed

@he-yufeng he-yufeng force-pushed the fix/inline-skill-json-string-args branch from c9de697 to 79694c7 Compare June 6, 2026 19:21
@he-yufeng

Copy link
Copy Markdown
Contributor Author

Rebased this branch onto current microsoft:main and force-pushed the cleaned head.

Validation on Windows:

dotnet build .\dotnet\tests\Microsoft.Agents.AI.UnitTests\Microsoft.Agents.AI.UnitTests.csproj -f net10.0 -c Debug --tl:off
# succeeded, 0 warnings, 0 errors

dotnet .\dotnet\tests\Microsoft.Agents.AI.UnitTests\bin\Debug\net10.0\Microsoft.Agents.AI.UnitTests.dll --filter-class Microsoft.Agents.AI.UnitTests.AgentSkills.AgentInlineSkillScriptTests --no-progress
# 21 passed

git diff --check upstream/main..HEAD

I initially tried the dotnet test --project ... -- ... form from the earlier validation note, but this local .NET 10 CLI forwarded --project to MSBuild and failed before running tests. The direct test-dll runner above is the successful validation path.

@he-yufeng he-yufeng force-pushed the fix/inline-skill-json-string-args branch from 79694c7 to cb33c96 Compare June 12, 2026 03:43
@he-yufeng

Copy link
Copy Markdown
Contributor Author

Rebased this branch onto current main and pushed the updated head cb33c961.

Validation run locally from dotnet/:

  • dotnet build .\src\Microsoft.Agents.AI\Microsoft.Agents.AI.csproj -f net10.0 --tl:off -> passed, 0 warnings/errors
  • dotnet run --project .\tests\Microsoft.Agents.AI.UnitTests\Microsoft.Agents.AI.UnitTests.csproj -f net10.0 -> passed, 1649 tests
  • git diff --check upstream/main..HEAD -> passed

I used dotnet run --project for the xUnit v3/MTP test project because dotnet test is not usable with this checkout's current runner configuration on my Windows machine.

@he-yufeng he-yufeng force-pushed the fix/inline-skill-json-string-args branch from cb33c96 to 4435e35 Compare June 12, 2026 11:56
@he-yufeng

Copy link
Copy Markdown
Contributor Author

Rebased this branch onto current main and pushed the updated head $head.

Validation run locally from dotnet/:

  • dotnet build .\src\Microsoft.Agents.AI\Microsoft.Agents.AI.csproj -f net10.0 --tl:off -> passed, 0 warnings/errors
  • dotnet run --project .\tests\Microsoft.Agents.AI.UnitTests\Microsoft.Agents.AI.UnitTests.csproj -f net10.0 -> passed, 1649 tests
  • git diff --check upstream/main..HEAD -> passed

@he-yufeng he-yufeng force-pushed the fix/inline-skill-json-string-args branch 2 times, most recently from 0f1e9cb to 2f67358 Compare June 12, 2026 16:57
@he-yufeng he-yufeng force-pushed the fix/inline-skill-json-string-args branch from 2f67358 to 8272455 Compare June 12, 2026 20:43
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