Skip to content

Commit 3ceceec

Browse files
.Net: Fix AggregatorKernelAgentFactory naming (#13018)
### Motivation and Context <!-- Thank you for your contribution to the semantic-kernel repo! Please help reviewers and future users, providing the following information: 1. Why is this change required? 2. What problem does it solve? 3. What scenario does it contribute to? 4. If it fixes an open issue, please link to the issue here. --> ### Description <!-- Describe your changes, the overall approach, the underlying design. These notes will help understanding how your code works. Thanks! --> ### Contribution Checklist <!-- Before submitting this PR, please make sure: --> - [ ] The code builds clean without any errors or warnings - [ ] The PR follows the [SK Contribution Guidelines](https://github.com/microsoft/semantic-kernel/blob/main/CONTRIBUTING.md) and the [pre-submission formatting script](https://github.com/microsoft/semantic-kernel/blob/main/CONTRIBUTING.md#development-scripts) raises no violations - [ ] All unit tests pass, and I have added new tests where possible - [ ] I didn't break anyone 😄
1 parent 9568fe8 commit 3ceceec

File tree

3 files changed

+19
-19
lines changed

3 files changed

+19
-19
lines changed

dotnet/samples/GettingStartedWithAgents/Step10_MultiAgent_Declarative.cs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -106,7 +106,7 @@ public Step10_MultiAgent_Declarative(ITestOutputHelper output) : base(output)
106106
this._kernel = builder.Build();
107107

108108
this._kernelAgentFactory =
109-
new AggregatorKernelAgentFactory(
109+
new AggregatorAgentFactory(
110110
new ChatCompletionAgentFactory(),
111111
new OpenAIAssistantAgentFactory(),
112112
new AzureAIAgentFactory());

dotnet/src/Agents/Core/Definition/AggregatorKernelAgentFactory.cs renamed to dotnet/src/Agents/Abstractions/Definition/AggregatorAgentFactory.cs

Lines changed: 12 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -8,40 +8,40 @@
88
namespace Microsoft.SemanticKernel.Agents;
99

1010
/// <summary>
11-
/// Provides a <see cref="AgentFactory"/> which aggregates multiple kernel agent factories.
11+
/// Provides a <see cref="AgentFactory"/> which aggregates multiple agent factories.
1212
/// </summary>
1313
[Experimental("SKEXP0110")]
14-
public sealed class AggregatorKernelAgentFactory : AgentFactory
14+
public sealed class AggregatorAgentFactory : AgentFactory
1515
{
16-
private readonly AgentFactory[] _kernelAgentFactories;
16+
private readonly AgentFactory[] _agentFactories;
1717

1818
/// <summary>Initializes the instance.</summary>
19-
/// <param name="kernelAgentFactories">Ordered <see cref="AgentFactory"/> instances to aggregate.</param>
19+
/// <param name="agentFactories">Ordered <see cref="AgentFactory"/> instances to aggregate.</param>
2020
/// <remarks>
2121
/// Where multiple <see cref="AgentFactory"/> instances are provided, the first factory that supports the <see cref="AgentDefinition"/> will be used.
2222
/// </remarks>
23-
public AggregatorKernelAgentFactory(params AgentFactory[] kernelAgentFactories) : base(kernelAgentFactories.SelectMany(f => f.Types).ToArray())
23+
public AggregatorAgentFactory(params AgentFactory[] agentFactories) : base(agentFactories.SelectMany(f => f.Types).ToArray())
2424
{
25-
Verify.NotNullOrEmpty(kernelAgentFactories);
25+
Verify.NotNullOrEmpty(agentFactories);
2626

27-
foreach (AgentFactory kernelAgentFactory in kernelAgentFactories)
27+
foreach (AgentFactory agentFactory in agentFactories)
2828
{
29-
Verify.NotNull(kernelAgentFactory, nameof(kernelAgentFactories));
29+
Verify.NotNull(agentFactory, nameof(agentFactories));
3030
}
3131

32-
this._kernelAgentFactories = kernelAgentFactories;
32+
this._agentFactories = agentFactories;
3333
}
3434

3535
/// <inheritdoc/>
3636
public override async Task<Agent?> TryCreateAsync(Kernel kernel, AgentDefinition agentDefinition, AgentCreationOptions? agentCreationOptions = null, CancellationToken cancellationToken = default)
3737
{
3838
Verify.NotNull(agentDefinition);
3939

40-
foreach (var kernelAgentFactory in this._kernelAgentFactories)
40+
foreach (var agentFactory in this._agentFactories)
4141
{
42-
if (kernelAgentFactory.IsSupported(agentDefinition))
42+
if (agentFactory.IsSupported(agentDefinition))
4343
{
44-
var kernelAgent = await kernelAgentFactory.TryCreateAsync(kernel, agentDefinition, agentCreationOptions, cancellationToken).ConfigureAwait(false);
44+
var kernelAgent = await agentFactory.TryCreateAsync(kernel, agentDefinition, agentCreationOptions, cancellationToken).ConfigureAwait(false);
4545
if (kernelAgent is not null)
4646
{
4747
return kernelAgent;

dotnet/src/Agents/UnitTests/Core/Factory/AggregatorKernelAgentFactoryTests.cs renamed to dotnet/src/Agents/UnitTests/Core/Factory/AggregatorAgentFactoryTests.cs

Lines changed: 6 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -11,12 +11,12 @@
1111
namespace SemanticKernel.Agents.UnitTests.Core.Factory;
1212

1313
/// <summary>
14-
/// Tests for <see cref="AggregatorKernelAgentFactory"/>.
14+
/// Tests for <see cref="AggregatorAgentFactory"/>.
1515
/// </summary>
16-
public class AggregatorKernelAgentFactoryTests
16+
public class AggregatorAgentFactoryTests
1717
{
1818
/// <summary>
19-
/// Verifies that the <see cref="AggregatorKernelAgentFactory"/> can create different types of agents.
19+
/// Verifies that the <see cref="AggregatorAgentFactory"/> can create different types of agents.
2020
/// </summary>
2121
[Fact]
2222
public async Task ItCreatesKernelAgentsAsync()
@@ -25,7 +25,7 @@ public async Task ItCreatesKernelAgentsAsync()
2525
var agentDefinition1 = new AgentDefinition() { Type = "my-type-1", Name = "my-name-1", Description = "my-description-1", Instructions = "my-instructions-1" };
2626
var agentDefinition2 = new AgentDefinition() { Type = "my-type-2", Name = "my-name-2", Description = "my-description-2", Instructions = "my-instructions-2" };
2727
var kernel = new Kernel();
28-
var target = new AggregatorKernelAgentFactory(new MyAgentFactory1(), new MyAgentFactory2());
28+
var target = new AggregatorAgentFactory(new MyAgentFactory1(), new MyAgentFactory2());
2929

3030
// Act
3131
var result1 = await target.CreateAsync(kernel, agentDefinition1);
@@ -39,15 +39,15 @@ public async Task ItCreatesKernelAgentsAsync()
3939
}
4040

4141
/// <summary>
42-
/// Verifies that the <see cref="AggregatorKernelAgentFactory"/> throws <see cref="KernelException"/> for an unknown agent type.
42+
/// Verifies that the <see cref="AggregatorAgentFactory"/> throws <see cref="KernelException"/> for an unknown agent type.
4343
/// </summary>
4444
[Fact]
4545
public async Task ItReturnsNullForUnknownAgentTypeAsync()
4646
{
4747
// Arrange
4848
var agentDefinition = new AgentDefinition() { Type = "my-type-unknown", Name = "my-name-1", Description = "my-description-1", Instructions = "my-instructions-1" };
4949
var kernel = new Kernel();
50-
var target = new AggregatorKernelAgentFactory(new MyAgentFactory1(), new MyAgentFactory2());
50+
var target = new AggregatorAgentFactory(new MyAgentFactory1(), new MyAgentFactory2());
5151

5252
// Act & Assert
5353
await Assert.ThrowsAsync<NotSupportedException>(async () => await target.CreateAsync(kernel, agentDefinition));

0 commit comments

Comments
 (0)