diff --git a/dotnet/src/Agents/Abstractions/AggregatorAgent.cs b/dotnet/src/Agents/Abstractions/AggregatorAgent.cs index 1255db7061bb..eb1f7d0fac98 100644 --- a/dotnet/src/Agents/Abstractions/AggregatorAgent.cs +++ b/dotnet/src/Agents/Abstractions/AggregatorAgent.cs @@ -45,7 +45,7 @@ public sealed class AggregatorAgent(Func chatProvider) : Agent protected internal override IEnumerable GetChannelKeys() { yield return typeof(AggregatorChannel).FullName!; - yield return this.GetHashCode().ToString(); + yield return this.Name ?? this.Id; } /// diff --git a/dotnet/src/Agents/UnitTests/AgentChatSerializerTests.cs b/dotnet/src/Agents/UnitTests/AgentChatSerializerTests.cs index 07774bd96705..ba607d260689 100644 --- a/dotnet/src/Agents/UnitTests/AgentChatSerializerTests.cs +++ b/dotnet/src/Agents/UnitTests/AgentChatSerializerTests.cs @@ -174,7 +174,7 @@ public async Task VerifyDeserializedChatWithAgentsAsync() public async Task VerifyDeserializedChatWithAggregatorAsync() { // Create chat - TestChat chat = new(new AggregatorAgent(() => new TestChat(CreateMockAgent()))); + TestChat chat = new(new AggregatorAgent(() => new TestChat(CreateMockAgent())) { Name = "Group" }); chat.AddChatMessage(new ChatMessageContent(AuthorRole.User, "test")); ChatMessageContent[] messages = await chat.InvokeAsync().ToArrayAsync(); @@ -182,7 +182,7 @@ public async Task VerifyDeserializedChatWithAggregatorAsync() AgentChatSerializer serializer = await this.CreateSerializerAsync(chat); Assert.Single(serializer.Participants); - TestChat copy = new(new AggregatorAgent(() => new TestChat(CreateMockAgent()))); + TestChat copy = new(new AggregatorAgent(() => new TestChat(CreateMockAgent())) { Name = "Group" }); await serializer.DeserializeAsync(copy);