# Experiment

> Tracon documentation. Tracon is a .NET package family that adds a control
> plane on Microsoft Agent Framework, published as NuGet packages that run
> inside your own ASP.NET Core application.
>
> Page: https://tracon.dev/api/tracon.experiment/
> Summary: Experiment: Represents an A/B experiment that splits traffic between two or more definition versions of the same agent.

<div class="api-provenance">Namespace Tracon · Assembly <code>Tracon.Abstractions.dll</code></div>

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

```csharp
public sealed record Experiment : IEquatable<Experiment>
```

<dl class="api-relations"><dt>Inheritance</dt><dd><a href="https://learn.microsoft.com/dotnet/api/system.object">object</a> ← <a href="/api/tracon.experiment/">Experiment</a></dd><dt>Implements</dt><dd><a href="https://learn.microsoft.com/dotnet/api/system.iequatable-1">IEquatable&lt;Experiment&gt;</a></dd><dt>Inherited Members</dt><dd><a href="https://learn.microsoft.com/dotnet/api/system.object.gettype">object.GetType()</a>, <a href="https://learn.microsoft.com/dotnet/api/system.object.tostring">object.ToString()</a>, <a href="https://learn.microsoft.com/dotnet/api/system.object.equals#system-object-equals(system-object)">object.Equals(object?)</a>, <a href="https://learn.microsoft.com/dotnet/api/system.object.equals#system-object-equals(system-object-system-object)">object.Equals(object?, object?)</a>, <a href="https://learn.microsoft.com/dotnet/api/system.object.referenceequals">object.ReferenceEquals(object?, object?)</a>, <a href="https://learn.microsoft.com/dotnet/api/system.object.gethashcode">object.GetHashCode()</a></dd></dl>

## Remarks

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](/api/tracon.agentdefinitionorigin/)) cannot have an
experiment because they have no version history. The endpoint
states this clearly with HTTP 400.

## Constructors

### <a id="Tracon_Experiment__ctor"></a> Experiment\(\)

```csharp
public Experiment()
```

## Properties

### <a id="Tracon_Experiment_AgentName"></a> AgentName

Gets the name of the agent whose traffic is split.

```csharp
public required string AgentName { get; init; }
```

#### Property Value

 [string](https://learn.microsoft.com/dotnet/api/system.string)

### <a id="Tracon_Experiment_AssignmentKey"></a> AssignmentKey

Gets a reserved value. Runtime assignment does **not read** it:
the assignment key is always the session identifier, or the run identifier
when no session exists. The property is reserved for future strategies that
assign outside a session, and setting it today changes nothing.

```csharp
public string? AssignmentKey { get; init; }
```

#### Property Value

 [string](https://learn.microsoft.com/dotnet/api/system.string)?

### <a id="Tracon_Experiment_Canary"></a> Canary

Gets the canary policy. [null](https://learn.microsoft.com/dotnet/csharp/language-reference/keywords/null) disables automatic decisions,
so no background service evaluates this experiment.

```csharp
public CanaryPolicy? Canary { get; init; }
```

#### Property Value

 [CanaryPolicy](/api/tracon.canarypolicy/)?

### <a id="Tracon_Experiment_EndedAt"></a> EndedAt

Gets the time when the experiment stopped. Returns [null](https://learn.microsoft.com/dotnet/csharp/language-reference/keywords/null) when
it runs or never started.

```csharp
public DateTimeOffset? EndedAt { get; init; }
```

#### Property Value

 [DateTimeOffset](https://learn.microsoft.com/dotnet/api/system.datetimeoffset)?

### <a id="Tracon_Experiment_Id"></a> Id

Gets the experiment identifier.

```csharp
public required Guid Id { get; init; }
```

#### Property Value

 [Guid](https://learn.microsoft.com/dotnet/api/system.guid)

### <a id="Tracon_Experiment_Name"></a> Name

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

```csharp
public required string Name { get; init; }
```

#### Property Value

 [string](https://learn.microsoft.com/dotnet/api/system.string)

### <a id="Tracon_Experiment_RollbackReason"></a> RollbackReason

Gets the reason for an automatic rollback. Returns [null](https://learn.microsoft.com/dotnet/csharp/language-reference/keywords/null)
when the experiment was stopped manually or was never stopped.

```csharp
public string? RollbackReason { get; init; }
```

#### Property Value

 [string](https://learn.microsoft.com/dotnet/api/system.string)?

### <a id="Tracon_Experiment_StartedAt"></a> StartedAt

Gets the time when the experiment entered [ExperimentStatus.Running](/api/tracon.experimentstatus/). Returns [null](https://learn.microsoft.com/dotnet/csharp/language-reference/keywords/null) while it is a
draft.

```csharp
public DateTimeOffset? StartedAt { get; init; }
```

#### Property Value

 [DateTimeOffset](https://learn.microsoft.com/dotnet/api/system.datetimeoffset)?

### <a id="Tracon_Experiment_Status"></a> Status

Gets the current experiment status.

```csharp
public ExperimentStatus Status { get; init; }
```

#### Property Value

 [ExperimentStatus](/api/tracon.experimentstatus/)

### <a id="Tracon_Experiment_TenantId"></a> TenantId

Gets the tenant that owns the experiment.

```csharp
public required string TenantId { get; init; }
```

#### Property Value

 [string](https://learn.microsoft.com/dotnet/api/system.string)

### <a id="Tracon_Experiment_UpdatedAt"></a> UpdatedAt

Gets the UTC time of the last update.

```csharp
public DateTimeOffset? UpdatedAt { get; init; }
```

#### Property Value

 [DateTimeOffset](https://learn.microsoft.com/dotnet/api/system.datetimeoffset)?

### <a id="Tracon_Experiment_Variants"></a> Variants

Gets the experiment variants. Their weights must total 100.

```csharp
public required IReadOnlyList<ExperimentVariant> Variants { get; init; }
```

#### Property Value

 [IReadOnlyList](https://learn.microsoft.com/dotnet/api/system.collections.generic.ireadonlylist\-1)<[ExperimentVariant](/api/tracon.experimentvariant/)\>

## Methods

### <a id="Tracon_Experiment_Equals_System_Object_"></a> Equals\(object?\)

```csharp
public override bool Equals(object? obj)
```

#### Parameters

`obj` [object](https://learn.microsoft.com/dotnet/api/system.object)?

#### Returns

 [bool](https://learn.microsoft.com/dotnet/api/system.boolean)

### <a id="Tracon_Experiment_Equals_Tracon_Experiment_"></a> Equals\(Experiment?\)

```csharp
public bool Equals(Experiment? other)
```

#### Parameters

`other` [Experiment](/api/tracon.experiment/)?

#### Returns

 [bool](https://learn.microsoft.com/dotnet/api/system.boolean)

### <a id="Tracon_Experiment_GetHashCode"></a> GetHashCode\(\)

```csharp
public override int GetHashCode()
```

#### Returns

 [int](https://learn.microsoft.com/dotnet/api/system.int32)

### <a id="Tracon_Experiment_ToString"></a> ToString\(\)

```csharp
public override string ToString()
```

#### Returns

 [string](https://learn.microsoft.com/dotnet/api/system.string)

## Operators

### <a id="Tracon_Experiment_op_Equality_Tracon_Experiment_Tracon_Experiment_"></a> operator ==\(Experiment?, Experiment?\)

```csharp
public static bool operator ==(Experiment? left, Experiment? right)
```

#### Parameters

`left` [Experiment](/api/tracon.experiment/)?

`right` [Experiment](/api/tracon.experiment/)?

#### Returns

 [bool](https://learn.microsoft.com/dotnet/api/system.boolean)

### <a id="Tracon_Experiment_op_Inequality_Tracon_Experiment_Tracon_Experiment_"></a> operator \!=\(Experiment?, Experiment?\)

```csharp
public static bool operator !=(Experiment? left, Experiment? right)
```

#### Parameters

`left` [Experiment](/api/tracon.experiment/)?

`right` [Experiment](/api/tracon.experiment/)?

#### Returns

 [bool](https://learn.microsoft.com/dotnet/api/system.boolean)
