.NET: [BREAKING] Graduate ToolApprovalAgent and add ToolAutoApprovalRuleContext#7107
Open
westey-m wants to merge 2 commits into
Open
.NET: [BREAKING] Graduate ToolApprovalAgent and add ToolAutoApprovalRuleContext#7107westey-m wants to merge 2 commits into
westey-m wants to merge 2 commits into
Conversation
Contributor
There was a problem hiding this comment.
Pull request overview
Graduates the .NET ToolApprovalAgent surface from experimental to GA and introduces a new ToolAutoApprovalRuleContext so tool auto-approval rules can evolve without further breaking delegate signature changes.
Changes:
- Removes
[Experimental]from tool-approval public surface types and cleans up now-unused usings. - Introduces
ToolAutoApprovalRuleContextand updates auto-approval rules fromFunc<FunctionCallContent, ValueTask<bool>>toFunc<ToolAutoApprovalRuleContext, ValueTask<bool>>. - Threads run context (session, request messages, run options) through
ToolApprovalAgentso rules can access it; updates tests/samples accordingly.
Reviewed changes
Copilot reviewed 15 out of 15 changed files in this pull request and generated 2 comments.
Show a summary per file
| File | Description |
|---|---|
| dotnet/tests/Microsoft.Agents.AI.UnitTests/Harness/ToolApproval/ToolApprovalAgentTests.cs | Updates tests for new auto-approval rule delegate signature. |
| dotnet/tests/Microsoft.Agents.AI.UnitTests/Harness/FileAccess/FileAccessProviderTests.cs | Updates file-access auto-approval rule tests to use the new context parameter. |
| dotnet/tests/Microsoft.Agents.AI.UnitTests/AgentSkills/AgentSkillsProviderTests.cs | Updates skills-provider auto-approval rule tests to use the new context parameter. |
| dotnet/tests/Microsoft.Agents.AI.Harness.UnitTests/HarnessAgentTests.cs | Updates harness agent test to use context.FunctionCallContent in auto-approval rules. |
| dotnet/src/Microsoft.Agents.AI/Skills/AgentSkillsProvider.cs | Updates built-in skills auto-approval rules to accept ToolAutoApprovalRuleContext. |
| dotnet/src/Microsoft.Agents.AI/Harness/ToolApproval/ToolAutoApprovalRuleContext.cs | Adds the new public context wrapper type for auto-approval rules. |
| dotnet/src/Microsoft.Agents.AI/Harness/ToolApproval/ToolApprovalState.cs | Removes experimental annotation/usings from persisted state type. |
| dotnet/src/Microsoft.Agents.AI/Harness/ToolApproval/ToolApprovalRule.cs | Removes experimental annotation/usings from standing rule model type. |
| dotnet/src/Microsoft.Agents.AI/Harness/ToolApproval/ToolApprovalRequestContentExtensions.cs | Removes experimental annotation/usings from the extension surface. |
| dotnet/src/Microsoft.Agents.AI/Harness/ToolApproval/ToolApprovalAgentOptions.cs | Changes AutoApprovalRules type to accept the new context object and updates docs. |
| dotnet/src/Microsoft.Agents.AI/Harness/ToolApproval/ToolApprovalAgentBuilderExtensions.cs | Removes experimental annotation/usings from builder extensions. |
| dotnet/src/Microsoft.Agents.AI/Harness/ToolApproval/ToolApprovalAgent.cs | Threads run context through run/streaming/queue-drain paths and applies rules via the new context. |
| dotnet/src/Microsoft.Agents.AI/Harness/ToolApproval/AlwaysApproveToolApprovalResponseContent.cs | Removes experimental annotation/usings from approval response content type. |
| dotnet/src/Microsoft.Agents.AI/Harness/FileAccess/FileAccessProvider.cs | Updates built-in file-access auto-approval rules to accept ToolAutoApprovalRuleContext. |
| dotnet/samples/02-agents/Harness/Harness_Step05_Loop/Program.cs | Updates sample auto-approval rule to use context.FunctionCallContent. |
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.
Motivation & Context
The Harness agent (
HarnessAgent) is being prepared for release, but it depends on thetool-approval feature which was still marked experimental. This PR graduates
ToolApprovalAgentand its related public types out of experimental status so they can shipas part of the supported surface.
It also makes the auto-approval extension point future-proof. Auto-approval rules previously
received only a
FunctionCallContent, which cannot gain additional inputs without breakingevery rule. Wrapping the input in a context object lets us add fields over time without
further breaking changes.
Part of the harness dependency graduation tracked by #6964.
Description & Review Guide
What are the major changes?
[Experimental]attribute (and now-unused usings) from the ToolApprovalpublic types:
ToolApprovalAgent,ToolApprovalAgentOptions,ToolApprovalAgentBuilderExtensions,ToolApprovalRule,AlwaysApproveToolApprovalResponseContent,ToolApprovalRequestContentExtensions,ToolApprovalState.ToolAutoApprovalRuleContextthat wraps theFunctionCallContenttogether with the surrounding run context (
Agent,Session,RequestMessages,RunOptions), mirroringAgentRunContext.Func<FunctionCallContent, ValueTask<bool>>toFunc<ToolAutoApprovalRuleContext, ValueTask<bool>>onToolApprovalAgentOptions.AutoApprovalRulesand the built-in rules(
ToolApprovalAgent.AllToolsAutoApprovalRule, and theReadOnly/AllToolsrules onFileAccessProviderandAgentSkillsProvider).ToolApprovalAgentrun/streaming/queue-drain paths so it can be supplied to rules.What is the impact of these changes?
experimental types are now GA. Custom rules that used the
FunctionCallContentparametermust now read
context.FunctionCallContent.changes.
What do you want reviewers to focus on?
ToolApprovalAgent— thatAgent/Session/RequestMessages/RunOptionsare correctly populated on every code path (non-streaming, streaming, and thequeued-request drain).
Related Issue
Related to #6964
Contribution Checklist
breaking changelabel (or add "[BREAKING]" to the title prefix, before or after any language prefix) — a workflow keeps the label and title prefix in sync automatically.