Skip to content

Python: Align ModeProvider tool names and instructions#6071

Merged
westey-m merged 2 commits into
microsoft:mainfrom
westey-m:modeprovider-py-net-alignment
May 26, 2026
Merged

Python: Align ModeProvider tool names and instructions#6071
westey-m merged 2 commits into
microsoft:mainfrom
westey-m:modeprovider-py-net-alignment

Conversation

@westey-m
Copy link
Copy Markdown
Collaborator

Motivation and Context

It's important to have similar tool names so that when rendering names in the client, we don't need different code depending on the agent language.

Description

  • Align ModeProvider tool names and instructions

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 May 25, 2026 14:01
@github-actions github-actions Bot changed the title Align ModeProvider tool names and instructions .NET: Align ModeProvider tool names and instructions May 25, 2026
@github-actions github-actions Bot changed the title .NET: Align ModeProvider tool names and instructions Python: Align ModeProvider tool names and instructions May 25, 2026
@moonbox3
Copy link
Copy Markdown
Contributor

moonbox3 commented May 25, 2026

Python Test Coverage

Python Test Coverage Report •
FileStmtsMissCoverMissing
packages/core/agent_framework/_harness
   _mode.py102199%97
TOTAL36297430988% 

Python Unit Test Overview

Tests Skipped Failures Errors Time
7240 34 💤 0 ❌ 0 🔥 1m 52s ⏱️

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

Aligns AgentModeProvider tool naming and injected mode instructions across Python and .NET so clients can render mode tools consistently regardless of agent language.

Changes:

  • Renamed mode tools to mode_set / mode_get in both Python and .NET implementations (and updated corresponding tests).
  • Updated Python default mode instructions and available-mode rendering to match the .NET heading-based format.
  • Updated the .NET console sample formatter to recognize the new mode_set tool name (but needs an additional fix; see comment).

Reviewed changes

Copilot reviewed 5 out of 5 changed files in this pull request and generated 1 comment.

Show a summary per file
File Description
python/packages/core/tests/core/test_harness_mode.py Updates assertions for new tool names and revised instruction formatting.
python/packages/core/agent_framework/_harness/_mode.py Renames exposed tools to mode_set/mode_get and aligns default instructions + mode list formatting.
dotnet/tests/Microsoft.Agents.AI.UnitTests/Harness/AgentMode/AgentModeProviderTests.cs Updates unit tests to use the new tool names.
dotnet/src/Microsoft.Agents.AI/Harness/AgentMode/AgentModeProvider.cs Renames the generated tool names and updates docs/instructions references.
dotnet/samples/02-agents/Harness/Harness_Shared_Console/ToolFormatters/ModeToolFormatter.cs Switches formatting to mode_set (but CanFormat still uses legacy prefix).
Comments suppressed due to low confidence (1)

python/packages/core/agent_framework/_harness/_mode.py:318

  • This comment still refers to the agent's "set_mode" tool call, but the tool was renamed to "mode_set" in this PR. Update the wording to match the new tool name to avoid confusing future maintainers.
        context.extend_tools(self.source_id, [mode_set, mode_get])
        if isinstance(previous_mode, str) and previous_mode != current_mode:
            # Inject a user-role message announcing the external mode change. System instructions
            # always render first in the chat history, so the agent can otherwise stay anchored to
            # the most recent ``set_mode`` tool call rather than the new mode.

Copy link
Copy Markdown

@github-actions github-actions Bot left a comment

Choose a reason for hiding this comment

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

Automated Code Review

Reviewers: 4 | Confidence: 96%

✓ Correctness

This PR is a straightforward, consistent renaming of tool names from AgentMode_Set/AgentMode_Get (dotnet) and set_mode/get_mode (Python) to the aligned mode_set/mode_get in both. All functional code references (tool definitions, instruction strings, tests, and the sample formatter) are updated correctly. No logical correctness issues found.

✓ Security Reliability

The PR correctly renames mode tools for cross-language alignment and maintains input validation in both implementations. However, the ModeToolFormatter sample has an incomplete rename: the CanFormat method (line 13) still checks call.Name.StartsWith("AgentMode_", ...), which will never match the new mode_set/mode_get names—making the FormatDetail change on line 18 dead code and the formatter entirely non-functional.

✓ Test Coverage

The PR correctly renames tools and updates tests for both Python and .NET providers. However, ModeToolFormatter.cs has an incomplete rename: CanFormat still checks for the old "AgentMode_" prefix while FormatDetail was updated to "mode_set", making the formatter dead code. No test covers ModeToolFormatter, so this regression goes undetected. The core provider test coverage is adequate — both Python and .NET tests validate the new tool names and instruction content.

✓ Design Approach

I found one design-level gap in the rename: the .NET sample console formatter was only updated in its FormatDetail switch, but its CanFormat gate still recognizes the old AgentMode_ prefix. That means renamed mode_set/mode_get calls will no longer take the specialized formatting path in the sample client, which directly undercuts the PR’s stated goal of aligning names so clients can render them consistently.


Automated review by westey-m's agents

@westey-m westey-m added this pull request to the merge queue May 26, 2026
Merged via the queue into microsoft:main with commit bd4fc64 May 26, 2026
41 checks passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Projects

None yet

Development

Successfully merging this pull request may close these issues.

4 participants