microsoft / semantic-kernel

Integrate cutting-edge LLM technology quickly and easily into your apps
https://aka.ms/semantic-kernel
MIT License
21.88k stars 3.26k forks source link

.Net: Enhance Extensibility of Agent Classes by Unsealing and Implementing Interfaces (.NET, Agents) #8719

Closed joslat closed 4 weeks ago

joslat commented 1 month ago

I propose unsealing the AgentGroupChat, AgentChat, and AggregatorAgent classes and having them implement corresponding interfaces (IAgentGroupChat, IAgentChat). This change will greatly enhance the extensibility and flexibility of the Semantic Kernel, allowing developers to extend and customize these classes to suit various application needs.

Benefits:

I believe these changes will benefit the community and align with the project's goals. I'm open to feedback and willing to adjust the proposal as needed.

joslat commented 1 month ago

I'll follow with a PR - thanks for the adjustments @markwallace-microsoft !!

joslat commented 1 month ago

Initial PR submitted: https://github.com/microsoft/semantic-kernel/pull/8720

crickman commented 1 month ago

@joslat - Thank you for this suggesting and demonstrating the change in the PR. If we were to move forward with this, I wonder if it would make sense to explore the form agent-subclassing might take. For instance, how/where is customer logic applied and what problem does it solve.

I've been working with some other customers that have been able to make use of a composition pattern based on ChatHistoryKernelAgent instead of subclassing (like middle-ware). We might want to compare either approach.

Let's continue this discussion!

joslat commented 1 month ago

Thanks @crickman!

I like the middleware pattern, that would work. Basically you inject there "anything". AutoGen.NET is doing this...

Essentially what I did is to create custom AgentGroupChat(s), see https://github.com/joslat/SemanticKernelAgenticChatWorkflowsExtension/tree/main/SemanticKernel based in IAgentGroupChat where I wrapped AgentGroupChat in AgentGroupChatExt (which implements the interface IAgentGroupChat), so I can finally extend it - created several classes as example implementing:

Don't look at the MiddlewareAgentChat, that didn't work well ;) - left it there for reference.

On the ChatHistoryKernelAgent extensibility, how did you do that middleware injection? I would love to see an operative, working, sample of this...

crickman commented 4 weeks ago

Closing this in conjunection with the PR.

joslat commented 3 weeks ago

Thanks @crickman ! Do you have any example of what you mentioned earlier? "composition pattern based on ChatHistoryKernelAgent instead of subclassing (like middle-ware)."?

I would be very interested on peeking at it :)