Method ProvideAIContextAsync
- Namespace
- Oscova.Agents.Providers
- Assembly
- Oscova.Agents.dll
ProvideAIContextAsync(InvokingContext, CancellationToken)
When overridden in a derived class, provides additional AI context to be merged with the input context for the current invocation.
protected override ValueTask<AIContext> ProvideAIContextAsync(AIContextProvider.InvokingContext context, CancellationToken cancellationToken = default)Parameters
contextAIContextProvider.InvokingContext-
Contains the request context including the caller provided messages that will be used by the agent for this invocation.
cancellationTokenCancellationToken-
The System.Threading.CancellationToken to monitor for cancellation requests. The default is System.Threading.CancellationToken.None.
Returns
- ValueTask<AIContext>
-
A task that represents the asynchronous operation. The task result contains an Microsoft.Agents.AI.AIContext with additional context to be merged with the input context.
Remarks
This method is called from Microsoft.Agents.AI.AIContextProvider.InvokingCoreAsync(Microsoft.Agents.AI.AIContextProvider.InvokingContext,System.Threading.CancellationToken). Note that Microsoft.Agents.AI.AIContextProvider.InvokingCoreAsync(Microsoft.Agents.AI.AIContextProvider.InvokingContext,System.Threading.CancellationToken) can be overridden to directly control context merging and source stamping, in which case it is up to the implementer to call this method as needed to retrieve the additional context.
In contrast with Microsoft.Agents.AI.AIContextProvider.InvokingCoreAsync(Microsoft.Agents.AI.AIContextProvider.InvokingContext,System.Threading.CancellationToken), this method only returns additional context to be merged with the input, while Microsoft.Agents.AI.AIContextProvider.InvokingCoreAsync(Microsoft.Agents.AI.AIContextProvider.InvokingContext,System.Threading.CancellationToken) is responsible for returning the full merged Microsoft.Agents.AI.AIContext for the invocation.
Security consideration: Any messages, tools, or instructions returned by this method will be merged into the AI request context. If data is retrieved from external or untrusted sources, implementers should validate and sanitize it to prevent indirect prompt injection attacks.