TimeoutAIFunction
AgentPrism.Core.dllWraps an AI.AIFunction so a call that does not settle within a
fixed duration ends in AgentPrismToolTimeoutException instead
of running unbounded.
public sealed class TimeoutAIFunction : DelegatingAIFunctionInheritance
Section titled “Inheritance”object ← AITool ← AIFunctionDeclaration ← AIFunction ← DelegatingAIFunction ← TimeoutAIFunction
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 the tool registry, one layer inside the
authorization wrapper and outside the approval wrapper —
This
ordering matters: ApprovalRequiredAIFunction never blocks on the
human decision inside a single call (Microsoft Agent Framework returns a
pending request immediately and the decision resumes as a new run,
), so wrapping it with a timeout only ever bounds the tool’s own
execution, never an approval wait.
CancellationToken is cooperative. A tool body that never reads its token is not forcibly stopped: this class races the call against a delay and, on timeout, returns control to the caller while the call keeps running in the background until it finishes or faults on its own. This is a documented limit, not a bug.
Constructors
Section titled “Constructors”TimeoutAIFunction(AIFunction, TimeSpan, ILogger<TimeoutAIFunction>)
Section titled “ TimeoutAIFunction(AIFunction, TimeSpan, ILogger<TimeoutAIFunction>)”Creates a new timeout wrapper.
public TimeoutAIFunction(AIFunction innerFunction, TimeSpan timeout, ILogger<TimeoutAIFunction> logger)Parameters
Section titled “Parameters”innerFunction AIFunction
The tool to wrap.
timeout TimeSpan
The longest duration one call may run.
logger ILogger<TimeoutAIFunction>
The logger for a call that outlives its timeout.
Exceptions
Section titled “Exceptions”timeout is zero or negative.
Methods
Section titled “Methods”InvokeCoreAsync(AIFunctionArguments, CancellationToken)
Section titled “ InvokeCoreAsync(AIFunctionArguments, CancellationToken)”protected override ValueTask<object?> InvokeCoreAsync(AIFunctionArguments arguments, CancellationToken cancellationToken)Parameters
Section titled “Parameters”arguments AIFunctionArguments
cancellationToken CancellationToken