< Summary

Information
Class: NexusLabs.Needlr.AgentFramework.AgentTerminationConditionAttribute
Assembly: NexusLabs.Needlr.AgentFramework
File(s): /home/runner/work/needlr/needlr/src/NexusLabs.Needlr.AgentFramework/AgentTerminationConditionAttribute.cs
Line coverage
100%
Covered lines: 7
Uncovered lines: 0
Coverable lines: 7
Total lines: 52
Line coverage: 100%
Branch coverage
50%
Covered branches: 1
Total branches: 2
Branch coverage: 50%
Method coverage

Feature is only available for sponsors

Upgrade to PRO version

Metrics

MethodBranch coverage Crap Score Cyclomatic complexity Line coverage
.ctor(...)50%22100%
get_ConditionType()100%11100%
get_CtorArgs()100%11100%

File(s)

/home/runner/work/needlr/needlr/src/NexusLabs.Needlr.AgentFramework/AgentTerminationConditionAttribute.cs

#LineLine coverage
 1namespace NexusLabs.Needlr.AgentFramework;
 2
 3/// <summary>
 4/// Declares a termination condition that is wired into the group chat manager for this agent
 5/// (Layer 1). The condition is evaluated inside MAF's group chat loop, before the next agent
 6/// turn starts, giving a clean early exit.
 7/// </summary>
 8/// <remarks>
 9/// <para>
 10/// Apply to a class also decorated with <see cref="AgentGroupChatMemberAttribute"/>. Multiple
 11/// conditions may be stacked; OR semantics apply (first match stops the workflow).
 12/// </para>
 13/// <para>
 14/// The <c>conditionType</c> must implement <see cref="IWorkflowTerminationCondition"/>.
 15/// Constructor arguments for the condition are passed via <c>ctorArgs</c>.
 16/// </para>
 17/// <example>
 18/// <code>
 19/// [AgentGroupChatMember("code-review")]
 20/// [AgentTerminationCondition(typeof(KeywordTerminationCondition), "APPROVED")]
 21/// public class ApprovalAgent { }
 22/// </code>
 23/// </example>
 24/// </remarks>
 25[AttributeUsage(AttributeTargets.Class, AllowMultiple = true, Inherited = false)]
 26public sealed class AgentTerminationConditionAttribute : Attribute
 27{
 28    /// <summary>
 29    /// Initializes a new instance of <see cref="AgentTerminationConditionAttribute"/>.
 30    /// </summary>
 31    /// <param name="conditionType">
 32    /// The type that implements <see cref="IWorkflowTerminationCondition"/>. An instance is
 33    /// created at workflow construction time via
 34    /// <see cref="Activator.CreateInstance(Type, object[])"/> with <paramref name="ctorArgs"/>.
 35    /// </param>
 36    /// <param name="ctorArgs">
 37    /// Arguments forwarded to the condition's constructor. May be empty if the condition has a
 38    /// parameterless constructor.
 39    /// </param>
 19640    public AgentTerminationConditionAttribute(Type conditionType, params object[] ctorArgs)
 41    {
 19642        ArgumentNullException.ThrowIfNull(conditionType);
 19643        ConditionType = conditionType;
 19644        CtorArgs = ctorArgs ?? [];
 19645    }
 46
 47    /// <summary>Gets the type of the termination condition to instantiate.</summary>
 148    public Type ConditionType { get; }
 49
 50    /// <summary>Gets the constructor arguments forwarded when instantiating the condition.</summary>
 151    public object[] CtorArgs { get; }
 52}