Skip to content

Experiment

Namespace AgentPrism · Assembly AgentPrism.Abstractions.dll

Represents an A/B experiment that splits traffic between two or more definition versions of the same agent.

public sealed record Experiment : IEquatable<Experiment>

objectExperiment

IEquatable<Experiment>

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

An experiment can only compare versions of the same agent. An experiment across different agents is out of scope because it complicates name resolution.

Code-based agents (AgentDefinitionOrigin.Code) cannot have an experiment because they have no version history. The endpoint states this clearly with HTTP 400.

public Experiment()

Gets the name of the agent whose traffic is split.

public required string AgentName { get; init; }

string

Gets a reserved value. Runtime assignment does not read it in this phase. The assignment key is always the session identifier, or the run identifier when no session exists. This property is reserved for future strategies that assign outside a session.

public string? AssignmentKey { get; init; }

string?

Gets the canary policy. null disables automatic decisions, so no background service evaluates this experiment.

public CanaryPolicy? Canary { get; init; }

CanaryPolicy?

Gets the time when the experiment stopped. Returns null when it runs or never started.

public DateTimeOffset? EndedAt { get; init; }

DateTimeOffset?

Gets the experiment identifier.

public required Guid Id { get; init; }

Guid

Gets the experiment name. It is unique within the tenant and is used as an API route key.

public required string Name { get; init; }

string

Gets the reason for an automatic rollback. Returns null when the experiment was stopped manually or was never stopped.

public string? RollbackReason { get; init; }

string?

Gets the time when the experiment entered ExperimentStatus.Running. Returns null while it is a draft.

public DateTimeOffset? StartedAt { get; init; }

DateTimeOffset?

Gets the current experiment status.

public ExperimentStatus Status { get; init; }

ExperimentStatus

Gets the tenant that owns the experiment.

public required string TenantId { get; init; }

string

Gets the UTC time of the last update.

public DateTimeOffset? UpdatedAt { get; init; }

DateTimeOffset?

Gets the experiment variants. Their weights must total 100.

public required IReadOnlyList<ExperimentVariant> Variants { get; init; }

IReadOnlyList<ExperimentVariant>

public override bool Equals(object? obj)

obj object?

bool

public bool Equals(Experiment? other)

other Experiment?

bool

public override int GetHashCode()

int

public override string ToString()

string

public static bool operator ==(Experiment? left, Experiment? right)

left Experiment?

right Experiment?

bool

public static bool operator !=(Experiment? left, Experiment? right)

left Experiment?

right Experiment?

bool