AgentModeProvider 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 tracks the agent's operating mode (e.g., "plan" or "execute") in the session state and provides tools for querying and switching modes.
public sealed class AgentModeProvider : Microsoft.Agents.AI.AIContextProvider
type AgentModeProvider = class
inherit AIContextProvider
Public NotInheritable Class AgentModeProvider
Inherits AIContextProvider
- Inheritance
Remarks
The AgentModeProvider enables agents to operate in distinct modes during long-running complex tasks. The current mode is persisted in the session's AgentSessionStateBag and is included in the instructions provided to the agent on each invocation.
The set of available modes is configurable via Modes. By default, two modes are provided: "plan" (interactive planning) and "execute" (autonomous execution).
This provider exposes the following tools to the agent:
mode_set— Switch the agent's operating mode.mode_get— Retrieve the agent's current operating mode.
Public helper methods GetMode(AgentSession) and SetMode(AgentSession, String) allow external code to programmatically read and change the mode.
Constructors
| Name | Description |
|---|---|
| AgentModeProvider(AgentModeProviderOptions) |
Initializes a new instance of the AgentModeProvider 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 |
|---|---|
| GetMode(AgentSession) |
Gets the current operating mode from the session state. |
| 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) |
| SetMode(AgentSession, String) |
Sets the operating mode in the session state. |
| StoreAIContextAsync(AIContextProvider+InvokedContext, CancellationToken) |
When overridden in a derived class, processes invocation results at the end of the agent invocation. (Inherited from AIContextProvider) |