-
Notifications
You must be signed in to change notification settings - Fork 4.3k
.Net: AgentKernelPluginFactory.CreateFromAgents - enable direct support for agents implicitly #11443
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Merged
markwallace-microsoft
merged 10 commits into
microsoft:main
from
joslat:joslat-agents-as-plugins-implicit-conversion
Jul 24, 2025
Merged
.Net: AgentKernelPluginFactory.CreateFromAgents - enable direct support for agents implicitly #11443
Changes from all commits
Commits
Show all changes
10 commits
Select commit
Hold shift + click to select a range
e6c7a05
initial implementation through an extension method
joslat 3445f8e
improvement
joslat 3130a0d
Merge branch 'main' into joslat-agents-as-plugins-implicit-conversion
crickman 41d15c7
minor naming update
joslat a385146
Merge branch 'joslat-agents-as-plugins-implicit-conversion' of https:…
joslat 514503f
Merge branch 'main' into joslat-agents-as-plugins-implicit-conversion
joslat 916a3e0
Update AgentKernelPluginFactory.cs
markwallace-microsoft 2607b76
Merge branch 'main' into joslat-agents-as-plugins-implicit-conversion
markwallace-microsoft b220ab8
Update AgentKernelPluginFactory.cs
markwallace-microsoft f75d499
Merge branch 'main' into joslat-agents-as-plugins-implicit-conversion
markwallace-microsoft File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
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
47 changes: 47 additions & 0 deletions
47
dotnet/src/Agents/Core/Functions/AgentKernelPluginFactory.cs
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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,47 @@ | ||
// Copyright (c) Microsoft. All rights reserved. | ||
|
||
using System; | ||
using System.Collections.Generic; | ||
using System.Diagnostics.CodeAnalysis; | ||
using System.Linq; | ||
using Microsoft.SemanticKernel.Agents; | ||
|
||
namespace Microsoft.SemanticKernel; | ||
|
||
/// <summary> | ||
/// Extension methods for creating KernelPlugin instances from agents. | ||
/// </summary> | ||
[Experimental("SKEXP0110")] | ||
public static class AgentKernelPluginFactory | ||
{ | ||
/// <summary> | ||
/// Creates a plugin from a collection of agents. Each agent is converted into a KernelFunction via AgentKernelFunctionFactory. | ||
/// </summary> | ||
/// <param name="pluginName">The name for the plugin.</param> | ||
/// <param name="description">A description of the plugin.</param> | ||
/// <param name="agents">A collection of agents to include in the plugin.</param> | ||
/// <returns>A KernelPlugin with functions derived from the provided agents.</returns> | ||
/// <exception cref="ArgumentNullException">Thrown when agents is null.</exception> | ||
public static KernelPlugin CreateFromAgents(string pluginName, string? description, IEnumerable<Agent> agents) | ||
{ | ||
if (agents == null) | ||
{ | ||
throw new ArgumentNullException(nameof(agents)); | ||
} | ||
|
||
KernelFunction[] functions = agents | ||
.Select(agent => AgentKernelFunctionFactory.CreateFromAgent(agent)) | ||
.ToArray(); | ||
|
||
return KernelPluginFactory.CreateFromFunctions(pluginName, description, functions); | ||
} | ||
|
||
/// <summary> | ||
/// Creates a plugin from an array of agents. Each agent is converted into a KernelFunction via AgentKernelFunctionFactory. | ||
/// </summary> | ||
/// <param name="pluginName">The name for the plugin.</param> | ||
/// <param name="agents">The agents to include in the plugin.</param> | ||
/// <returns>A KernelPlugin with functions derived from the provided agents.</returns> | ||
public static KernelPlugin CreateFromAgents(string pluginName, params Agent[] agents) => | ||
CreateFromAgents(pluginName, description: null, agents); | ||
} |
Oops, something went wrong.
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.
Uh oh!
There was an error while loading. Please reload this page.