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

@moonbox3 moonbox3 added the .NET label May 30, 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