# AgentRunScope

> 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.agentrunscope/
> Summary: AgentRunScope: Represents the view of a running run that is exposed to the helper components in the run path.

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

Represents the view of a running run that is exposed to the helper
components in the run path.

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

The scope is opened by [RunRecordingAgent](/api/tracon.runrecordingagent/). A sub-agent
invocation builds its own [TraconRunOptions](/api/tracon.traconrunoptions/) object from
the values it reads here; this is how tree linkage, depth, and budget are
carried through the call chain.

## Constructors

### <a id="Tracon_AgentRunScope__ctor"></a> AgentRunScope\(\)

```csharp
public AgentRunScope()
```

## Properties

### <a id="Tracon_AgentRunScope_AgentName"></a> AgentName

Gets the name of the agent running this run.

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

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

Gets the definition version this run measures. [null](https://learn.microsoft.com/dotnet/csharp/language-reference/keywords/null) if unknown.

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

 [int](https://learn.microsoft.com/dotnet/api/system.int32)?

### <a id="Tracon_AgentRunScope_Budget"></a> Budget

Gets the budget shared across the tree.

```csharp
public AgentRunBudget? Budget { get; init; }
```

#### Property Value

 [AgentRunBudget](/api/tracon.agentrunbudget/)?

### <a id="Tracon_AgentRunScope_Depth"></a> Depth

Gets the depth in the tree. The root run is 0.

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

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

Gets the identity of the experiment this run belongs to. [null](https://learn.microsoft.com/dotnet/csharp/language-reference/keywords/null)
for a run outside an experiment.

```csharp
public Guid? ExperimentId { get; init; }
```

#### Property Value

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

Gets the labels of this run, or [null](https://learn.microsoft.com/dotnet/csharp/language-reference/keywords/null) when there are none.

```csharp
public IReadOnlyDictionary<string, string>? Labels { get; init; }
```

#### Property Value

 [IReadOnlyDictionary](https://learn.microsoft.com/dotnet/api/system.collections.generic.ireadonlydictionary\-2)<[string](https://learn.microsoft.com/dotnet/api/system.string), [string](https://learn.microsoft.com/dotnet/api/system.string)\>?

#### Remarks

The same value [IRunAttributionContext](/api/tracon.irunattributioncontext/) resolved for the run
record ([RunRecord.Labels](/api/tracon.runrecord/#Tracon_RunRecord_Labels)).

### <a id="Tracon_AgentRunScope_RootRunId"></a> RootRunId

Gets the identity of the run at the root of the tree. Equal to [AgentRunScope.RunId](/api/tracon.agentrunscope/#Tracon_AgentRunScope_RunId) at the root.

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

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

Gets the identity of the running run.

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

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

Gets the session the run belongs to. [null](https://learn.microsoft.com/dotnet/csharp/language-reference/keywords/null) for a sessionless run.

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

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

Content that a tool produces and writes to the `attachments`
table MUST CARRY this field. The retention policy treats an
attachment with an empty `session_id` field as **orphaned**
and deletes it after the cutoff date; the content in the transcript is
then lost while the session is still alive. A tool cannot access
`AgentSession`, so this is the only place it can read the session
identity from.

### <a id="Tracon_AgentRunScope_TenantId"></a> TenantId

Gets the tenant of the run. A sub-run cannot leave this tenant.

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

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

Gets the user this run belongs to, or [null](https://learn.microsoft.com/dotnet/csharp/language-reference/keywords/null) when unknown.

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

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

The same value [IRunAttributionContext](/api/tracon.irunattributioncontext/) resolved for the run
record ([RunRecord.UserId](/api/tracon.runrecord/#Tracon_RunRecord_UserId)) — this is not a new concept, only
a new place to read it from. A tool reads it from
[TraconRunContext.Current](/api/tracon.traconruncontext/#Tracon_TraconRunContext_Current) to learn who is calling it,
since a tool cannot depend on HTTP request state directly.

### <a id="Tracon_AgentRunScope_Variant"></a> Variant

Gets the name of the experiment arm this run is assigned to. [null](https://learn.microsoft.com/dotnet/csharp/language-reference/keywords/null) for a run outside an experiment.

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

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

Gets the event writer for this run. A sub-run writes its summary events here.

```csharp
public RunEventWriter? Writer { get; init; }
```

#### Property Value

 [RunEventWriter](/api/tracon.runeventwriter/)?

#### Remarks

The sequence number is produced by **a single writer**.
If a sub-call set up its own writer, the same run
would end up with two independent counters and the sequence numbers
would collide.

## Methods

### <a id="Tracon_AgentRunScope_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_AgentRunScope_Equals_Tracon_AgentRunScope_"></a> Equals\(AgentRunScope?\)

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

`other` [AgentRunScope](/api/tracon.agentrunscope/)?

#### Returns

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

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

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

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

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

### <a id="Tracon_AgentRunScope_op_Equality_Tracon_AgentRunScope_Tracon_AgentRunScope_"></a> operator ==\(AgentRunScope?, AgentRunScope?\)

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

`left` [AgentRunScope](/api/tracon.agentrunscope/)?

`right` [AgentRunScope](/api/tracon.agentrunscope/)?

#### Returns

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

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

`left` [AgentRunScope](/api/tracon.agentrunscope/)?

`right` [AgentRunScope](/api/tracon.agentrunscope/)?

#### Returns

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