# RunCompletion

> 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.runcompletion/
> Summary: RunCompletion: Everything needed to close a run.

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

Everything needed to close a run.

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

## Constructors

### <a id="Tracon_RunCompletion__ctor"></a> RunCompletion\(\)

```csharp
public RunCompletion()
```

## Properties

### <a id="Tracon_RunCompletion_CompletedAt"></a> CompletedAt

Gets the completion time (UTC).

```csharp
public required DateTimeOffset CompletedAt { get; init; }
```

#### Property Value

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

Gets the computed cost. [null](https://learn.microsoft.com/dotnet/csharp/language-reference/keywords/null) when the model is unknown
(a code agent, for example); when the model is known the value is populated
even if the price is not (see [RunCost](/api/tracon.runcost/)).

```csharp
public RunCost? Cost { get; init; }
```

#### Property Value

 [RunCost](/api/tracon.runcost/)?

### <a id="Tracon_RunCompletion_Error"></a> Error

Gets the error information. Only populated for [RunStatus.Failed](/api/tracon.runstatus/).

```csharp
public RunError? Error { get; init; }
```

#### Property Value

 [RunError](/api/tracon.runerror/)?

### <a id="Tracon_RunCompletion_EventCount"></a> EventCount

Gets the total number of events written.

```csharp
public long EventCount { get; init; }
```

#### Property Value

 [long](https://learn.microsoft.com/dotnet/api/system.int64)

### <a id="Tracon_RunCompletion_ModelId"></a> ModelId

Gets the model that actually answered, overriding `runs.model_id`
when it differs from the value written at `RunStarted`.
[null](https://learn.microsoft.com/dotnet/csharp/language-reference/keywords/null) leaves the stored value unchanged.

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

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

The row is written once, at run start, from the agent's primary
[ModelBinding](/api/tracon.modelbinding/) — before it is known whether a
[ModelBinding.Fallbacks](/api/tracon.modelbinding/#Tracon_ModelBinding_Fallbacks) link will answer instead. This
field lets completion correct the record so
`IRunStore.GetStatisticsAsync`'s `ByModel` breakdown groups by
the model that really ran. [null](https://learn.microsoft.com/dotnet/csharp/language-reference/keywords/null) is the
overwhelmingly common case (no fallback happened) and is a deliberate
no-op, not an omission.

### <a id="Tracon_RunCompletion_ModelProvider"></a> ModelProvider

Gets the provider of the model that actually answered, overriding
`runs.model_provider` the same way `ModelId` overrides
`runs.model_id`. [null](https://learn.microsoft.com/dotnet/csharp/language-reference/keywords/null) leaves the stored value
unchanged — the overwhelmingly common case (no fallback happened).

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

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

Gets the non-token cost the run reported ([RunNonTokenCost](/api/tracon.runnontokencost/)), or
[null](https://learn.microsoft.com/dotnet/csharp/language-reference/keywords/null) when it reported none.

```csharp
public RunNonTokenCost? NonTokenCost { get; init; }
```

#### Property Value

 [RunNonTokenCost](/api/tracon.runnontokencost/)?

#### Remarks

Written with the rest of the completion and never again: an item reported after
the run closed is kept in the run's detail only.

### <a id="Tracon_RunCompletion_RunId"></a> RunId

Gets the run id.

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

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

Gets the final status.

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

 [RunStatus](/api/tracon.runstatus/)

### <a id="Tracon_RunCompletion_TenantId"></a> TenantId

Gets the EXPECTED tenant of the run being closed. Defence in depth; when [null](https://learn.microsoft.com/dotnet/csharp/language-reference/keywords/null) no tenant check is made.

```csharp
[JsonIgnore]
public string? TenantId { get; init; }
```

#### Property Value

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

For the reason, and why the ambient tenant is not used, see `RunEvent.TenantId`.

The field is WRITE-side only and is removed from the transport contract with
`Serialization.JsonIgnoreAttribute`.

### <a id="Tracon_RunCompletion_Usage"></a> Usage

Gets the token usage.

```csharp
public RunUsage? Usage { get; init; }
```

#### Property Value

 [RunUsage](/api/tracon.runusage/)?

## Methods

### <a id="Tracon_RunCompletion_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_RunCompletion_Equals_Tracon_RunCompletion_"></a> Equals\(RunCompletion?\)

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

`other` [RunCompletion](/api/tracon.runcompletion/)?

#### Returns

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

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

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

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

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

### <a id="Tracon_RunCompletion_op_Equality_Tracon_RunCompletion_Tracon_RunCompletion_"></a> operator ==\(RunCompletion?, RunCompletion?\)

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

`left` [RunCompletion](/api/tracon.runcompletion/)?

`right` [RunCompletion](/api/tracon.runcompletion/)?

#### Returns

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

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

`left` [RunCompletion](/api/tracon.runcompletion/)?

`right` [RunCompletion](/api/tracon.runcompletion/)?

#### Returns

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