# IStructuredResponseValidator

> 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.istructuredresponsevalidator/
> Summary: IStructuredResponseValidator: Validates a run's response against the agent's requested AgentResponseFormat before the run closes.

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

Validates a run's response against the agent's requested
[AgentResponseFormat](/api/tracon.agentresponseformat/) before the run closes.

```csharp
public interface IStructuredResponseValidator
```

## Remarks

A structural constraint sent to the provider ([AgentResponseFormat](/api/tracon.agentresponseformat/))
does not guarantee the response that comes back: a model can still answer with
empty content, cut off mid-document, or a JSON value that does not match the
requested schema. Tracon checks well-formedness on its own (non-empty,
parses as JSON) before this validator ever runs; everything past that —
schema conformance, a domain rule such as an allowed `score` range — is
this validator's job.

The default implementation is a no-op (registered with
`TryAddSingleton`), so an installation that registers nothing keeps
today's behaviour exactly, and `TraconStructuredResponseOptions.Enabled`
stays [false](https://learn.microsoft.com/dotnet/csharp/language-reference/builtin-types/bool) by default on top of that. A consumer replaces
the registration to enforce its own rule; Tracon does not ship a built-in
JSON Schema validator — validation stays inside the consumer's own trust
boundary, the same position [IToolArgumentsValidator](/api/tracon.itoolargumentsvalidator/) documents.

If this validator throws, the response is **invalid**
(fail-closed). A gate that fails open on an exception is not a gate.

**Tenant mode:** [IStructuredResponseValidator.ValidateAsync](/api/tracon.istructuredresponsevalidator/#Tracon_IStructuredResponseValidator_ValidateAsync_Tracon_StructuredResponseValidationContext_System_Threading_CancellationToken_) carries no tenant
parameter — no delivery guarantee applies to the call it makes (it runs
synchronously, inline, once per run that reaches this check; it is never
queued or retried by Tracon itself). A multi-tenant implementation
reads the ambient tenant itself, the same way [IToolArgumentsValidator](/api/tracon.itoolargumentsvalidator/)
does.

## Methods

### <a id="Tracon_IStructuredResponseValidator_ValidateAsync_Tracon_StructuredResponseValidationContext_System_Threading_CancellationToken_"></a> ValidateAsync\(StructuredResponseValidationContext, CancellationToken\)

Validates one run's response.

```csharp
ValueTask<StructuredResponseValidationResult> ValidateAsync(StructuredResponseValidationContext context, CancellationToken cancellationToken = default)
```

#### Parameters

`context` [StructuredResponseValidationContext](/api/tracon.structuredresponsevalidationcontext/)

The response and the format it was asked to match.

`cancellationToken` [CancellationToken](https://learn.microsoft.com/dotnet/api/system.threading.cancellationtoken)

The cancellation token.

#### Returns

 [ValueTask](https://learn.microsoft.com/dotnet/api/system.threading.tasks.valuetask\-1)<[StructuredResponseValidationResult](/api/tracon.structuredresponsevalidationresult/)\>

The validation outcome.
