Skip to content
Tracon

IStructuredResponseValidator

Namespace Tracon · Assembly Tracon.Abstractions.dll

Validates a run’s response against the agent’s requested AgentResponseFormat before the run closes.

public interface IStructuredResponseValidator

A structural constraint sent to the provider (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 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 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 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 does.

ValidateAsync(StructuredResponseValidationContext, CancellationToken)

Section titled “ ValidateAsync(StructuredResponseValidationContext, CancellationToken)”

Validates one run’s response.

ValueTask<StructuredResponseValidationResult> ValidateAsync(StructuredResponseValidationContext context, CancellationToken cancellationToken = default)

context StructuredResponseValidationContext

The response and the format it was asked to match.

cancellationToken CancellationToken

The cancellation token.

ValueTask<StructuredResponseValidationResult>

The validation outcome.