Skip to content

[dotnet-port-api] Add tool approval bypass opt-out - #1044

Merged
Quim Muntal (qmuntal) merged 2 commits into
mainfrom
copilot/dotnet-port-api-toolapproval-bypass-optout-20260713-063604-230d44dc9dd8e156
Sep 10, 2026
Merged

[dotnet-port-api] Add tool approval bypass opt-out#1044
Quim Muntal (qmuntal) merged 2 commits into
mainfrom
copilot/dotnet-port-api-toolapproval-bypass-optout-20260713-063604-230d44dc9dd8e156

Conversation

@michelle-clayton-work

Copy link
Copy Markdown
Contributor

Summary

Port the public opt-out from microsoft/agent-framework#6970 for bypassing approval requests on tools that do not actually require approval.

This adds toolapproval.Config.DisableNonApprovalRequiredToolBypassing, wires it into the middleware's auto-approval decision path, adds focused coverage for the opt-out behavior, and updates the .NET/Go feature comparison note to reflect the exposed Go surface.

Upstream source commit: 76f2c1a0c974cd4168857dc71520597674650bf8 (https://github.com/microsoft/agent-framework/commit/76f2c1a0c974cd4168857dc71520597674650bf8).

Ported .NET PRs

Breaking Changes

No.

Tests and Examples

  • go test ./agent/harness/toolapproval ./agent/harness/toolautocall -count=1
  • Added focused toolapproval coverage verifying that queued non-approval-required tool requests are surfaced when bypassing is disabled.
  • Updated docs/dotnet-go-sdk-feature-comparison.md
  • No examples changed; this port adds a configuration opt-out to existing middleware behavior rather than a new end-user scenario.

Notes

  • The other public change in upstream PR #6970 (RequirePerServiceCallChatHistoryPersistence) is a broader chat-client pipeline feature and was intentionally not bundled into this narrow nightly port.
  • Existing Go behavior already matched the default bypass semantics; this PR only exposes the public opt-out needed for parity.

Generated by .NET to Go API Porting Agent · 732 AIC · ⌖ 17.9 AIC · ⊞ 21.7K ·

Closes #480

Port the public opt-out for approval-not-required tool bypassing from microsoft/agent-framework#6970 by adding a matching toolapproval middleware configuration flag and focused tests.

Co-authored-by: Copilot <223556219+Copilot@users.noreply.github.com>
Copilot AI lite review requested due to automatic review settings September 9, 2026 20:25
@github-actions github-actions Bot added area:agent Changes files in the agent area size:medium At most 100 changed lines across at most 5 files labels Sep 9, 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.

🟡 Changes recommended

A newly added public-facing doc comment describes narrower semantics than the actual implementation, which could mislead API consumers.

Once you've addressed the issues Copilot identified, you can request another Copilot review.

Pull request overview

Adds a public toolapproval middleware configuration opt-out to stop automatically bypassing/silently auto-approving tool-approval requests for tools that don’t require approval, plus targeted tests and updated .NET/Go parity documentation.

Changes:

  • Added toolapproval.Config.DisableNonApprovalRequiredToolBypassing and wired it into the auto-approval decision path.
  • Added a focused toolapproval test ensuring queued non-approval-required requests are surfaced when bypassing is disabled.
  • Updated the .NET/Go SDK feature comparison to reflect the new Go surface area.
File summaries
File Description
agent/harness/toolapproval/toolapproval.go Adds the opt-out config flag and changes auto-approval logic to respect it.
agent/harness/toolapproval/toolapproval_test.go Adds coverage validating queued non-approval-required requests are surfaced when the opt-out is enabled.
docs/dotnet-go-sdk-feature-comparison.md Updates parity documentation to mention/configure the new opt-out.
Review details
  • Files reviewed: 3/3 changed files
  • Comments generated: 1
  • Review effort level: Lite

💡 Add a code-review agent skill or configure MCP servers for context-aware, tailored reviews. Learn more in the docs.

Comment on lines +98 to +102
// DisableNonApprovalRequiredToolBypassing disables the default behavior that
// auto-approves requests for tools that do not actually require approval when
// they are surfaced alongside approval-required tools. When true, all such
// requests are surfaced to the caller instead of being transparently
// re-injected as approved on the next turn.
@github-actions github-actions Bot added kind:code Changes production behavior or code kind:docs Changes documentation or comments kind:tests Changes tests, fixtures, or test infrastructure pending-auto-risk Automatic risk classification is in progress labels Sep 9, 2026
@michelle-clayton-work

Copy link
Copy Markdown
Contributor Author

Copilot resolve merge conflicts and address PR feedback

…pi-toolapproval-bypass-optout-20260713-063604-230d44dc9dd8e156

# Conflicts:
#	agent/harness/toolapproval/toolapproval.go
#	docs/dotnet-go-sdk-feature-comparison.md

Co-authored-by: michelle-clayton-work <262183035+michelle-clayton-work@users.noreply.github.com>

Copilot AI commented Sep 9, 2026

Copy link
Copy Markdown
Contributor

Copilot resolve merge conflicts and address PR feedback

Merged main into the branch (conflicts in agent/harness/toolapproval/toolapproval.go and docs/dotnet-go-sdk-feature-comparison.md resolved so the opt-out sits alongside the new DisableApprovalResponseBinding/MaxAutoApprovalIterations config and the updated isAutoApprovable signature), and updated the DisableNonApprovalRequiredToolBypassing doc comment to describe the actual behavior: it gates all isNotApprovalRequired-based auto-approvals, with standing rules and AutoApprovalRules still applying.

go test ./agent/harness/toolapproval ./agent/harness/toolautocall -count=1 passes.

@github-actions github-actions Bot added risk:medium Contained production impact requiring normal review depth pending-auto-risk Automatic risk classification is in progress and removed pending-auto-risk Automatic risk classification is in progress risk:medium Contained production impact requiring normal review depth labels Sep 9, 2026
@github-actions

github-actions Bot commented Sep 9, 2026

Copy link
Copy Markdown
Contributor

Scope: public API, user-visible behavior

Changed Go contract: New exported field toolapproval.Config.DisableNonApprovalRequiredToolBypassing (agent/harness/toolapproval/toolapproval.go), wired into isAutoApprovable so !cfg.DisableNonApprovalRequiredToolBypassing && isNotApprovalRequired(...) gates the existing default auto-bypass of non-approval-required tool calls. Default false preserves prior always-bypass behavior; true surfaces those calls as approval requests unless matched by a standing rule or AutoApprovalRules.

Upstream evidence reviewed:

  • dotnet/src/Microsoft.Agents.AI/ChatClient/ChatClientAgentOptions.csDisableApprovalNotRequiredFunctionBypassing (post-rename in the cited commit 76f2c1a0c9), default false, opt-out semantics matching this PR.
  • dotnet/src/Microsoft.Agents.AI/ChatClient/ChatClientExtensions.cs (WithDefaultAgentMiddleware) — decorator now injected by default unless the option is true, i.e. bypass-by-default with an opt-out, matching the Go default.
  • dotnet/src/Microsoft.Agents.AI.Harness/HarnessAgentOptions.csDisableApprovalNotRequiredFunctionBypassing, same opt-out shape surfaced at the harness level, analogous to toolapproval.Config.
  • dotnet/tests/Microsoft.Agents.AI.Harness.UnitTests/HarnessAgentTests.csApprovalNotRequiredFunctionBypassing_SurfacesAllApprovalsWhenDisabledAsync covers the same "opt-out surfaces all approvals" scenario as the new Go test TestToolApproval_DisableNonApprovalRequiredToolBypassing_SurfacesQueuedNonApprovalRequest.

Result: aligned. The default (bypass enabled) matches upstream's default, and the new opt-out field mirrors the upstream contract shape (an exported boolean disabling the default bypass), adapted idiomatically to Go's options-struct/middleware pattern rather than .NET's chat-client decorator. The cited upstream commit's unrelated changes (no-session no-op/logging behavior for the .NET decorator, and removal of [Experimental] from RequirePerServiceCallChatHistoryPersistence) are correctly and explicitly excluded from this PR's scope per its description, and neither affects the parity of the ported opt-out. No naming, default, or behavioral divergence found; the Go/.NET feature-comparison doc update accurately reflects the new surface.

Ran locally: go test ./agent/harness/toolapproval/... passes, including the new test.

Generated by Go API Consistency Review Agent for #1044 · copilot · auto · 57.5 AIC · ⌖ 7.18 AIC · ⊞ 9.6K ·

@github-actions github-actions Bot added parity-approved Go API consistency review found no parity issues public-api-change Pull Request changes public APIs risk:medium Contained production impact requiring normal review depth and removed pending-auto-risk Automatic risk classification is in progress labels Sep 9, 2026
@qmuntal
Quim Muntal (qmuntal) added this pull request to the merge queue Sep 10, 2026
Merged via the queue into main with commit 710598e Sep 10, 2026
46 of 48 checks passed
@qmuntal
Quim Muntal (qmuntal) deleted the copilot/dotnet-port-api-toolapproval-bypass-optout-20260713-063604-230d44dc9dd8e156 branch September 10, 2026 09:04
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

area:agent Changes files in the agent area kind:code Changes production behavior or code kind:docs Changes documentation or comments kind:tests Changes tests, fixtures, or test infrastructure parity-approved Go API consistency review found no parity issues public-api-change Pull Request changes public APIs risk:medium Contained production impact requiring normal review depth size:medium At most 100 changed lines across at most 5 files

Projects

None yet

Development

Successfully merging this pull request may close these issues.

[dotnet-port-api] Add tool approval bypass opt-out

4 participants