.NET API
ValidatingAIFunction
Tracon.Core.dllWraps an AI.AIFunction with an IToolArgumentsValidator
check that runs before every call.
public sealed class ValidatingAIFunction : DelegatingAIFunctionInheritance
Section titled “Inheritance”object ← AITool ← AIFunctionDeclaration ← AIFunction ← DelegatingAIFunction ← ValidatingAIFunction
Inherited Members
Section titled “Inherited Members”DelegatingAIFunction.ToString(), DelegatingAIFunction.GetService(Type, object?), DelegatingAIFunction.Name, DelegatingAIFunction.Description, DelegatingAIFunction.JsonSchema, DelegatingAIFunction.ReturnJsonSchema, DelegatingAIFunction.JsonSerializerOptions, DelegatingAIFunction.UnderlyingMethod, DelegatingAIFunction.AdditionalProperties, AIFunction.InvokeAsync(AIFunctionArguments?, CancellationToken), AIFunction.AsDeclarationOnly(), AIFunction.UnderlyingMethod, AIFunction.JsonSerializerOptions, AIFunctionDeclaration.JsonSchema, AIFunctionDeclaration.ReturnJsonSchema, AITool.ToString(), AITool.GetService(Type, object?), AITool.GetService<TService>(object?), AITool.Name, AITool.Description, AITool.AdditionalProperties, object.GetType(), object.ToString(), object.Equals(object?), object.Equals(object?, object?), object.ReferenceEquals(object?, object?), object.GetHashCode()
Remarks
Section titled “Remarks”Installed by ToolWrapperChain.Compose one layer inside the authorization wrapper and outside the timeout wrapper: a caller who cannot make the call at all is turned away before its arguments are even inspected, and a malformed call never consumes a timeout budget or waits on a human approval.
A rejection throws TraconException with
the validator’s reason as its message. This is the opposite choice from
AuthorizingAIFunction, which returns a denial as an ordinary
successful result: an authorization denial is a legitimate business
outcome, but rejected arguments are a malformed call, and Microsoft Agent
Framework’s own conversion of a thrown exception into a
FunctionResultContent is what makes the run record it as
ToolFailed instead of an ordinary result.
If IToolArgumentsValidator.ValidateAsync throws, the call is rejected (fail-closed) with a generic reason. A gate that fails open on an exception is not a gate.
Constructors
Section titled “Constructors”ValidatingAIFunction(AIFunction, ToolDescriptor, IToolArgumentsValidator, ILogger<ValidatingAIFunction>)
Section titled “ ValidatingAIFunction(AIFunction, ToolDescriptor, IToolArgumentsValidator, ILogger<ValidatingAIFunction>)”Creates a new argument validation wrapper.
public ValidatingAIFunction(AIFunction innerFunction, ToolDescriptor descriptor, IToolArgumentsValidator validator, ILogger<ValidatingAIFunction> logger)Parameters
Section titled “Parameters”innerFunction AIFunction
The tool to wrap.
descriptor ToolDescriptor
The tool’s descriptor, passed to the validator.
validator IToolArgumentsValidator
The validation policy.
logger ILogger<ValidatingAIFunction>
The logger for a faulting validator.
Methods
Section titled “Methods”InvokeCoreAsync(AIFunctionArguments, CancellationToken)
Section titled “ InvokeCoreAsync(AIFunctionArguments, CancellationToken)”Invokes the AI.AIFunction and returns its result.
protected override ValueTask<object?> InvokeCoreAsync(AIFunctionArguments arguments, CancellationToken cancellationToken)Parameters
Section titled “Parameters”arguments AIFunctionArguments
The arguments to pass to the function’s invocation.
cancellationToken CancellationToken
The CancellationToken to monitor for cancellation requests.
Returns
Section titled “Returns”The result of the function’s execution.