.NET: Support custom types in skill resource and script functions#5152
Merged
SergeyMenshykh merged 2 commits intomicrosoft:mainfrom Apr 8, 2026
Merged
Conversation
Allow callers to pass custom JsonSerializerOptions when creating inline resources and scripts via AgentInlineSkill, AgentClassSkill, AgentInlineSkillResource, and AgentInlineSkillScript. A skill-level default can be set on AgentInlineSkill and overridden per-resource/ script call. Co-authored-by: Copilot <223556219+Copilot@users.noreply.github.com>
Contributor
There was a problem hiding this comment.
Pull request overview
Adds optional JsonSerializerOptions plumbing to the .NET programmatic skill APIs so callers can control JSON marshaling for delegate-backed resources and scripts.
Changes:
- Extend
AgentInlineSkill/AgentClassSkillAPIs to accept optionalJsonSerializerOptions(skill-level default + per-resource/per-script override). - Forward serializer options into
AIFunctionFactorycreation for inline resources/scripts. - Add unit tests and a source-generated
JsonSerializerContextfor custom test types.
Reviewed changes
Copilot reviewed 10 out of 10 changed files in this pull request and generated 5 comments.
Show a summary per file
| File | Description |
|---|---|
| dotnet/src/Microsoft.Agents.AI/Skills/Programmatic/AgentInlineSkill.cs | Adds skill-level default JsonSerializerOptions and per-call override parameters. |
| dotnet/src/Microsoft.Agents.AI/Skills/Programmatic/AgentInlineSkillResource.cs | Passes optional serializer options into delegate-backed resource AIFunction creation. |
| dotnet/src/Microsoft.Agents.AI/Skills/Programmatic/AgentInlineSkillScript.cs | Passes optional serializer options into delegate-backed script AIFunction creation. |
| dotnet/src/Microsoft.Agents.AI/Skills/Programmatic/AgentClassSkill.cs | Extends factory helpers to accept optional JsonSerializerOptions. |
| dotnet/src/Microsoft.Agents.AI/CompatibilitySuppressions.xml | Adds CP0002 suppressions for removed/changed member signatures. |
| dotnet/tests/Microsoft.Agents.AI.UnitTests/AgentSkills/TestSkillTypes.cs | Adds custom test DTOs and a source-gen JSON context. |
| dotnet/tests/Microsoft.Agents.AI.UnitTests/AgentSkills/AgentInlineSkillTests.cs | Adds tests for skill-level defaults and per-script/per-resource overrides. |
| dotnet/tests/Microsoft.Agents.AI.UnitTests/AgentSkills/AgentInlineSkillScriptTests.cs | Adds script marshaling test using custom types + JSO. |
| dotnet/tests/Microsoft.Agents.AI.UnitTests/AgentSkills/AgentInlineSkillResourceTests.cs | Adds resource marshaling test using custom return type + JSO. |
| dotnet/tests/Microsoft.Agents.AI.UnitTests/AgentSkills/AgentClassSkillTests.cs | Adds tests validating JSO support for class-skill helpers. |
dotnet/tests/Microsoft.Agents.AI.UnitTests/AgentSkills/TestSkillTypes.cs
Outdated
Show resolved
Hide resolved
…llTypes.cs Co-authored-by: Copilot <175728472+Copilot@users.noreply.github.com>
3 tasks
westey-m
approved these changes
Apr 8, 2026
rogerbarreto
approved these changes
Apr 8, 2026
Member
rogerbarreto
left a comment
There was a problem hiding this comment.
Should we state that this has "Experimental breaking changes" ?
Similar how OpenAI discern here:
https://github.com/openai/openai-dotnet/blob/OpenAI_2.10.0/CHANGELOG.md#breaking-changes-in-preview-apis
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Summary
Add optional
JsonSerializerOptionsparameter support to the programmatic skill APIs to enable custom types in skill resource and script delegate functions.Changes
AgentInlineSkill– constructors accept an optionalJsonSerializerOptionsas a skill-level default for all delegate-backed resources and scripts. IndividualAddResourceandAddScriptcalls can override it.AgentClassSkill–CreateResource(string, Delegate, ...)andCreateScripthelpers accept an optionalJsonSerializerOptions.AgentInlineSkillResource/AgentInlineSkillScript– constructors updated to forwardJsonSerializerOptionsto the underlyingAIFunction.