Skip to content

Commit dde4d55

Browse files
Merge pull request #49537 from buzahid/sk-multi-agents
Semantic Kernel orchestration module
2 parents f855ab4 + af83f01 commit dde4d55

15 files changed

+345
-0
lines changed
Lines changed: 13 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,13 @@
1+
### YamlMime:ModuleUnit
2+
uid: learn.wwl.orchestrate-sk-multi-agent-solution.introduction
3+
title: Introduction
4+
metadata:
5+
title: Introduction
6+
description: Learn how to design multi-agent solutions with Semantic Kernel and Azure AI Foundry.
7+
author: buzahid
8+
ms.author: buzahid
9+
ms.date: 03/14/2025
10+
ms.topic: unit
11+
durationInMinutes: 2
12+
content: |
13+
[!include[](includes/1-introduction.md)]
Lines changed: 13 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,13 @@
1+
### YamlMime:ModuleUnit
2+
uid: learn.wwl.orchestrate-sk-multi-agent-solution.understand-agent-framework
3+
title: Understand the Semantic Kernel Agent Framework
4+
metadata:
5+
title: Understand the Semantic Kernel Agent Framework
6+
description: This unit explains the Semantic Kernel Agent Framework.
7+
author: buzahid
8+
ms.author: buzahid
9+
ms.date: 03/14/2025
10+
ms.topic: unit
11+
durationInMinutes: 6
12+
content: |
13+
[!include[](includes/2-understand-agent-framework.md)]
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,13 @@
1+
### YamlMime:ModuleUnit
2+
uid: learn.wwl.orchestrate-sk-multi-agent-solution.design-agent-selection-strategy
3+
title: Design an agent selection strategy
4+
metadata:
5+
title: Design an agent selection strategy
6+
description: Design a strategy that determines which agent should take the next turn.
7+
ms.date: 3/18/2025
8+
author: buzahid
9+
ms.author: buzahid
10+
ms.topic: unit
11+
durationInMinutes: 1
12+
content: |
13+
[!include[](includes/3-design-agent-selection-strategy.md)]
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,13 @@
1+
### YamlMime:ModuleUnit
2+
uid: learn.wwl.orchestrate-sk-multi-agent-solution.define-chat-termination-strategy
3+
title: Define a chat termination strategy
4+
metadata:
5+
title: Define a chat termination strategy
6+
description: Learn how to manage the completion state of the multi-agent collaboration.
7+
author: buzahid
8+
ms.author: buzahid
9+
ms.date: 03/14/2025
10+
ms.topic: unit
11+
durationInMinutes: 6
12+
content: |
13+
[!include[](includes/4-define-chat-termination-strategy.md)]
Lines changed: 13 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,13 @@
1+
### YamlMime:ModuleUnit
2+
uid: learn.wwl.orchestrate-sk-multi-agent-solution.exercise
3+
title: Exercise - Develop a multi-agent solution
4+
metadata:
5+
title: Exercise - Develop a multi-agent solution
6+
description: Learn how to build a multi-agent solution. This unit provides an interactive exercise to develop a multi-agent solution with the Semantic Kernel Agent Framework.
7+
author: buzahid
8+
ms.author: buzahid
9+
ms.date: 03/14/2025
10+
ms.topic: unit
11+
durationInMinutes: 30
12+
content: |
13+
[!include[](includes/5-exercise.md)]
Lines changed: 47 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,47 @@
1+
### YamlMime:ModuleUnit
2+
uid: learn.wwl.orchestrate-sk-multi-agent-solution.knowledge-check
3+
title: Knowledge check
4+
metadata:
5+
title: Knowledge check
6+
description: This unit contains a knowledge check which can help learners reinforce their understanding of the material.
7+
author: buzahid
8+
ms.author: buzahid
9+
ms.date: 03/14/2025
10+
ms.topic: unit
11+
durationInMinutes: 3
12+
content: |
13+
quiz:
14+
questions:
15+
- content: "Which of the following options best describes an agent in the Semantic Kernel Agent Framework?"
16+
choices:
17+
- content: "A human-controlled interface for interacting with AI models"
18+
isCorrect: false
19+
explanation: "Incorrect. Agents in the framework aren't human-controlled; they're autonomous systems designed to process input and complete tasks."
20+
- content: "A storage system used to manage user data"
21+
isCorrect: false
22+
explanation: "Incorrect. Agents don't function as data storage systems; they perform tasks based on user interaction and intent."
23+
- content: "An autonomous system that interacts with users and performs specific tasks based on user input and intent."
24+
isCorrect: true
25+
explanation: "Correct. In the Semantic Kernel Agent Framework, agents are autonomous systems that interact with users, interpret input, and perform tasks tailored to the user's needs."
26+
- content: "How does the Semantic Kernel Agent Framework select the right agent for a task?"
27+
choices:
28+
- content: "By random selection"
29+
isCorrect: false
30+
explanation: "Incorrect. Agent selection isn't random; it's based on analyzing user intent and routing according to specific rules."
31+
- content: "Based on the user's intent and predefined rules"
32+
isCorrect: true
33+
explanation: "Correct. The framework uses intent recognition and predefined rules to route queries to the most relevant agent."
34+
- content: "By the agent's physical location"
35+
isCorrect: false
36+
explanation: "Incorrect. Agent selection isn't based on physical location but on task relevance and expertise."
37+
- content: "What is the role of the Termination Strategy in the Semantic Kernel Agent Framework?"
38+
choices:
39+
- content: "It determines when a conversation or task should end"
40+
isCorrect: true
41+
explanation: "Correct. The Termination Strategy ensures conversations or tasks are properly concluded, preventing unnecessary messages or prolonged interactions."
42+
- content: "It defines the flow of conversation"
43+
isCorrect: false
44+
explanation: "Incorrect. The flow of conversation is managed by the selection strategy, not the termination strategy."
45+
- content: "It decides which agent takes the next turn"
46+
isCorrect: false
47+
explanation: "Incorrect. The next agent to respond is determined by the selection strategy, not the termination strategy."
Lines changed: 13 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,13 @@
1+
### YamlMime:ModuleUnit
2+
uid: learn.wwl.orchestrate-sk-multi-agent-solution.summary
3+
title: Summary
4+
metadata:
5+
title: Summary
6+
description: This unit summarizes the key concepts covered in the module, including key features and how to use Semantic Kernel Agent Framework.
7+
author: buzahid
8+
ms.author: buzahid
9+
ms.date: 03/14/2025
10+
ms.topic: unit
11+
durationInMinutes: 2
12+
content: |
13+
[!include[](includes/7-summary.md)]
Lines changed: 21 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,21 @@
1+
AI agents offer a powerful combination of technologies, able to complete tasks with the use of generative AI. However, in some situations, the task required might be larger than is realistic for a single agent. For those scenarios, consider a **multi-agent** solution. A multi-agent solution allows agents to collaborate within the same conversation.
2+
3+
Imagine you're trying to address common DevOps challenges such as monitoring application performance, identifying issues, and deploying fixes. A multi-agent system could consist of four specialized agents working collaboratively:
4+
5+
- The Monitoring Agent continuously ingests logs and metrics, detects anomalies using natural language processing (NLP), and triggers alerts when issues arise.
6+
7+
- The Root Cause Analysis Agent then correlates these anomalies with recent system changes, using machine learning models or predefined rules to pinpoint the root cause of the problem.
8+
9+
- Once the root cause is identified, the Automated Deployment Agent takes over to implement fixes or roll back problematic changes by interacting with CI/CD pipelines and executing deployment scripts.
10+
11+
- Finally, the Reporting Agent generates detailed reports summarizing the anomalies, root causes, and resolutions, and notifies stakeholders via email or other communication channels.
12+
13+
This modular, scalable, and intelligent multi-agent system streamlines the DevOps process. The agents collaborate to reduce manual intervention and improve efficiency while ensuring timely communication and resolution of issues.
14+
15+
In this module, you'll explore how to use the powerful capabilities of Semantic Kernel to design and orchestrate intelligent agents that work collaboratively to solve complex problems. You'll also learn how to use the Semantic Kernel Agents Framework to develop your own AI agents that can collaborate for a multi-agent solution.
16+
17+
After completing this module, you'll be able to:
18+
19+
- Build AI agents using the Semantic Kernel SDK
20+
- Use tools and plugins with your AI agents
21+
- Develop multi-agent solutions
Lines changed: 45 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,45 @@
1+
Semantic Kernel is an open-source SDK that enables developers to integrate AI models into their applications. Part of that SDK is the *Semantic Kernel Agents Framework*, enabling the creation of agents using the same features that exist in the core Semantic Kernel framework.
2+
3+
## What is the Semantic Kernel Agent Framework?
4+
5+
The Semantic Kernel Agent Framework is a framework designed to help developers build AI-powered agents. These agents can process user inputs, make decisions, and execute tasks autonomously by leveraging large language models and traditional programming logic. The framework provides structured components for defining AI-driven workflows, enabling agents to interact with users, APIs, and external services.
6+
7+
### Core Concepts
8+
9+
The Agent Framework in Semantic Kernel provides architecture on top of existing Semantic Kernel resources, including:
10+
11+
- **Agents**
12+
13+
Agents are intelligent, AI-driven entities capable of reasoning and executing tasks. They use language models, functions, and memory to make decisions dynamically.
14+
15+
- **Agent Collaboration**
16+
17+
Agents can collaborate together through an **agent group chat**, which enables multiple agents to join the same chat, even of different agent types. Agent group chats determine which agent should respond and how to determine if the conversation is finished.
18+
19+
The features that power Semantic Kernel are also still available within the Agent Framework, including:
20+
21+
- **Kernel**
22+
23+
The kernel is the central component of the Semantic Kernel. The kernel acts as the execution engine, managing AI interactions, function orchestration, and memory.
24+
25+
- **Tools and Plugins**
26+
27+
**Plugins** align with existing Semantic Kernel features, enabling agents to dynamically interact with external services or execute complex tasks through function calling. Within the Agent Framework, **tools** are available to provide extra functionality to your agents, such as file searching or code interpreter, similar to tool usage in Azure AI Agent service. Agents use tools and plugins to perform specific tasks.
28+
29+
- **History**
30+
31+
Agents can maintain chat history across multiple interactions, allowing them to track previous interactions and adapt responses accordingly. The conversation history is always accessible by the agents, either as a whole or for a specific agent's chat history.
32+
33+
### Types of Agents
34+
35+
The Semantic Kernel Agent Framework supports several different types of agents, including:
36+
37+
- **Azure AI Agent** - a specialized agent within the Semantic Kernel Agent Framework. The `AsureAIAgent` type is designed to provide advanced conversational capabilities with seamless tool integration. It automates tool calling and securely manages conversation history using threads, reducing the overhead of maintaining state. The `AzureAIAgent` also supports a variety of built-in tools, including file retrieval, code execution, and data interaction via Bing, Azure AI Search, Azure Functions, and OpenAPI.
38+
39+
- **Chat Completion Agent**: designed for chat completion and conversation interfaces. The `ChatCompletionAgent` type mirrors the features and patterns in the underlying AI Service to support natural language processing, contextual understanding, and dialogue management.
40+
41+
- **OpenAI Assistant Agent**: designed for more advanced capabilities and multi-step tasks. The `OpenAIAssistantAgent` type supports goal-driven interactions with additional features like code interpretation and file search.
42+
43+
## Why you should use the Semantic Kernel Agent Framework
44+
45+
The Semantic Kernel Agent Framework offers a robust platform for building intelligent, autonomous, and collaborative AI agents. The framework can integrate agents from multiple sources, including Azure AI Agent Service, and supports both multi-agent collaboration and human-agent interaction. Agents can work together to orchestrate sophisticated workflows, where each agent specializes in a specific task, such as data collection, analysis, or decision-making. The framework also facilitates human-in-the-loop processes, enabling agents to augment human decision-making by providing insights or automating repetitive tasks. This combination of autonomy, collaboration, and interactivity makes the Semantic Kernel Agent Framework an ideal choice for applications requiring dynamic, goal-oriented behavior.
Lines changed: 56 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,56 @@
1+
A key part of the Semantic Kernel Agent Framework is a system designed to facilitate intelligent, multi-agent interactions. Agent collaboration, called `AgentGroupChat`, has critical components to consider that aren't necessary with single agents or non-agentic Semantic Kernel applications.
2+
3+
The following units discuss an example multi-agent solution, where we have two agents in a writer-reviewer scenario:
4+
5+
- A copywriter agent who writes online content, called _CopywriterAgent_.
6+
- A creative director only reviewing the proposals, called _ReviewingDirectorAgent_.
7+
8+
## Agent selection
9+
10+
Choosing the agent best suited to respond to a user's query is pivotal, especially in multi-agent systems where agents specialize in different domains.
11+
12+
For example, if you chat with the agents asking for a slogan for a new scrubbing brush, the _ReviewingDirectorAgent_ shouldn't be invoked to respond since they don't know how to write slogans. Instead, having the _CopywriterAgent_ respond would provide the user an accurate response.
13+
14+
### Why is agent selection important?
15+
16+
- Accuracy: Routing queries to the most relevant agent ensures precise responses.
17+
- Efficiency: It reduces processing time by leveraging the expertise of specialized agents.
18+
- Scalability: Proper selection allows the framework to handle diverse queries without overwhelming individual agents, and provides the best response to the user as the number of agents in the chat grows.
19+
20+
### How does the framework select agents?
21+
22+
**Single-turn conversations**
23+
24+
- Intent recognition: The framework analyzes the user's query to identify the intent and match it with the most relevant agent.
25+
- Predefined rules: Developers can configure routing rules to direct specific queries to designated agents in their application.
26+
27+
**Multi-turn conversations**
28+
29+
- Context tracking: The framework maintains a record of the conversation history to understand the user's intent and select the appropriate agent.
30+
- Dynamic switching: If the topic shifts, the framework dynamically switches to an agent specializing in the new domain in the middle of the conversation.
31+
32+
For multi-turn agents, agent selection is determined by a **selection strategy**. The selection strategy is defined within the framework, either by using one of the predefined selection strategies or by extending a base class to define custom selection behavior. The selection strategy is defined in the creation of the `AgentGroupChat`.
33+
34+
Defining your selection function is done by creating a kernel function from a prompt. In our writer and reviewer example, your selection strategy prompt might be:
35+
36+
```python
37+
prompt=f"""
38+
Determine which participant takes the next turn in a conversation based on the the most recent participant.
39+
State only the name of the participant to take the next turn.
40+
No participant should take more than one turn in a row.
41+
42+
Choose only from these participants:
43+
- ReviewingDirectorAgent
44+
- CopywriterAgent
45+
46+
Always follow these rules when selecting the next participant:
47+
- After user input, it is CopywriterAgent's turn.
48+
- After CopywriterAgent replies, it is ReviewingDirectorAgent's turn.
49+
- After ReviewingDirectorAgent provides feedback, it is CopywriterAgent's turn.
50+
51+
History:
52+
{{$history}}
53+
"""
54+
```
55+
56+
If your preferred interaction should always have a certain agent respond first, that can be specified in your selection strategy as seen in the prompt above.

0 commit comments

Comments
 (0)