StageExecutionPolicy
NexusLabs.Needlr.AgentFramework.Workflows¶
NexusLabs.Needlr.AgentFramework.Workflows.Sequential¶
StageExecutionPolicy Class¶
Configures runtime behavior for a single pipeline stage, including conditional skipping, post-execution validation with retries, and per-stage token budgets.
public sealed record StageExecutionPolicy : System.IEquatable<NexusLabs.Needlr.AgentFramework.Workflows.Sequential.StageExecutionPolicy>
Inheritance System.Object 🡒 StageExecutionPolicy
Implements System.IEquatable<StageExecutionPolicy>
Example¶
var policy = new StageExecutionPolicy
{
ShouldSkip = ctx => ctx.StageIndex > 3,
PostValidation = result => result.ResponseText?.Contains("error") == true
? "Response contained an error"
: null,
MaxAttempts = 3,
TokenBudget = 5000,
};
Properties¶
StageExecutionPolicy.AfterExecution Property¶
Called after stage execution (success or failure, not skip). Receives the execution result and context for workspace checks or state updates.
public System.Func<NexusLabs.Needlr.AgentFramework.Workflows.Sequential.StageExecutionResult,NexusLabs.Needlr.AgentFramework.Workflows.Sequential.StageExecutionContext,System.Threading.Tasks.Task>? AfterExecution { get; init; }
Property Value¶
System.Func<StageExecutionResult,StageExecutionContext,System.Threading.Tasks.Task>
StageExecutionPolicy.MaxAttempts Property¶
Maximum execution attempts for post-validation retries. Default is 1 (no retry).
Property Value¶
StageExecutionPolicy.PostValidation Property¶
Called after stage execution. Returns null on success, or an error message that triggers a retry (up to MaxAttempts).
public System.Func<NexusLabs.Needlr.AgentFramework.Workflows.Sequential.StageExecutionResult,string?>? PostValidation { get; init; }
Property Value¶
System.Func<StageExecutionResult,System.String>
StageExecutionPolicy.ShouldSkip Property¶
Evaluated at runtime. When true, the stage is skipped entirely.
public System.Func<NexusLabs.Needlr.AgentFramework.Workflows.Sequential.StageExecutionContext,bool>? ShouldSkip { get; init; }
Property Value¶
System.Func<StageExecutionContext,System.Boolean>
StageExecutionPolicy.TokenBudget Property¶
Optional per-stage token budget. When set, the runner scopes a child budget tracker for this stage.