Skip to content

.NET: Make Todo, Mode and FileMemory providers more configurable - #5477

Merged
westey (westey-m) merged 4 commits into
microsoft:feature-harnessfrom
westey-m:harness-providers-params
Apr 27, 2026
Merged

.NET: Make Todo, Mode and FileMemory providers more configurable#5477
westey (westey-m) merged 4 commits into
microsoft:feature-harnessfrom
westey-m:harness-providers-params

Conversation

@westey-m

Copy link
Copy Markdown
Contributor

Motivation and Context

Users should be able to configure providers as far as possible for their own scenarios, including customizing instructions.

Description

  • Allow users to provide their own instructions for the Todo and FileMemory providers.
  • Change function tool names to start with consistent prefixes.
  • Improve the Mode provider to configure the set of modes and instructions. Also update it to inject a message after the user changes the mode, so that the LLM is notified that there was an update.

Contribution Checklist

  • The code builds clean without any errors or warnings
  • The PR follows the Contribution Guidelines
  • All unit tests pass, and I have added new tests where possible
  • Is this a breaking change? If yes, add "[BREAKING]" prefix to the title of the PR.

CopilotAI review requested due to automatic review settings April 24, 2026 16:20
@moonbox3Evan Mattson (moonbox3) added the .NET Usage: [Issues, PRs], Target: .Net label Apr 24, 2026
@github-actionsgithub-actionsBot changed the title Make Todo, Mode and FileMemory providers more configurable.NET: Make Todo, Mode and FileMemory providers more configurableApr 24, 2026

@github-actionsgithub-actionsBot left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Automated Code Review

Reviewers: 2 | Confidence: 94% | Result: All clear

Reviewed: Correctness, Design Approach


Automated review by westey-m's agents

CopilotAI left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Pull request overview

This PR makes the built-in Harness providers (Todo, FileMemory, AgentMode) more configurable by adding options for custom instructions, standardizing tool name prefixes, and enhancing AgentMode behavior to support configurable mode sets and external mode-change notifications.

Changes:

  • Added *ProviderOptions types to allow custom instructions for Todo and FileMemory providers.
  • Renamed Todo and AgentMode function tools to consistent prefixes (TodoList_*, AgentMode_*) and updated samples/tests accordingly.
  • Enhanced AgentModeProvider to accept configurable modes/default mode and to inject a notification message when the mode is changed externally.

Reviewed changes

Copilot reviewed 13 out of 13 changed files in this pull request and generated 5 comments.

Show a summary per file
FileDescription
dotnet/src/Microsoft.Agents.AI/Harness/Todo/TodoProvider.csAdds options-based instructions + renames todo tool names.
dotnet/src/Microsoft.Agents.AI/Harness/Todo/TodoProviderOptions.csNew options type for Todo provider instructions.
dotnet/src/Microsoft.Agents.AI/Harness/FileMemory/FileMemoryProvider.csAdds options-based instructions.
dotnet/src/Microsoft.Agents.AI/Harness/FileMemory/FileMemoryProviderOptions.csNew options type for FileMemory provider instructions.
dotnet/src/Microsoft.Agents.AI/Harness/AgentMode/AgentModeProvider.csAdds configurable modes + external change notification + renames tools.
dotnet/src/Microsoft.Agents.AI/Harness/AgentMode/AgentModeProviderOptions.csNew options type for modes/default/instructions configuration.
dotnet/src/Microsoft.Agents.AI/Harness/AgentMode/AgentModeState.csAdds notification state tracking + default mode string change.
dotnet/tests/.../TodoProviderTests.csUpdates tool names + adds options instruction tests.
dotnet/tests/.../FileMemoryProviderTests.csAdds options instruction tests.
dotnet/tests/.../AgentModeProviderTests.csUpdates tool names + adds options/mode list + notification tests.
dotnet/samples/.../Harness_Step01_Research/Program.csUpdates sample instructions to reference mode tools / behavior.
dotnet/samples/.../ToolCallFormatter.csUpdates tool name formatting mappings.
dotnet/samples/.../HarnessConsole.csUpdates mode coloring + mode command handling.
Comments suppressed due to low confidence (2)

dotnet/samples/02-agents/Harness/Harness_Shared_Console/HarnessConsole.cs:289

  • HandleModeCommand previously normalized "plan"/"execute" case-insensitively, but that logic was removed. As a result, /mode PLAN (or other casing) will now throw even for the default provider, which is a UX regression in the sample console. Consider restoring case-insensitive normalization for the built-in default modes (using string literals if you no longer expose constants).
 string newMode = parts[1];
try
{
modeProvider.SetMode(session, newMode);
System.Console.ForegroundColor = GetModeColor(newMode);
System.Console.WriteLine($"\n Switched to {newMode} mode.\n");

dotnet/src/Microsoft.Agents.AI/Harness/FileMemory/FileMemoryProvider.cs:86

  • This constructor signature change removes the previously published (fileStore, stateInitializer) overload and replaces it with a 3-parameter overload with an optional options parameter. That is a binary breaking change for already-compiled consumers. Consider reintroducing the original constructor overload and chaining to the new one so existing binaries keep working.
 /// <summary>
/// Initializes a new instance of the <see cref="FileMemoryProvider"/> class.
/// </summary>
/// <param name="fileStore">The file store implementation used for storage operations.</param>
/// <param name="stateInitializer">
/// An optional function that initializes the <see cref="FileMemoryState"/> for a new session.
/// Use this to customize the working folder (e.g., per-user or per-session subfolders).
/// When <see langword="null"/>, the default initializer creates state with an empty working folder.
/// </param>
/// <param name="options">Optional settings that control provider behavior. When <see langword="null"/>, defaults are used.</param>
/// <exception cref="ArgumentNullException">Thrown when <paramref name="fileStore"/> is <see langword="null"/>.</exception>
public FileMemoryProvider(AgentFileStore fileStore, Func<AgentSession?, FileMemoryState>? stateInitializer = null, FileMemoryProviderOptions? options = null)
{
Throw.IfNull(fileStore);
this._fileStore = fileStore;
this._instructions = options?.Instructions ?? DefaultInstructions;
this._sessionState = new ProviderSessionState<FileMemoryState>(
stateInitializer ?? (_ => new FileMemoryState()),
this.GetType().Name,
AgentJsonUtilities.DefaultOptions);
}

Comment threaddotnet/samples/02-agents/Harness/Harness_Step01_Research/Program.cs Outdated
Comment threaddotnet/src/Microsoft.Agents.AI/Harness/Todo/TodoProvider.cs
Comment threaddotnet/src/Microsoft.Agents.AI/Harness/AgentMode/AgentModeProvider.cs Outdated
Comment threaddotnet/src/Microsoft.Agents.AI/Harness/AgentMode/AgentModeProvider.cs Outdated
@westey-m
westey (westey-m) merged commit f747d8a into microsoft:feature-harnessApr 27, 2026
12 checks passed
pullBot pushed a commit to nagyist/ms-agent-framework that referenced this pull request May 1, 2026
* .NET: Add a TODO AIContextProvider (microsoft#5233)
* Add a TODO AIContextProvider
* Add unit tests
* Address PR comments
* Address PR comments
* Fix test after removing one tool
* .NET: Add a ModeProvider for managing agent modes (microsoft#5247)
* Add a ModeProvider for managing agent modes
* Fix typo
* Fix typo
* Fix typo
* Address PR comments
* .NET: Add sample to show how to build a harness (microsoft#5268)
* Add sample to show how to build a harness
* Improve sample
* Sample max output tokens and model
* Fix encoding
* Fix model name in readme
* Address PR comments
* .NET: Add context window size compaction strategy for harness (microsoft#5304)
* Add context window size compaction strategy for harness
* Apply suggestions from code review
Co-authored-by: Copilot <175728472+Copilot@users.noreply.github.com>
* Address PR comments
---------
Co-authored-by: Copilot <175728472+Copilot@users.noreply.github.com>
* .NET: Add a file memory provider (microsoft#5315)
* Add a file memory provider
* Address PR comments
* Fix review comments.
* Add additional unit tests
* Addressing PR comments.
* .NET: Harness: Improve prompts and add FileSystem store (microsoft#5365)
* Harness: Improve prompts and add FileSystem store
* Address PR comments
* .NET: Harness: Improve path validation (microsoft#5404)
* Harness: Improve path validation
* Address PR comments
* .NET: Add always approve helpers, improve sample and fix bug (microsoft#5451)
* Add always approve helpers, improve sample and fix bug
* Address PR comments
* .NET: Make Todo, Mode and FileMemory providers more configurable (microsoft#5477)
* Make Todo, Mode and FileMemory providers more configurable
* Address PR comments.
* .NET: Add subagents provider and sample (microsoft#5518)
* Add subagents provider and sample
* Addressing PR comments.
* .NET: Harness filememory index plus instructions consistency (microsoft#5540)
* Add FileMemoryProvider index and improve instruction consistency
* Address PR comments.
* Address PR comments
* Address PR comments.
* Apply suggestion from @rogerbarreto
Co-authored-by: Roger Barreto <19890735+rogerbarreto@users.noreply.github.com>
---------
Co-authored-by: Roger Barreto <19890735+rogerbarreto@users.noreply.github.com>
* .NET: Refactor harness console to be more extensible and easy to understand with better UX (microsoft#5573)
* Refactor harness console to be more extensible and easy to understand with better UX.
* Fix formatting issues.
* Allow multiple clarifications in one response
* Address PR comments
* .NET: Add FileAccessProvdider and concurrency fix for FileMemoryProvider (microsoft#5583)
* Add FileAccessProvdider and concurrency fix for FileMemoryProvider
* Address PR comments
---------
Co-authored-by: Copilot <175728472+Copilot@users.noreply.github.com>
Co-authored-by: Roger Barreto <19890735+rogerbarreto@users.noreply.github.com>
Sign up for freeto join this conversation on GitHub. Already have an account? Sign in to comment

Labels

.NETUsage: [Issues, PRs], Target: .Net

Projects

None yet

Development

Successfully merging this pull request may close these issues.

4 participants

@westey-m@SergeyMenshykh@moonbox3