BackgroundTaskCompletionLoopEvaluator 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.
A LoopEvaluator that keeps re-invoking the wrapped agent until a BackgroundAgentsProvider reports that no background tasks are still running.
public sealed class BackgroundTaskCompletionLoopEvaluator : Microsoft.Agents.AI.LoopEvaluator
type BackgroundTaskCompletionLoopEvaluator = class
inherit LoopEvaluator
Public NotInheritable Class BackgroundTaskCompletionLoopEvaluator
Inherits LoopEvaluator
- Inheritance
Remarks
The required BackgroundAgentsProvider is not supplied directly. It is resolved at evaluation time from the looped agent via GetService<TService>(Object). This works because an agent surfaces its registered AIContextProvider instances through GetService, so a single BackgroundAgentsProvider attached to the agent's session is discovered automatically.
Only tasks that are still running are treated as incomplete; completed, failed, and lost tasks are terminal and do not keep the loop going. While running tasks remain, the evaluator continues with feedback built from a template (see FeedbackMessageTemplate), with the running task list substituted for IncompleteTasksPlaceholder and the running task count substituted for IncompleteTaskCountPlaceholder. How that feedback is delivered to the agent (and whether the session is reset) is decided by the LoopAgent that consumes this evaluator.
Constructors
| Name | Description |
|---|---|
| BackgroundTaskCompletionLoopEvaluator(BackgroundTaskCompletionLoopEvaluatorOptions) |
Initializes a new instance of the BackgroundTaskCompletionLoopEvaluator class. |
Fields
| Name | Description |
|---|---|
| DefaultFeedbackMessageTemplate |
The default template used to build the feedback produced while background tasks are still running. |
| IncompleteTaskCountPlaceholder |
The placeholder token within DefaultFeedbackMessageTemplate (or a custom FeedbackMessageTemplate) that is replaced, on each evaluation, with the number of background tasks that are still running. |
| IncompleteTasksPlaceholder |
The placeholder token within DefaultFeedbackMessageTemplate (or a custom FeedbackMessageTemplate) that is replaced, on each evaluation, with a formatted list of the background tasks that are still running. |
Methods
| Name | Description |
|---|---|
| EvaluateAsync(LoopContext, CancellationToken) |
Evaluates the loop state after an iteration and decides whether to re-invoke the wrapped agent and what feedback to provide. |