.NET: Add a ModeProvider for managing agent modes#5247
Open
westey-m wants to merge 5 commits intomicrosoft:feature-harnessfrom
Open
.NET: Add a ModeProvider for managing agent modes#5247westey-m wants to merge 5 commits intomicrosoft:feature-harnessfrom
westey-m wants to merge 5 commits intomicrosoft:feature-harnessfrom
Conversation
Contributor
There was a problem hiding this comment.
Pull request overview
Introduces a new harness AIContextProvider for tracking an agent “mode” (planning vs execution) in per-session state, exposing tools and helpers to read/change that mode.
Changes:
- Added
AgentModeProviderwithGetMode/SetModehelpers plusGetMode/SetModefunction tools and mode-specific instructions. - Added
AgentModeStatestored inAgentSession.StateBagand registered it for source-generated JSON serialization. - Added unit tests covering default mode, tool behavior, helper behavior, and state persistence.
Reviewed changes
Copilot reviewed 4 out of 4 changed files in this pull request and generated 4 comments.
| File | Description |
|---|---|
| dotnet/src/Microsoft.Agents.AI/Harness/AgentMode/AgentModeProvider.cs | Adds the provider implementation, instructions, and mode tools backed by session state. |
| dotnet/src/Microsoft.Agents.AI/Harness/AgentMode/AgentModeState.cs | Adds the persisted session state model for current mode. |
| dotnet/src/Microsoft.Agents.AI/AgentJsonUtilities.cs | Registers AgentModeState for JSON source generation. |
| dotnet/tests/Microsoft.Agents.AI.UnitTests/Harness/AgentMode/AgentModeProviderTests.cs | Adds unit tests validating provider/tool/helper behavior and persistence. |
dotnet/tests/Microsoft.Agents.AI.UnitTests/Harness/AgentMode/AgentModeProviderTests.cs
Show resolved
Hide resolved
SergeyMenshykh
approved these changes
Apr 14, 2026
peibekwe
reviewed
Apr 14, 2026
| AIFunctionFactory.Create( | ||
| (string mode) => | ||
| { | ||
| if (mode != PlanMode && mode != ExecuteMode) |
Contributor
There was a problem hiding this comment.
nit: Does this need to be case-insensitive or we only support lowercase for the values?
peibekwe
approved these changes
Apr 14, 2026
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Motivation and Context
Description
Contribution Checklist