Skip to content

.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

Open
wants to merge 10 commits into
base: main
Choose a base branch
from

Conversation

joslat
Copy link
Contributor

@joslat joslat commented Apr 8, 2025

Motivation and Context

  1. Why
  2. Need to write too much code to set an agent as a plugin:
var agentPlugin = KernelPluginFactory.CreateFromFunctions("AgentPlugin",
            [
                AgentKernelFunctionFactory.CreateFromAgent(this.CreateSalesAssistant()),
                AgentKernelFunctionFactory.CreateFromAgent(this.CreateRefundAgent())
            ]);

while in Python:
plugins=[billing_agent, refund_agent],

  1. Scenario
    Making easier and simpler to write agentic code :)

  2. Issue: .NET Agents New Feature: When Adding an agent as a plugin it is too verbose, I want to do it like in Python! #11439

Description

Added the change as an extension method as KernelPluginFactory is in SemanticKernel.Core without any reference to Agents.Core where the method is. Unsure you would like to add a reference to it in the SemanticKernel.Core, but it would be a lot more simpler to implement.

Now, the changes have been applied here:

var agentPlugin = KernelPluginFactory.CreateFromFunctions("AgentPlugin",

So it would look instead of the above code as:

        KernelPlugin agentPlugin = KernelPluginFactoryExtensions.CreateFromFunctions("AgentPlugin",
            [
                this.CreateSalesAssistant(),
                this.CreateRefundAgent()
            ]);

Which is a little less verbose, and more similar to the Python code.

Contribution Checklist

@joslat joslat requested a review from a team as a code owner April 8, 2025 14:05
@markwallace-microsoft markwallace-microsoft added the .NET Issue or Pull requests regarding .NET code label Apr 8, 2025
@github-actions github-actions bot changed the title initial implementation through an extension method .Net: initial implementation through an extension method Apr 8, 2025
@joslat joslat changed the title .Net: initial implementation through an extension method .Net: KernelPluginFactory.CreateFromFunctions - enable direct support for agents through an extension method Apr 8, 2025
@joslat joslat changed the title .Net: KernelPluginFactory.CreateFromFunctions - enable direct support for agents through an extension method .Net: KernelPluginFactory.CreateFromFunctions - enable direct support for agents implicitly Apr 10, 2025
@joslat
Copy link
Contributor Author

joslat commented Apr 16, 2025

@markwallace-microsoft all changes applied 👍

@markwallace-microsoft markwallace-microsoft changed the title .Net: KernelPluginFactory.CreateFromFunctions - enable direct support for agents implicitly .Net: AgentKernelPluginFactory.CreateFromAgents - enable direct support for agents implicitly Apr 17, 2025
@SergeyMenshykh
Copy link
Member

LGTM: having a unit test or a few would be helpful here.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
.NET Issue or Pull requests regarding .NET code
Projects
None yet
Development

Successfully merging this pull request may close these issues.

.Net Agents New Feature: I want the "Agents as plugins" to be able to access the main agent thread - if I want
5 participants