Skip to content

RegexTerminationCondition

NexusLabs.Needlr.AgentFramework.Workflows

RegexTerminationCondition Class

Terminates a workflow when an agent's response matches a specified regular expression pattern.

public sealed class RegexTerminationCondition : NexusLabs.Needlr.AgentFramework.IWorkflowTerminationCondition

Inheritance System.Object 🡒 RegexTerminationCondition

Implements NexusLabs.Needlr.AgentFramework.IWorkflowTerminationCondition

Remarks

Matching is performed against the full response text of each completed agent turn. To restrict the condition to a specific agent, provide the agent's name or executor ID via the agentId constructor parameter.

Constructors

RegexTerminationCondition(string) Constructor

Initializes a new instance that fires when \<em>any\</em> agent's response matches pattern (case-insensitive, single-line).

public RegexTerminationCondition(string pattern);

Parameters

pattern System.String

The regular expression pattern to match against response text.

RegexTerminationCondition(string, string) Constructor

Initializes a new instance that fires when a specific agent's response matches pattern.

public RegexTerminationCondition(string pattern, string? agentId);

Parameters

pattern System.String

The regular expression pattern to match against response text.

agentId System.String

The agent name or executor ID to restrict the match to, or null to match any agent.

RegexTerminationCondition(string, string, RegexOptions) Constructor

Initializes a new instance with full control over agent filtering and regex options.

public RegexTerminationCondition(string pattern, string? agentId, System.Text.RegularExpressions.RegexOptions options);

Parameters

pattern System.String

The regular expression pattern to match against response text.

agentId System.String

The agent name or executor ID to restrict the match to, or null to match any agent.

options System.Text.RegularExpressions.RegexOptions

Regex options applied when compiling and evaluating the pattern.

Methods

RegexTerminationCondition.ShouldTerminate(TerminationContext) Method

Determines whether the workflow should terminate after the given agent response.

public bool ShouldTerminate(NexusLabs.Needlr.AgentFramework.TerminationContext context);

Parameters

context NexusLabs.Needlr.AgentFramework.TerminationContext

Context for the completed agent turn.

Implements ShouldTerminate(TerminationContext)

Returns

System.Boolean
true to stop the workflow; false to continue.