Overview
TheAutoGen.SemanticKernel package enables integration between AutoGen and Microsoft Semantic Kernel, allowing you to:
- Use Semantic Kernel agents in AutoGen workflows
- Access Semantic Kernel plugins from AutoGen agents
- Combine both frameworks’ strengths
- Leverage existing Semantic Kernel code
Installation
Basic Setup
1
Create a Semantic Kernel
2
Create a SemanticKernelAgent
3
Use the agent
SemanticKernelAgent
The main agent class for Semantic Kernel integration:Constructor Parameters
Kernel
required
Configured Semantic Kernel instance
string
required
Unique identifier for the agent
string
Instructions defining the agent’s behavior
Using Semantic Kernel Plugins
Leverage Semantic Kernel plugins in AutoGen:1
Create Semantic Kernel plugins
2
Add plugins to kernel
3
Create agent with plugins
Multi-Agent with Semantic Kernel
Combine Semantic Kernel and OpenAI agents:Azure OpenAI with Semantic Kernel
Use Azure OpenAI in Semantic Kernel:Using Kernel Functions with AutoGen Agents
Use Semantic Kernel functions with non-SK agents:Built-in Semantic Kernel Plugins
Use built-in SK plugins:Prompt Templates
Use Semantic Kernel prompt templates:- Overall assessment
- Potential bugs
- Improvement suggestions
- Best practices violated ”;
Custom Plugins
Create complex plugins:Message Connector
Register the message connector for AutoGen message support:Best Practices
When to Use Semantic Kernel
When to Use Semantic Kernel
Use
SemanticKernelAgent when:- You have existing Semantic Kernel code
- You need SK-specific plugins (Bing, etc.)
- You want SK’s memory capabilities
- You’re using SK prompt templates
- You need SK’s planning features
Plugin Design
Plugin Design
Error Handling
Error Handling
Performance
Performance
- Reuse
Kernelinstances - Cache plugin results when appropriate
- Use async operations for I/O
- Limit plugin complexity
- Monitor token usage
Semantic Kernel vs AutoGen Functions
Semantic Kernel Plugins
Advantages:
- Rich ecosystem of plugins
- Built-in memory and planning
- Prompt templates
- Enterprise features
- Complex orchestration
- Multi-step planning
- Memory requirements
- Existing SK code
AutoGen Functions
Advantages:
- Simpler, lighter weight
- Source generator for type safety
- Direct control
- Better for simple functions
- Simple function calling
- New projects
- Performance-critical code
- Minimal dependencies
Next Steps
Function Calling
Learn about AutoGen’s function calling
OpenAI Integration
Use OpenAI models with AutoGen
Group Chat
Create multi-agent workflows