# RunSpend

> 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.runspend/
> Summary: RunSpend: The one place a run's token cost and its reported (non-token) amount are added.

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

The one place a run's token cost and its reported (non-token) amount are added.

```csharp
public static class RunSpend
```

<dl class="api-relations"><dt>Inheritance</dt><dd><a href="https://learn.microsoft.com/dotnet/api/system.object">object</a> ← <a href="/api/tracon.runspend/">RunSpend</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.memberwiseclone">object.MemberwiseClone()</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 decision about money — a quota entry, a budget, a webhook amount — takes its
number from here, never from [RunCost.Total](/api/tracon.runcost/#Tracon_RunCost_Total) alone. A caller that
reads the token total only under-reports every run that reported a non-token
amount, and a tenant's quota ceiling can then be passed without anyone
noticing. The same rule as the cache charge in [RunCost.Total](/api/tracon.runcost/#Tracon_RunCost_Total):
one function answers, and the callers do not repeat the sum.

Amounts in two currencies are never added. When the currencies differ, the token
total stands alone and the reported amount is left out; a custom
[IRunPricingResolver](/api/tracon.irunpricingresolver/) is the only way to get there, since the built-in
one prices tokens and the reported amounts in `Tracon:Pricing:Currency`.

## Methods

### <a id="Tracon_RunSpend_Total_Tracon_RunCost_Tracon_RunNonTokenCost_"></a> Total\(RunCost?, RunNonTokenCost?\)

Adds a run's token cost and the amount it reported.

```csharp
public static decimal? Total(RunCost? cost, RunNonTokenCost? nonTokenCost)
```

#### Parameters

`cost` [RunCost](/api/tracon.runcost/)?

The run's token cost, or [null](https://learn.microsoft.com/dotnet/csharp/language-reference/keywords/null).

`nonTokenCost` [RunNonTokenCost](/api/tracon.runnontokencost/)?

The run's reported (non-token) cost, or [null](https://learn.microsoft.com/dotnet/csharp/language-reference/keywords/null).

#### Returns

 [decimal](https://learn.microsoft.com/dotnet/api/system.decimal)?

The sum, or [null](https://learn.microsoft.com/dotnet/csharp/language-reference/keywords/null) when neither side has an amount. Never zero for
a run nothing could be priced for.

### <a id="Tracon_RunSpend_Total_Tracon_RunTreeCost_Tracon_RunNonTokenCost_"></a> Total\(RunTreeCost?, RunNonTokenCost?\)

Adds a run tree's token cost and the amount the tree reported.

```csharp
public static decimal? Total(RunTreeCost? cost, RunNonTokenCost? nonTokenCost)
```

#### Parameters

`cost` [RunTreeCost](/api/tracon.runtreecost/)?

The tree's token cost, or [null](https://learn.microsoft.com/dotnet/csharp/language-reference/keywords/null).

`nonTokenCost` [RunNonTokenCost](/api/tracon.runnontokencost/)?

The tree's reported (non-token) cost, or [null](https://learn.microsoft.com/dotnet/csharp/language-reference/keywords/null).

#### Returns

 [decimal](https://learn.microsoft.com/dotnet/api/system.decimal)?

The sum, or [null](https://learn.microsoft.com/dotnet/csharp/language-reference/keywords/null) when neither side has an amount, or when the
tree's token cost is in more than one currency.

#### Remarks

Both arguments already include the root run's own share
([RunRecord.TreeCost](/api/tracon.runrecord/#Tracon_RunRecord_TreeCost), [RunRecord.TreeNonTokenCost](/api/tracon.runrecord/#Tracon_RunRecord_TreeNonTokenCost)).

A tree whose runs are priced in more than one currency
([RunTreeCost.CurrencyCount](/api/tracon.runtreecost/#Tracon_RunTreeCost_CurrencyCount)) has no total, and a partial one would
read as the whole bill. A reported amount in more than one currency is left out,
the same as a reported amount in another currency than the tokens.
