-
Notifications
You must be signed in to change notification settings - Fork 4.3k
Add adapters to allow SK agents to be exposed as AIAgent #13240
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
base: main
Are you sure you want to change the base?
Conversation
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Pull Request Overview
This PR adds adapters to allow Semantic Kernel (SK) agents to be exposed as AIAgent implementations from the Microsoft Agent Framework. The implementation provides a common interface conformance pattern that enables different agent types to work through the same AIAgent abstraction.
- Introduces
AIAgentAdapter
andAIAgentThreadAdapter
classes to bridge SK agents with the Microsoft Agent Framework - Adds extension methods for each agent type (OpenAI, Azure AI, Bedrock, etc.) to convert to AIAgent
- Creates comprehensive unit and integration tests to verify the adapter functionality
Reviewed Changes
Copilot reviewed 37 out of 37 changed files in this pull request and generated no comments.
Show a summary per file
File | Description |
---|---|
dotnet/src/Agents/Abstractions/AIAgent/AIAgentAdapter.cs |
Core adapter class that wraps SK agents and exposes them as AIAgent |
dotnet/src/Agents/Abstractions/AIAgent/AIAgentThreadAdapter.cs |
Thread adapter for bridging SK agent threads with AIAgent threads |
dotnet/src/Agents/Abstractions/AgentExtensions.cs |
Base extension method for converting any SK agent to AIAgent |
dotnet/src/Agents/*/Extensions.cs |
Agent-specific extension methods for each agent type |
Unit test files | Comprehensive test coverage for all adapter functionality |
Integration test files | End-to-end testing of adapter conformance |
Tip: Customize your code reviews with copilot-instructions.md. Create the file or learn how to get started.
/// <summary> | ||
/// Gets the underlying Semantic Kernel Agent Framework <see cref="Agent"/>. | ||
/// </summary> | ||
public Agent InnerAgent { get; } |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Not fully sure if we need to expose the Agent, we could just recommend the GetService<Agent>()
for this.
public Agent InnerAgent { get; } |
/// <summary> | ||
/// Gets the underlying Semantic Kernel Agent Framework <see cref="AgentThread"/>. | ||
/// </summary> | ||
public AgentThread InnerThread { get; } |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
The rationale here is a bit similar to where after the conversion we don't expose the converted type back as we assume the caller will have the reference already.
Line 18 in 3ac7861
private readonly IChatCompletionService _chatCompletionService; |
Point to the GetService
usage.
/// <summary> | |
/// Gets the underlying Semantic Kernel Agent Framework <see cref="AgentThread"/>. | |
/// </summary> | |
public AgentThread InnerThread { get; } |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
nit. (Internal)
For the name of this class I would do something in the same lines we did for the ChatCompletionService vs ChatClient.
i.e: SKAgentAIAgent
, see ChatCompletionServiceChatClient.cs
<RootNamespace>Microsoft.SemanticKernel.Agents</RootNamespace> | ||
<TargetFrameworks>net8.0;netstandard2.0</TargetFrameworks> | ||
<NoWarn>$(NoWarn)</NoWarn> | ||
<NoWarn>$(NoWarn);NU5104</NoWarn> |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
This can be a strong breaking change for .Net Framework based customers as pipelines relying on GA releases will break to update a preview
package.
We might need to rethink how bring this dependency...
<NoWarn>$(NoWarn);NU5104</NoWarn> | |
<NoWarn>$(NoWarn);</NoWarn> |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
This error only surfaces on the package directly referencing the preview package. Anyone who references M.SK.Agents.Abstractions will not have this error for transitive references.
If this was not the case, I would have had to suppress this error for the core agents package as well, since it is also GA, and is referencing MAAI.A as a transitive reference.
Motivation and Context
microsoft/agent-framework#1122
Description
Add adapters to allow SK agents to be exposed as AIAgent
Contribution Checklist