< Summary

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

Feature is only available for sponsors

Upgrade to PRO version

Metrics

MethodBranch coverage Crap Score Cyclomatic complexity Line coverage
.ctor(...)0%620%
get_ConditionType()100%210%
get_CtorArgs()100%210%

File(s)

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

#LineLine coverage
 1namespace NexusLabs.Needlr.AgentFramework;
 2
 3/// <summary>
 4/// Declares a termination condition that is evaluated by Needlr's <c>RunAsync</c> execution
 5/// helpers after each completed agent turn (Layer 2). Unlike
 6/// <see cref="AgentTerminationConditionAttribute"/>, this works with all workflow types
 7/// (group chat, handoff, sequential).
 8/// </summary>
 9/// <remarks>
 10/// <para>
 11/// Apply to any agent class. Multiple conditions may be stacked; OR semantics apply (first
 12/// match stops the workflow). Conditions from all agents in the workflow are merged; a condition
 13/// fires only when the agent it is declared on produces the matching response.
 14/// </para>
 15/// <para>
 16/// The <c>conditionType</c> must implement <see cref="IWorkflowTerminationCondition"/>.
 17/// Constructor arguments are passed via <c>ctorArgs</c>.
 18/// </para>
 19/// <para>
 20/// For group chat workflows, prefer <see cref="AgentTerminationConditionAttribute"/> — it fires
 21/// before the next turn starts, which is a cleaner stop than Layer 2 (which fires after the
 22/// response is fully emitted).
 23/// </para>
 24/// <example>
 25/// <code>
 26/// // Stop a sequential pipeline early on extraction failure
 27/// [AgentSequenceMember("content-pipeline", Order = 1)]
 28/// [WorkflowRunTerminationCondition(typeof(KeywordTerminationCondition), "EXTRACTION_FAILED")]
 29/// public class ContentExtractorAgent { }
 30/// </code>
 31/// </example>
 32/// </remarks>
 33[AttributeUsage(AttributeTargets.Class, AllowMultiple = true, Inherited = false)]
 34public sealed class WorkflowRunTerminationConditionAttribute : Attribute
 35{
 36    /// <summary>
 37    /// Initializes a new instance of <see cref="WorkflowRunTerminationConditionAttribute"/>.
 38    /// </summary>
 39    /// <param name="conditionType">
 40    /// The type that implements <see cref="IWorkflowTerminationCondition"/>. An instance is
 41    /// created at workflow construction time via
 42    /// <see cref="Activator.CreateInstance(Type, object[])"/> with <paramref name="ctorArgs"/>.
 43    /// </param>
 44    /// <param name="ctorArgs">
 45    /// Arguments forwarded to the condition's constructor. May be empty if the condition has a
 46    /// parameterless constructor.
 47    /// </param>
 048    public WorkflowRunTerminationConditionAttribute(Type conditionType, params object[] ctorArgs)
 49    {
 050        ArgumentNullException.ThrowIfNull(conditionType);
 051        ConditionType = conditionType;
 052        CtorArgs = ctorArgs ?? [];
 053    }
 54
 55    /// <summary>Gets the type of the termination condition to instantiate.</summary>
 056    public Type ConditionType { get; }
 57
 58    /// <summary>Gets the constructor arguments forwarded when instantiating the condition.</summary>
 059    public object[] CtorArgs { get; }
 60}