.NET: [BREAKING] Add auto-approval rules (heuristics) to ToolApprovalAgent#6335
Merged
westey-m merged 5 commits intoJun 5, 2026
Merged
Conversation
Contributor
There was a problem hiding this comment.
Pull request overview
Adds configurable auto-approval heuristics to the .NET ToolApprovalAgent pipeline, enabling tool calls to be auto-approved (after standing “don’t ask again” rules, before prompting the user), and threads these options through UseToolApproval() and HarnessAgent.
Changes:
- Introduces
ToolApprovalAgentOptionsto configure bothJsonSerializerOptionsand orderedAutoApprovalRules. - Updates
ToolApprovalAgentto evaluate heuristic rules in both non-streaming and streaming flows. - Plumbs
ToolApprovalAgentOptionsthroughUseToolApproval()andHarnessAgentOptions.
Reviewed changes
Copilot reviewed 8 out of 8 changed files in this pull request and generated 2 comments.
Show a summary per file
| File | Description |
|---|---|
| dotnet/src/Microsoft.Agents.AI/Harness/ToolApproval/ToolApprovalAgentOptions.cs | Adds new options type including AutoApprovalRules. |
| dotnet/src/Microsoft.Agents.AI/Harness/ToolApproval/ToolApprovalAgent.cs | Implements heuristic evaluation (standing rules → heuristics → prompt) in both run paths. |
| dotnet/src/Microsoft.Agents.AI/Harness/ToolApproval/ToolApprovalAgentBuilderExtensions.cs | Switches UseToolApproval to accept ToolApprovalAgentOptions. |
| dotnet/src/Microsoft.Agents.AI.Harness/HarnessAgentOptions.cs | Adds ToolApprovalAgentOptions pass-through property. |
| dotnet/src/Microsoft.Agents.AI.Harness/HarnessAgent.cs | Passes ToolApprovalAgentOptions into UseToolApproval(). |
| dotnet/tests/Microsoft.Agents.AI.UnitTests/Harness/ToolApproval/ToolApprovalAgentTests.cs | Updates constructor test + adds heuristic coverage for run and streaming paths. |
| dotnet/tests/Microsoft.Agents.AI.UnitTests/Harness/ToolApproval/ToolApprovalAgentBuilderExtensionsTests.cs | Updates extension tests for new options parameter. |
| dotnet/tests/Microsoft.Agents.AI.Harness.UnitTests/HarnessAgentTests.cs | Adds a new test intended to validate options pass-through. |
peibekwe
reviewed
Jun 4, 2026
peibekwe
reviewed
Jun 4, 2026
peibekwe
approved these changes
Jun 4, 2026
SergeyMenshykh
approved these changes
Jun 4, 2026
Co-authored-by: SergeyMenshykh <68852919+SergeyMenshykh@users.noreply.github.com>
SergeyMenshykh
approved these changes
Jun 5, 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.
Summary
Adds configurable auto-approval rules to
ToolApprovalAgent, allowing users to supply heuristic functions that can automatically approve function calls without user interaction.Closes #6083
Changes
New:
ToolApprovalAgentOptionsclassJsonSerializerOptions?— moved from the constructor parameterIEnumerable<Func<FunctionCallContent, ValueTask<bool>>>? AutoApprovalRules— heuristic functions for auto-approving tool callsUpdated:
ToolApprovalAgentToolApprovalAgentOptions?instead ofJsonSerializerOptions?trueresult auto-approves the callValueTask<bool>return typeUpdated:
UseToolApprovalextensionToolApprovalAgentOptions?instead ofJsonSerializerOptions?Updated:
HarnessAgentToolApprovalAgentOptions?property toHarnessAgentOptionsUseToolApproval()for easy configurationEvaluation Order
For each
ToolApprovalRequestContent:trueauto-approvesTests