Skip to content
Tracon

ContentGuardContext

Namespace Tracon · Assembly Tracon.Abstractions.dll

The context of an IContentGuard call.

public sealed record ContentGuardContext : IEquatable<ContentGuardContext>

objectContentGuardContext

IEquatable<ContentGuardContext>

object.GetType(), object.ToString(), object.Equals(object?), object.Equals(object?, object?), object.ReferenceEquals(object?, object?), object.GetHashCode()

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”).

public ContentGuardContext()

The name of the agent executing the run. null if unknown.

public string? AgentName { get; init; }

string?

The direction of the check.

public required ContentGuardDirection Direction { get; init; }

ContentGuardDirection

The identifier of the model being called. null if unknown.

public string? ModelId { get; init; }

string?

The run identifier. null if called outside a run’s scope.

public Guid? RunId { get; init; }

Guid?

The source of the inspected text.

public ContentGuardSource Source { get; init; }

ContentGuardSource

Defaults to ContentGuardSource.Unknown — 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”.

The run’s tenant. null if unknown.

public string? TenantId { get; init; }

string?

The text to check.

public required string Text { get; init; }

string

The name of the tool whose result is being inspected. null when ContentGuardContext.Source is not ContentGuardSource.ToolResult.

public string? ToolName { get; init; }

string?

Can also be null while ContentGuardContext.Source is still ContentGuardSource.ToolResult: 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, never off this field’s presence.

public override bool Equals(object? obj)

obj object?

bool

public bool Equals(ContentGuardContext? other)

other ContentGuardContext?

bool

public override int GetHashCode()

int

public override string ToString()

string

operator ==(ContentGuardContext?, ContentGuardContext?)

Section titled “ operator ==(ContentGuardContext?, ContentGuardContext?)”
public static bool operator ==(ContentGuardContext? left, ContentGuardContext? right)

left ContentGuardContext?

right ContentGuardContext?

bool

operator !=(ContentGuardContext?, ContentGuardContext?)

Section titled “ operator !=(ContentGuardContext?, ContentGuardContext?)”
public static bool operator !=(ContentGuardContext? left, ContentGuardContext? right)

left ContentGuardContext?

right ContentGuardContext?

bool