TodoProvider Class

Definition

An AIContextProvider that provides todo management tools and instructions to an agent for tracking work items during long-running complex tasks.

public sealed class TodoProvider : Microsoft.Agents.AI.AIContextProvider, IDisposable
type TodoProvider = class
    inherit AIContextProvider
    interface IDisposable
Public NotInheritable Class TodoProvider
Inherits AIContextProvider
Implements IDisposable
Inheritance
TodoProvider
Implements

Remarks

The TodoProvider enables agents to create, complete, remove, and query todo items as part of their planning and execution workflow. Todo state is stored in the session's AgentSessionStateBag and persists across agent invocations within the same session.

This provider exposes the following tools to the agent:

  • todos_add — Add one or more todo items, each with a title and optional description.
  • todos_complete — Mark one or more todo items as complete by their IDs and reasons.
  • todos_remove — Remove one or more todo items by their IDs.
  • todos_get_remaining — Retrieve only incomplete todo items.
  • todos_get_all — Retrieve all todo items (complete and incomplete).

All operations are thread-safe; concurrent reads and mutations on the same session are serialized using a per-session lock to prevent duplicate IDs, lost updates, or inconsistent reads.

Constructors

Name Description
TodoProvider(TodoProviderOptions)

Initializes a new instance of the TodoProvider 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
Dispose()

Performs application-defined tasks associated with freeing, releasing, or resetting unmanaged resources.

GetAllTodosAsync(AgentSession, CancellationToken)

Gets all todo items from the session state.

GetRemainingTodosAsync(AgentSession, CancellationToken)

Gets the remaining (incomplete) todo items from the session state.

GetService(Type, Object)

Asks the AIContextProvider for an object of the specified type serviceType.

(Inherited from AIContextProvider)
GetService<TService>(Object)

Asks the AIContextProvider for an object of type TService.

(Inherited from AIContextProvider)
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)

Applies to