Skip to content

CanaryPolicy

Namespace AgentPrism · Assembly AgentPrism.Abstractions.dll

Defines automatic rollback and gradual traffic-increase rules for an experiment canary variant.

public sealed record CanaryPolicy : IEquatable<CanaryPolicy>

objectCanaryPolicy

IEquatable<CanaryPolicy>

object.GetType(), object.ToString(), object.Equals(object?), object.Equals(object?, object?), object.ReferenceEquals(object?, object?), object.GetHashCode()

This policy can only be defined for two-variant experiments. CanaryPolicy.CanaryVariant is the canary and the one remaining variant is the control. With more than two variants, proportional control-weight redistribution could not guarantee session stability. This constraint keeps the canary range fixed at [0, canaryWeight) and makes the control range contiguous.

Comparison is relative. The canary rolls back when its error rate is CanaryPolicy.MaxErrorRateDelta higher than the control rate. An absolute threshold, such as “stop at a 5% error rate”, would unfairly stop a canary for an agent whose control is also unhealthy.

public CanaryPolicy()

Gets the canary variant name. It must exist in the experiment Variants list.

public required string CanaryVariant { get; init; }

string

Gets the maximum absolute error-rate difference from the control, from 0.0 through 1.0. The canary rolls back when its rate is higher. No error-rate check runs when this value is null.

public double? MaxErrorRateDelta { get; init; }

double?

Gets the minimum completed run count that both the canary and control variants must reach before a decision is made.

public int MinSampleSize { get; init; }

int

This is the same rule as OnlineEvaluationOptions.MinSampleSize. It has the same default of 20 and the same a threshold reacts to noise with a small sample. Gradual increases use the same value to advance to the next step; a second threshold property is not added.

Gets the minimum average canary score from 0 through 100. The canary rolls back below this threshold. No score check runs when this value is null.

public int? MinScore { get; init; }

int?

Gets the minimum time between steps.

public TimeSpan RampInterval { get; init; }

TimeSpan

Gets the canary-weight steps that increase over time, for example [5, 25, 50, 100]. An empty list disables gradual increases. The canary weight stays at the value set through SaveAsync and only rollback is evaluated.

public IReadOnlyList<int> RampSteps { get; init; }

IReadOnlyList<int>

public override bool Equals(object? obj)

obj object?

bool

public bool Equals(CanaryPolicy? other)

other CanaryPolicy?

bool

public override int GetHashCode()

int

public override string ToString()

string

operator ==(CanaryPolicy?, CanaryPolicy?)

Section titled “ operator ==(CanaryPolicy?, CanaryPolicy?)”
public static bool operator ==(CanaryPolicy? left, CanaryPolicy? right)

left CanaryPolicy?

right CanaryPolicy?

bool

operator !=(CanaryPolicy?, CanaryPolicy?)

Section titled “ operator !=(CanaryPolicy?, CanaryPolicy?)”
public static bool operator !=(CanaryPolicy? left, CanaryPolicy? right)

left CanaryPolicy?

right CanaryPolicy?

bool