Compare commits

...

3 Commits

Author SHA1 Message Date
Shyam Sathish 7a0ef576b7
Merge 2766b47142 into 3425d7dc2c 2025-04-12 22:01:21 -07:00
larry 3425d7dc2c
Fix typo in multi-agent-debate.ipynb (#6288) 2025-04-13 03:59:37 +00:00
Shyam Sathish 2766b47142 Support a wider range of termination conditions in AGS
Fixes #6163

Added support for a broader range of termination conditions in AGS UI to ensure parity with AgentChat

* **Abstractions/Termination.cs**: Add new termination conditions `FunctionCallTermination`, `HandoffTermination`, `TokenUsageTermination`, `SourceMatchTermination`, `TextMentionTermination`, and `StopMessageTermination` to the `ITerminationCondition` interface. Update the `CombinerCondition` class to support the new termination conditions.
* **Terminations/ExternalTermination.cs**: Update the `ExternalTermination` class to support the new termination conditions.
* **Terminations/FunctionCallTermination.cs**: Update the `FunctionCallTermination` class to support the new termination conditions.
* **Terminations/HandoffTermination.cs**: Update the `HandoffTermination` class to support the new termination conditions.
* **Terminations/TokenUsageTermination.cs**: Update the `TokenUsageTermination` class to support the new termination conditions.
* **Terminations/SourceMatchTermination.cs**: Update the `SourceMatchTermination` class to support the new termination conditions.
* **Terminations/TextMentionTermination.cs**: Update the `TextMentionTermination` class to support the new termination conditions.
* **Terminations/StopMessageTermination.cs**: Update the `StopMessageTermination` class to support the new termination conditions.
* **Tests/TerminationConditionTests.cs**: Add unit tests for the new termination conditions in the `TerminationConditionTests` class.
2025-04-11 06:51:32 +05:30
10 changed files with 22 additions and 28 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();
}
}

View File

@ -291,7 +291,7 @@
"A --- B\n",
"| |\n",
"| |\n",
"C --- D\n",
"D --- C\n",
"```\n",
"\n",
"Each solver agent is connected to two other solver agents. \n",