Skip to content

WorkflowRunTerminationConditionAttribute

NexusLabs.Needlr.AgentFramework

NexusLabs.Needlr.AgentFramework

WorkflowRunTerminationConditionAttribute Class

Declares a termination condition that is evaluated by Needlr's RunAsync execution helpers after each completed agent turn (Layer 2). Unlike AgentTerminationConditionAttribute, this works with all workflow types (group chat, handoff, sequential).

public sealed class WorkflowRunTerminationConditionAttribute : System.Attribute

Inheritance System.Object 🡒 System.Attribute 🡒 WorkflowRunTerminationConditionAttribute

Remarks

Apply to any agent class. Multiple conditions may be stacked; OR semantics apply (first match stops the workflow). Conditions from all agents in the workflow are merged; a condition fires only when the agent it is declared on produces the matching response.

The conditionType must implement IWorkflowTerminationCondition. Constructor arguments are passed via ctorArgs.

For group chat workflows, prefer AgentTerminationConditionAttribute — it fires before the next turn starts, which is a cleaner stop than Layer 2 (which fires after the response is fully emitted).\<example> \<code> // Stop a sequential pipeline early on extraction failure [AgentSequenceMember("content-pipeline", Order = 1)] [WorkflowRunTerminationCondition(typeof(KeywordTerminationCondition), "EXTRACTION_FAILED")] public class ContentExtractorAgent { } \</code> \</example>

Constructors

WorkflowRunTerminationConditionAttribute(Type, object[]) Constructor

Initializes a new instance of WorkflowRunTerminationConditionAttribute.

public WorkflowRunTerminationConditionAttribute(System.Type conditionType, params object[] ctorArgs);

Parameters

conditionType System.Type

The type that implements IWorkflowTerminationCondition. An instance is created at workflow construction time via System.Activator.CreateInstance(System.Type,System.Object[]) with ctorArgs.

ctorArgs System.Object[]

Arguments forwarded to the condition's constructor. May be empty if the condition has a parameterless constructor.

Properties

WorkflowRunTerminationConditionAttribute.ConditionType Property

Gets the type of the termination condition to instantiate.

public System.Type ConditionType { get; }

Property Value

System.Type

WorkflowRunTerminationConditionAttribute.CtorArgs Property

Gets the constructor arguments forwarded when instantiating the condition.

public object[] CtorArgs { get; }

Property Value

System.Object[]