# RunTreeCost

> 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.runtreecost/
> Summary: RunTreeCost: Total cost of a run tree (the root plus every child run).

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

Total cost of a run tree (the root plus every child run).

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

This **must not be added** to [RunRecord.Cost](/api/tracon.runrecord/#Tracon_RunRecord_Cost): the
value already includes the root's own cost, for the same reason as
[RunRecord.TreeUsage](/api/tracon.runrecord/#Tracon_RunRecord_TreeUsage). The user interface shows the two in
separate columns.

## Constructors

### <a id="Tracon_RunTreeCost__ctor"></a> RunTreeCost\(\)

```csharp
public RunTreeCost()
```

## Properties

### <a id="Tracon_RunTreeCost_CachedInputCost"></a> CachedInputCost

Gets the total cached-input cost across the tree.

```csharp
public decimal? CachedInputCost { get; init; }
```

#### Property Value

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

This is a THIRD addend of the tree's total, not a subset of
[RunTreeCost.InputCost](/api/tracon.runtreecost/#Tracon_RunTreeCost_InputCost): every run's own [RunCost.InputCost](/api/tracon.runcost/#Tracon_RunCost_InputCost)
already has its cached tokens subtracted out. A total that adds only
input and output under-reports every tree that hit the prompt cache.

### <a id="Tracon_RunTreeCost_Currency"></a> Currency

Gets the currency.

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

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

[null](https://learn.microsoft.com/dotnet/csharp/language-reference/keywords/null) when the tree's runs are priced in more than one ([RunTreeCost.CurrencyCount](/api/tracon.runtreecost/#Tracon_RunTreeCost_CurrencyCount)).

### <a id="Tracon_RunTreeCost_CurrencyCount"></a> CurrencyCount

Gets how many currencies the tree's runs are priced in.

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

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

Amounts in two currencies are never added: a sum across currencies is not an
amount. Above one, [RunTreeCost.InputCost](/api/tracon.runtreecost/#Tracon_RunTreeCost_InputCost), [RunTreeCost.OutputCost](/api/tracon.runtreecost/#Tracon_RunTreeCost_OutputCost),
[RunTreeCost.CachedInputCost](/api/tracon.runtreecost/#Tracon_RunTreeCost_CachedInputCost) and [RunTreeCost.Currency](/api/tracon.runtreecost/#Tracon_RunTreeCost_Currency) are [null](https://learn.microsoft.com/dotnet/csharp/language-reference/keywords/null),
and so is [RunTreeCost.Total](/api/tracon.runtreecost/#Tracon_RunTreeCost_Total); the runs keep their own costs
([RunRecord.Cost](/api/tracon.runrecord/#Tracon_RunRecord_Cost)). Zero when no run in the tree carries a currency.

Currencies are compared without regard to letter case. The built-in pricing
prices every run in `Tracon:Pricing:Currency`, so more than one comes from
a custom [IRunPricingResolver](/api/tracon.irunpricingresolver/) or from a currency setting changed
while the tree was running.

### <a id="Tracon_RunTreeCost_InputCost"></a> InputCost

Gets the total input cost across the tree.

```csharp
public decimal? InputCost { get; init; }
```

#### Property Value

 [decimal](https://learn.microsoft.com/dotnet/api/system.decimal)?

### <a id="Tracon_RunTreeCost_OutputCost"></a> OutputCost

Gets the total output cost across the tree.

```csharp
public decimal? OutputCost { get; init; }
```

#### Property Value

 [decimal](https://learn.microsoft.com/dotnet/api/system.decimal)?

### <a id="Tracon_RunTreeCost_RunsWithUnknownPricing"></a> RunsWithUnknownPricing

Gets how many runs in the tree have an unknown price.

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

 [long](https://learn.microsoft.com/dotnet/api/system.int64)

## Methods

### <a id="Tracon_RunTreeCost_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_RunTreeCost_Equals_Tracon_RunTreeCost_"></a> Equals\(RunTreeCost?\)

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

`other` [RunTreeCost](/api/tracon.runtreecost/)?

#### Returns

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

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

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

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

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

Gets the tree's total cost — input, output and cache read together.

```csharp
public decimal? Total()
```

#### Returns

 [decimal](https://learn.microsoft.com/dotnet/api/system.decimal)?

[null](https://learn.microsoft.com/dotnet/csharp/language-reference/keywords/null) when no run in the tree was ever priced.

#### Remarks

Same rule as [RunCost.Total](/api/tracon.runcost/#Tracon_RunCost_Total): never add only two of the three.

## Operators

### <a id="Tracon_RunTreeCost_op_Equality_Tracon_RunTreeCost_Tracon_RunTreeCost_"></a> operator ==\(RunTreeCost?, RunTreeCost?\)

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

`left` [RunTreeCost](/api/tracon.runtreecost/)?

`right` [RunTreeCost](/api/tracon.runtreecost/)?

#### Returns

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

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

`left` [RunTreeCost](/api/tracon.runtreecost/)?

`right` [RunTreeCost](/api/tracon.runtreecost/)?

#### Returns

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