# TraconRunContext

> 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.traconruncontext/
> Summary: TraconRunContext: Carries the identity, tree position, and budget of the running run to the helper components inside the run path.

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

Carries the identity, tree position, and budget of the running run to the
helper components inside the run path.

```csharp
public static class TraconRunContext
```

<dl class="api-relations"><dt>Inheritance</dt><dd><a href="https://learn.microsoft.com/dotnet/api/system.object">object</a> ← <a href="/api/tracon.traconruncontext/">TraconRunContext</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

It has two consumers. Skill script execution is triggered from inside MAF,
*below* the recording wrapper; sub-agent invocation is triggered
from MAF's background task tool. Neither has a way to pass the run
identity as a parameter: the call chain belongs to MAF.

The value is held in an `Threading.AsyncLocal`. This means the
assignment **does not flow back to the caller**: the
`Set` call must happen in the *own body* of the method that
starts the run. The same trap happened with
`Activity.Current`.

The value **flows downward**: because Microsoft Agent
Framework's background agent task captures `ExecutionContext`, a
sub-agent running on a different thread also sees the same scope.

## Properties

### <a id="Tracon_TraconRunContext_Current"></a> Current

Gets the scope of the running run. [null](https://learn.microsoft.com/dotnet/csharp/language-reference/keywords/null) outside a run.

```csharp
public static AgentRunScope? Current { get; }
```

#### Property Value

 [AgentRunScope](/api/tracon.agentrunscope/)?

### <a id="Tracon_TraconRunContext_CurrentRunId"></a> CurrentRunId

Gets the identity of the running run. [null](https://learn.microsoft.com/dotnet/csharp/language-reference/keywords/null) outside a run.

```csharp
public static Guid? CurrentRunId { get; }
```

#### Property Value

 [Guid](https://learn.microsoft.com/dotnet/api/system.guid)?

## Methods

### <a id="Tracon_TraconRunContext_SetCurrent_Tracon_AgentRunScope_"></a> SetCurrent\(AgentRunScope?\)

Sets the scope of the running run.

```csharp
public static void SetCurrent(AgentRunScope? scope)
```

#### Parameters

`scope` [AgentRunScope](/api/tracon.agentrunscope/)?

The scope. If [null](https://learn.microsoft.com/dotnet/csharp/language-reference/keywords/null), the scope is cleared.
