Skip to content

.NET: GitHub Copilot provider doesn't enforce ApprovalRequiredAIFunction for custom function tools #6671

Description

@giles17

The .NET Microsoft.Agents.AI.GitHub.Copilot provider doesn't honor the Agent Framework approval boundary for custom function tools wrapped in ApprovalRequiredAIFunction. Because the GitHub Copilot SDK owns the tool-calling loop, the standard AF approval round-trip never runs, so the tool can execute without approval.

Direction

Rather than reimplementing enforcement, lean on the Copilot SDK's native OnPreToolUse hook (verified: it gates custom tools, runs before the permission layer, and "ask" routes to OnPermissionRequest):

  • The provider installs a default OnPreToolUse hook only if the user hasn't supplied their own. It returns "ask" for tools wrapped in ApprovalRequiredAIFunction (routed to OnPermissionRequest to approve/deny) and defers (null) for everything else, so other tools surface through OnPermissionRequest as they do today.
  • If the user supplies their own OnPreToolUse, theirs takes precedence and they own approval handling. This is documented, and the provider logs a warning when an approval-required tool would go unenforced.

A follow-up will align the Python provider to the same model.

Metadata

Metadata

Assignees

Labels

.NETUsage: [Issues, PRs], Target: .Net

Type

Projects

Status
Done

Milestone

No milestone

Relationships

None yet

Development

No branches or pull requests

Issue actions