.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
github-merge-queue
Bot
removed this pull request from the merge queue due to failed status checks
Jun 5, 2026
github-merge-queue
Bot
removed this pull request from the merge queue due to failed status checks
Jun 5, 2026
github-actions Bot
added a commit
to microsoft/agent-framework-go
that referenced
this pull request
Jun 6, 2026
Port microsoft/agent-framework#6335: add heuristic auto-approval rules to ToolApprovalAgent. AutoApprovalFuncs in Config lets callers provide predicate functions that are evaluated after standing rules but before surfacing an approval request to the user. The first function returning true auto-approves the call without interrupting the caller. - Add AutoApprovalFuncs []func(*message.FunctionCallContent) bool to Config - Change New to capture cfg via closure instead of ignoring it - Change run to accept Config and thread it through to drainAutoApprovable - Add matchesAutoApprovalFuncs helper (first-match-wins semantics) - Apply auto-approval funcs in drainAutoApprovable (queued requests) and in the outbound classification loop (new requests from inner agent) - Add 5 tests covering: matching, non-matching, first-match-wins, queued request drain, and standing-rule precedence Co-authored-by: Copilot <223556219+Copilot@users.noreply.github.com>
qmuntal
added a commit
to microsoft/agent-framework-go
that referenced
this pull request
Jun 8, 2026
…iddleware (#254) * feat(toolapproval): add auto-approval funcs (heuristics) to Config Port microsoft/agent-framework#6335: add heuristic auto-approval rules to ToolApprovalAgent. AutoApprovalFuncs in Config lets callers provide predicate functions that are evaluated after standing rules but before surfacing an approval request to the user. The first function returning true auto-approves the call without interrupting the caller. - Add AutoApprovalFuncs []func(*message.FunctionCallContent) bool to Config - Change New to capture cfg via closure instead of ignoring it - Change run to accept Config and thread it through to drainAutoApprovable - Add matchesAutoApprovalFuncs helper (first-match-wins semantics) - Apply auto-approval funcs in drainAutoApprovable (queued requests) and in the outbound classification loop (new requests from inner agent) - Add 5 tests covering: matching, non-matching, first-match-wins, queued request drain, and standing-rule precedence Co-authored-by: Copilot <223556219+Copilot@users.noreply.github.com> * docs(toolapproval): clarify auto-approval callback expectations and naming parity note * refactor(toolapproval): rename auto approval rules and pass context * docs(toolapproval): align config comment terminology with AutoApprovalRules --------- Co-authored-by: github-actions[bot] <41898282+github-actions[bot]@users.noreply.github.com> Co-authored-by: Copilot <223556219+Copilot@users.noreply.github.com> Co-authored-by: copilot-swe-agent[bot] <198982749+Copilot@users.noreply.github.com>
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