This commit is contained in:
Shyam Sathish 2025-04-11 19:12:19 -07:00 committed by GitHub
commit 564e5c1dbc
No known key found for this signature in database
GPG Key ID: B5690EEEBB952194
9 changed files with 21 additions and 27 deletions

View File

@ -1,6 +1,3 @@
// Copyright (c) Microsoft Corporation. All rights reserved.
// Termination.cs
namespace Microsoft.AutoGen.AgentChat.Abstractions;
public static class TerminationConditionExtensions

View File

@ -1,6 +1,3 @@
// Copyright (c) Microsoft Corporation. All rights reserved.
// ExternalTermination.cs
using Microsoft.AutoGen.AgentChat.Abstractions;
namespace Microsoft.AutoGen.AgentChat.Terminations;

View File

@ -1,6 +1,3 @@
// Copyright (c) Microsoft Corporation. All rights reserved.
// FunctionCallTermination.cs
using Microsoft.AutoGen.AgentChat.Abstractions;
namespace Microsoft.AutoGen.AgentChat.Terminations;

View File

@ -1,6 +1,3 @@
// Copyright (c) Microsoft Corporation. All rights reserved.
// HandoffTermination.cs
using Microsoft.AutoGen.AgentChat.Abstractions;
namespace Microsoft.AutoGen.AgentChat.Terminations;

View File

@ -1,6 +1,3 @@
// Copyright (c) Microsoft Corporation. All rights reserved.
// SourceMatchTermination.cs
using Microsoft.AutoGen.AgentChat.Abstractions;
namespace Microsoft.AutoGen.AgentChat.Terminations;

View File

@ -1,6 +1,3 @@
// Copyright (c) Microsoft Corporation. All rights reserved.
// StopMessageTermination.cs
using Microsoft.AutoGen.AgentChat.Abstractions;
namespace Microsoft.AutoGen.AgentChat.Terminations;

View File

@ -1,6 +1,3 @@
// Copyright (c) Microsoft Corporation. All rights reserved.
// TextMentionTermination.cs
using Microsoft.AutoGen.AgentChat.Abstractions;
using Microsoft.Extensions.AI;

View File

@ -1,6 +1,3 @@
// Copyright (c) Microsoft Corporation. All rights reserved.
// TokenUsageTermination.cs
using Microsoft.AutoGen.AgentChat.Abstractions;
namespace Microsoft.AutoGen.AgentChat.Terminations;

View File

@ -1,6 +1,3 @@
// Copyright (c) Microsoft Corporation. All rights reserved.
// TerminationConditionTests.cs
using FluentAssertions;
using Microsoft.AutoGen.AgentChat.Abstractions;
using Microsoft.AutoGen.AgentChat.Terminations;
@ -473,4 +470,25 @@ public class TerminationConditionTests
termination.Reset();
termination.IsTerminated.Should().BeFalse();
}
[Fact]
public async Task Test_SourceMatchTermination()
{
SourceMatchTermination termination = new("user", "agent");
termination.IsTerminated.Should().BeFalse();
TextMessage userMessage = new() { Content = "Hello", Source = "user" };
TextMessage agentMessage = new() { Content = "World", Source = "agent" };
TextMessage otherMessage = new() { Content = "Hi", Source = "other" };
await termination.InvokeExpectingNullAsync([]);
await termination.InvokeExpectingStopAsync([userMessage]);
await termination.InvokeExpectingStopAsync([agentMessage]);
await termination.InvokeExpectingNullAsync([otherMessage]);
await termination.InvokeExpectingFailureAsync([], reset: false);
termination.Reset();
termination.IsTerminated.Should().BeFalse();
}
}