Yesterday I talked about the new agent abstraction in Semantic Kernel and how it can simplify the steps required to build your own AI agent. But what could be better than having one agent? Multiple agents of course!
And that is exactly what was recently introduced as a preview in Semantic Kernel.
As explained in this blog post, there are multiple ways that multiple agents can work together. The simplest way is as a group chat where multiple agents can talk back-and-forth with each other. To avoid that these agents get stuck in a loop this is combined with a custom termination strategy that specifies when the conversation is over.
Here is a small example.
I start with the default Semantic Kernel configuration to create a kernel instance:
Now I define the instructions for the different agents and create them:
Remark: Notice that I can use different kernels with different models if I want to.
To make sure that the conversation is ended I need to specify a TerminationStrategy
:
As a last step I need to bring the multiple agents together in a group chat:
Now I can start the conversation by providing some input:
That’s it!
The full example:
More information
Exploring Multi-Agent AI Systems (microsoft.com)
Introducing enterprise multi-agent support in Semantic Kernel | Semantic Kernel (microsoft.com)