# ContentGuardContext

> 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.contentguardcontext/
> Summary: ContentGuardContext: The context of an IContentGuard call.

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

The context of an [IContentGuard](/api/tracon.icontentguard/) call.

```csharp
public sealed record ContentGuardContext : IEquatable<ContentGuardContext>
```

<dl class="api-relations"><dt>Inheritance</dt><dd><a href="https://learn.microsoft.com/dotnet/api/system.object">object</a> ← <a href="/api/tracon.contentguardcontext/">ContentGuardContext</a></dd><dt>Implements</dt><dd><a href="https://learn.microsoft.com/dotnet/api/system.iequatable-1">IEquatable&lt;ContentGuardContext&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 context carries **a single piece of text**, not a message
list. If messages were concatenated into one text, a false pattern could
match at the boundary between two messages (example: if one message ends
with `4539` and the next starts with `5787…`, an invalid card
number would "be found").

## Constructors

### <a id="Tracon_ContentGuardContext__ctor"></a> ContentGuardContext\(\)

```csharp
public ContentGuardContext()
```

## Properties

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

The name of the agent executing the run. [null](https://learn.microsoft.com/dotnet/csharp/language-reference/keywords/null) if unknown.

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

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

The direction of the check.

```csharp
public required ContentGuardDirection Direction { get; init; }
```

#### Property Value

 [ContentGuardDirection](/api/tracon.contentguarddirection/)

### <a id="Tracon_ContentGuardContext_ModelId"></a> ModelId

The identifier of the model being called. [null](https://learn.microsoft.com/dotnet/csharp/language-reference/keywords/null) if unknown.

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

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

The run identifier. [null](https://learn.microsoft.com/dotnet/csharp/language-reference/keywords/null) if called outside a run's scope.

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

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

The source of the inspected text.

```csharp
public ContentGuardSource Source { get; init; }
```

#### Property Value

 [ContentGuardSource](/api/tracon.contentguardsource/)

#### Remarks

Defaults to [ContentGuardSource.Unknown](/api/tracon.contentguardsource/) — code built before
this field existed leaves it at that value, and that is deliberate: a
guard must treat an unclassified source as at least as sensitive as a
tool result, never as an implicit "allow".

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

The run's tenant. [null](https://learn.microsoft.com/dotnet/csharp/language-reference/keywords/null) if unknown.

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

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

The text to check.

```csharp
public required string Text { get; init; }
```

#### Property Value

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

The name of the tool whose result is being inspected. [null](https://learn.microsoft.com/dotnet/csharp/language-reference/keywords/null)
when [ContentGuardContext.Source](/api/tracon.contentguardcontext/#Tracon_ContentGuardContext_Source) is not [ContentGuardSource.ToolResult](/api/tracon.contentguardsource/).

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

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

Can also be [null](https://learn.microsoft.com/dotnet/csharp/language-reference/keywords/null) **while [ContentGuardContext.Source](/api/tracon.contentguardcontext/#Tracon_ContentGuardContext_Source) is
still [ContentGuardSource.ToolResult](/api/tracon.contentguardsource/)**: resolving the
name requires the matching `FunctionCallContent` to still be present
earlier in the same message list, and a many-turn conversation can have
dropped it. A security decision must key off [ContentGuardContext.Source](/api/tracon.contentguardcontext/#Tracon_ContentGuardContext_Source), never
off this field's presence.

## Methods

### <a id="Tracon_ContentGuardContext_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_ContentGuardContext_Equals_Tracon_ContentGuardContext_"></a> Equals\(ContentGuardContext?\)

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

`other` [ContentGuardContext](/api/tracon.contentguardcontext/)?

#### Returns

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

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

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

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

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

### <a id="Tracon_ContentGuardContext_op_Equality_Tracon_ContentGuardContext_Tracon_ContentGuardContext_"></a> operator ==\(ContentGuardContext?, ContentGuardContext?\)

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

`left` [ContentGuardContext](/api/tracon.contentguardcontext/)?

`right` [ContentGuardContext](/api/tracon.contentguardcontext/)?

#### Returns

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

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

`left` [ContentGuardContext](/api/tracon.contentguardcontext/)?

`right` [ContentGuardContext](/api/tracon.contentguardcontext/)?

#### Returns

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