Skip to content

.NET: Add a ModeProvider for managing agent modes#5247

Open
westey-m wants to merge 5 commits intomicrosoft:feature-harnessfrom
westey-m:harness-mode-provider
Open

.NET: Add a ModeProvider for managing agent modes#5247
westey-m wants to merge 5 commits intomicrosoft:feature-harnessfrom
westey-m:harness-mode-provider

Conversation

@westey-m
Copy link
Copy Markdown
Contributor

Motivation and Context

Description

  • Tracks agent mode, between planning and execution.
  • Allows both the caller and the agent to switch modes.

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.

Copilot AI review requested due to automatic review settings April 14, 2026 11:53
@moonbox3 moonbox3 added the .NET label Apr 14, 2026
@github-actions github-actions bot changed the title Add a ModeProvider for managing agent modes .NET: Add a ModeProvider for managing agent modes Apr 14, 2026
Copy link
Copy Markdown
Contributor

Copilot AI left a comment

Choose a reason for hiding this comment

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

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 AgentModeProvider with GetMode/SetMode helpers plus GetMode/SetMode function tools and mode-specific instructions.
  • Added AgentModeState stored in AgentSession.StateBag and 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.

AIFunctionFactory.Create(
(string mode) =>
{
if (mode != PlanMode && mode != ExecuteMode)
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.

nit: Does this need to be case-insensitive or we only support lowercase for the values?

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

Projects

None yet

Development

Successfully merging this pull request may close these issues.

5 participants