Skip to content

.NET: Allow customizing the HarnessAgent shell tool name#6793

Closed
anneheartrecord wants to merge 1 commit into
microsoft:mainfrom
anneheartrecord:feat/harness-shell-tool-name
Closed

.NET: Allow customizing the HarnessAgent shell tool name#6793
anneheartrecord wants to merge 1 commit into
microsoft:mainfrom
anneheartrecord:feat/harness-shell-tool-name

Conversation

@anneheartrecord

Copy link
Copy Markdown
Contributor

Summary

HarnessAgent registers the shell tool with shellExecutor.AsAIFunction(), which always uses the default name run_shell. ShellExecutor.AsAIFunction(string name = "run_shell", ...) already supports a custom name, but HarnessAgent had no way to set it. This adds a ShellToolName option that flows through to AsAIFunction.

Closes #6789

Changes

  • HarnessAgentOptions.ShellToolName (string?, .NET-only, alongside the other shell options). When null (default), the executor's own default name is used and behavior is unchanged.
  • HarnessAgent passes ShellToolName to AsAIFunction when set; otherwise it keeps the parameterless call so the existing default is preserved exactly.

Test

  • ShellExecutor_CustomToolNameIsUsedAsync: sets ShellToolName and asserts the registered tool is exposed under that name (and not under run_shell). Verified red before the change (tool was still run_shell), green after.
  • Full Microsoft.Agents.AI.Harness.UnitTests suite passes (82 tests, net10.0).

HarnessAgent registered the shell tool via AsAIFunction() with the default
name run_shell, with no way to change it even though ShellExecutor.AsAIFunction
already accepts a name. Add HarnessAgentOptions.ShellToolName and pass it
through; null keeps the existing default unchanged.
Copilot AI review requested due to automatic review settings June 29, 2026 08:32
@moonbox3 moonbox3 added the .NET Usage: [Issues, PRs], Target: .Net label Jun 29, 2026
@github-actions github-actions Bot changed the title Allow customizing the HarnessAgent shell tool name .NET: Allow customizing the HarnessAgent shell tool name Jun 29, 2026

Copilot AI 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

Adds a .NET-only configuration knob to HarnessAgent so callers can override the shell tool function name registered via ShellExecutor.AsAIFunction, while preserving the existing default behavior when unset.

Changes:

  • Introduced HarnessAgentOptions.ShellToolName (string?) to optionally customize the model-visible shell tool name.
  • Updated HarnessAgent to pass the custom name through to ShellExecutor.AsAIFunction(name) only when set; otherwise it keeps the existing parameterless call.
  • Added a unit test verifying the shell tool is registered under the custom name (and not under run_shell).

Reviewed changes

Copilot reviewed 3 out of 3 changed files in this pull request and generated no comments.

File Description
dotnet/src/Microsoft.Agents.AI.Harness/HarnessAgentOptions.cs Adds ShellToolName option and documents null/default behavior.
dotnet/src/Microsoft.Agents.AI.Harness/HarnessAgent.cs Wires ShellToolName into shell tool registration while preserving the existing default path.
dotnet/tests/Microsoft.Agents.AI.Harness.UnitTests/HarnessAgentTests.cs Adds coverage ensuring the custom tool name is exposed and the default name is not.

@westey-m

westey-m commented Jul 2, 2026

Copy link
Copy Markdown
Contributor

Thanks for the contribution. This has been superseded by #6880 though, where we also added support for some additional settings in addition to name. So closing this PR.

@westey-m westey-m closed this Jul 2, 2026
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

.NET Usage: [Issues, PRs], Target: .Net

Projects

None yet

Development

Successfully merging this pull request may close these issues.

.NET: [Feature]: HarnessAgent should support custom ShellExecutor.AsAIFunction name

4 participants