Skip to content

KeywordTerminationCondition

NexusLabs.Needlr.AgentFramework.Workflows

KeywordTerminationCondition Class

Terminates a workflow when an agent's response contains a specified keyword.

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

Inheritance System.Object 🡒 KeywordTerminationCondition

Implements NexusLabs.Needlr.AgentFramework.IWorkflowTerminationCondition

Remarks

The check is a simple substring match (case-insensitive by default). To restrict the condition to a specific agent, provide the agent's name or executor ID via the agentId constructor parameter.

Constructors

KeywordTerminationCondition(string) Constructor

Initializes a new instance that fires when \<em>any\</em> agent's response contains keyword (case-insensitive).

public KeywordTerminationCondition(string keyword);

Parameters

keyword System.String

The keyword to look for in the response text.

KeywordTerminationCondition(string, string) Constructor

Initializes a new instance that fires when a specific agent's response contains keyword.

public KeywordTerminationCondition(string keyword, string? agentId);

Parameters

keyword System.String

The keyword to look for in the response text.

agentId System.String

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

KeywordTerminationCondition(string, string, StringComparison) Constructor

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

public KeywordTerminationCondition(string keyword, string? agentId, System.StringComparison comparison);

Parameters

keyword System.String

The keyword to look for in the response text.

agentId System.String

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

comparison System.StringComparison

The string comparison used when searching for the keyword.

Methods

KeywordTerminationCondition.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.