Skip to content

.NET: Support custom types in skill resource and script functions#5152

Merged
SergeyMenshykh merged 2 commits intomicrosoft:mainfrom
SergeyMenshykh:skills-support-custom-types
Apr 8, 2026
Merged

.NET: Support custom types in skill resource and script functions#5152
SergeyMenshykh merged 2 commits intomicrosoft:mainfrom
SergeyMenshykh:skills-support-custom-types

Conversation

@SergeyMenshykh
Copy link
Copy Markdown
Member

@SergeyMenshykh SergeyMenshykh commented Apr 7, 2026

Summary

Add optional JsonSerializerOptions parameter support to the programmatic skill APIs to enable custom types in skill resource and script delegate functions.

Changes

  • AgentInlineSkill – constructors accept an optional JsonSerializerOptions as a skill-level default for all delegate-backed resources and scripts. Individual AddResource and AddScript calls can override it.
  • AgentClassSkillCreateResource(string, Delegate, ...) and CreateScript helpers accept an optional JsonSerializerOptions.
  • AgentInlineSkillResource / AgentInlineSkillScript – constructors updated to forward JsonSerializerOptions to the underlying AIFunction.

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>
Copilot AI review requested due to automatic review settings April 7, 2026 16:33
@moonbox3 moonbox3 added the .NET label Apr 7, 2026
@SergeyMenshykh SergeyMenshykh changed the title .NET: Add JsonSerializerOptions support to programmatic skill APIs .NET: Support custom types in skill resource and script functions Apr 7, 2026
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

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 / AgentClassSkill APIs to accept optional JsonSerializerOptions (skill-level default + per-resource/per-script override).
  • Forward serializer options into AIFunctionFactory creation for inline resources/scripts.
  • Add unit tests and a source-generated JsonSerializerContext for 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.

…llTypes.cs

Co-authored-by: Copilot <175728472+Copilot@users.noreply.github.com>
@SergeyMenshykh SergeyMenshykh enabled auto-merge April 8, 2026 09:36
Copy link
Copy Markdown
Member

@rogerbarreto rogerbarreto left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

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

@SergeyMenshykh SergeyMenshykh added this pull request to the merge queue Apr 8, 2026
Merged via the queue into microsoft:main with commit 7010dd7 Apr 8, 2026
21 checks passed
@github-project-automation github-project-automation bot moved this from In Review to Done in Agent Framework Apr 8, 2026
@SergeyMenshykh SergeyMenshykh changed the title .NET: Support custom types in skill resource and script functions .NET: [Experimental breaking] Support custom types in skill resource and script functions Apr 8, 2026
@SergeyMenshykh SergeyMenshykh changed the title .NET: [Experimental breaking] Support custom types in skill resource and script functions .NET: Support custom types in skill resource and script functions Apr 8, 2026
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

Projects

Status: Done

Development

Successfully merging this pull request may close these issues.

5 participants