BackgroundAgentsProvider Class
Definition
Important
Some information relates to prerelease product that may be substantially modified before it’s released. Microsoft makes no warranties, express or implied, with respect to the information provided here.
An AIContextProvider that enables an agent to delegate work to background agents asynchronously.
public sealed class BackgroundAgentsProvider : Microsoft.Agents.AI.AIContextProvider
type BackgroundAgentsProvider = class
inherit AIContextProvider
Public NotInheritable Class BackgroundAgentsProvider
Inherits AIContextProvider
- Inheritance
Remarks
The BackgroundAgentsProvider allows a parent agent to start background tasks on child agents, wait for their completion, and retrieve results. Each background task runs in its own session and executes concurrently.
This provider exposes the following tools to the agent:
background_agents_start_task— Start a background task on a named agent with text input. Returns the task ID.background_agents_wait_for_first_completion— Block until the first of the specified tasks completes. Returns the completed task's ID.background_agents_get_task_results— Retrieve the text output of a completed background task.background_agents_get_all_tasks— List all background tasks with their IDs, statuses, descriptions, and agent names.background_agents_continue_task— Send follow-up input to a completed background task's session to resume work.background_agents_clear_completed_task— Remove a completed background task and release its session to free memory.
Constructors
| Name | Description |
|---|---|
| BackgroundAgentsProvider(IEnumerable<AIAgent>, BackgroundAgentsProviderOptions) |
Initializes a new instance of the BackgroundAgentsProvider class. |
Properties
| Name | Description |
|---|---|
| ProvideInputMessageFilter |
Gets the filter function to apply to input messages before providing context via ProvideAIContextAsync(AIContextProvider+InvokingContext, CancellationToken). (Inherited from AIContextProvider) |
| StateKeys |
Gets the set of keys used to store the provider state in the StateBag. |
| StoreInputRequestMessageFilter |
Gets the filter function to apply to request messages before storing context via StoreAIContextAsync(AIContextProvider+InvokedContext, CancellationToken). (Inherited from AIContextProvider) |
| StoreInputResponseMessageFilter |
Gets the filter function to apply to response messages before storing context via StoreAIContextAsync(AIContextProvider+InvokedContext, CancellationToken). (Inherited from AIContextProvider) |
Methods
| Name | Description |
|---|---|
| GetIncompleteTasks(AgentSession) |
Gets the background tasks for the specified session that have not yet completed (i.e., are still running). |
| GetService(Type, Object) |
Asks the AIContextProvider for an object of the specified type |
| GetService<TService>(Object) |
Asks the AIContextProvider for an object of type |
| InvokedAsync(AIContextProvider+InvokedContext, CancellationToken) |
Called at the end of the agent invocation to process the invocation results. (Inherited from AIContextProvider) |
| InvokedCoreAsync(AIContextProvider+InvokedContext, CancellationToken) |
Called at the end of the agent invocation to process the invocation results. (Inherited from AIContextProvider) |
| InvokingAsync(AIContextProvider+InvokingContext, CancellationToken) |
Called at the start of agent invocation to provide additional context. (Inherited from AIContextProvider) |
| InvokingCoreAsync(AIContextProvider+InvokingContext, CancellationToken) |
Called at the start of agent invocation to provide additional context. (Inherited from AIContextProvider) |
| ProvideAIContextAsync(AIContextProvider+InvokingContext, CancellationToken) |
When overridden in a derived class, provides additional AI context to be merged with the input context for the current invocation. (Inherited from AIContextProvider) |
| StoreAIContextAsync(AIContextProvider+InvokedContext, CancellationToken) |
When overridden in a derived class, processes invocation results at the end of the agent invocation. (Inherited from AIContextProvider) |