# LoopCriterion

> 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.loopcriterion/
> Summary: LoopCriterion: One declarative stop criterion of the harness loop (see LoopSettings).

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

One declarative stop criterion of the harness loop (see `LoopSettings`).

```csharp
public sealed record LoopCriterion : IEquatable<LoopCriterion>
```

<dl class="api-relations"><dt>Inheritance</dt><dd><a href="https://learn.microsoft.com/dotnet/api/system.object">object</a> ← <a href="/api/tracon.loopcriterion/">LoopCriterion</a></dd><dt>Implements</dt><dd><a href="https://learn.microsoft.com/dotnet/api/system.iequatable-1">IEquatable&lt;LoopCriterion&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

A criterion carries **data only**, never code. That is the same
boundary tools and eval checks live behind: a definition can arrive from the
management API, and an interface-authored definition must never be able to
define behavior. A criterion whose logic is written in code is registered
with `ITraconBuilder.AddLoopEvaluator(kind, evaluator)` and is
referenced here by its registered `Kind` name alone.

Five kinds are built in. Each reads only the fields listed for it, and
ignores the rest:

<table><thead><tr><th class="term">Kind</th><th class="description">Fields it reads</th></tr></thead><tbody><tr><td class="term">`completionMarker`</td><td class="description">
    `Marker` (required). The loop stops once the agent's answer
    contains that text.
    </td></tr><tr><td class="term">`todoCompletion`</td><td class="description">
    `Modes` (optional). The loop stops once the agent's todo list
    has no open item left.
    </td></tr><tr><td class="term">`aiJudge`</td><td class="description">
    `JudgeCriteria` (required) and `JudgeInstructions`
    (optional). A judge model decides whether the work is finished.
    </td></tr><tr><td class="term">`backgroundTaskCompletion`</td><td class="description">
    None. The loop stops once no background task is still running.
    </td></tr><tr><td class="term">`agentReview`</td><td class="description">
    `ReviewerAgent` (required) and `ReviewerAgentVersion`
    (optional). Another agent of the catalog reads the draft and approves it
    or sends feedback back. It runs as a child run of the run being evaluated.
    </td></tr></tbody></table>

An unknown `Kind` is **rejected** when the agent is
built, with `TraconCompilationException`; it is never ignored.
A silently ignored stop criterion is a loop with no stop criterion.

## Constructors

### <a id="Tracon_LoopCriterion__ctor"></a> LoopCriterion\(\)

```csharp
public LoopCriterion()
```

## Properties

### <a id="Tracon_LoopCriterion_JudgeCriteria"></a> JudgeCriteria

Gets the criteria the judge model scores the answer against. Read by
`aiJudge` only, where at least one entry is required.

```csharp
public IReadOnlyList<string> JudgeCriteria { get; init; }
```

#### Property Value

 [IReadOnlyList](https://learn.microsoft.com/dotnet/api/system.collections.generic.ireadonlylist\-1)<[string](https://learn.microsoft.com/dotnet/api/system.string)\>

### <a id="Tracon_LoopCriterion_JudgeInstructions"></a> JudgeInstructions

Gets the extra instructions handed to the judge model. Read by
`aiJudge` only.

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

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

Gets the criterion kind: `completionMarker`, `todoCompletion`,
`aiJudge`, `backgroundTaskCompletion`, `agentReview`, or a kind
registered in code with `AddLoopEvaluator`.

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

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

Gets the completion marker text. Read by `completionMarker` only,
where it is required.

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

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

Gets the agent modes the criterion applies to. Read by
`todoCompletion` only.

```csharp
public IReadOnlyList<string> Modes { get; init; }
```

#### Property Value

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

Tracon does not configure the harness mode provider today, so a
definition has no mode names of its own to match. Leave this empty
unless the agent's own instructions establish the modes.

### <a id="Tracon_LoopCriterion_ReviewerAgent"></a> ReviewerAgent

Gets the name of the reviewer agent. Read by `agentReview` only, where it is required.

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

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

The reviewer is an agent of the catalog, resolved on every iteration. It answers with a
JSON object, `{"approved": true|false, "feedback": "..."}`; give the reviewer that
answer shape as its own response format.

### <a id="Tracon_LoopCriterion_ReviewerAgentVersion"></a> ReviewerAgentVersion

Gets the version of the reviewer agent. Read by `agentReview` only;
[null](https://learn.microsoft.com/dotnet/csharp/language-reference/keywords/null) runs the reviewer's current version.

```csharp
public int? ReviewerAgentVersion { get; init; }
```

#### Property Value

 [int](https://learn.microsoft.com/dotnet/api/system.int32)?

#### Remarks

The same meaning as `WorkflowNodeReference.AgentVersion`: a number of 1 or more. An agent
defined in code keeps no version history, so a version for one is refused.

## Methods

### <a id="Tracon_LoopCriterion_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_LoopCriterion_Equals_Tracon_LoopCriterion_"></a> Equals\(LoopCriterion?\)

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

`other` [LoopCriterion](/api/tracon.loopcriterion/)?

#### Returns

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

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

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

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

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

### <a id="Tracon_LoopCriterion_op_Equality_Tracon_LoopCriterion_Tracon_LoopCriterion_"></a> operator ==\(LoopCriterion?, LoopCriterion?\)

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

`left` [LoopCriterion](/api/tracon.loopcriterion/)?

`right` [LoopCriterion](/api/tracon.loopcriterion/)?

#### Returns

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

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

`left` [LoopCriterion](/api/tracon.loopcriterion/)?

`right` [LoopCriterion](/api/tracon.loopcriterion/)?

#### Returns

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