Skip to content

Python: Align GitHub Copilot provider function approval to use SDK on_pre_tool_use hook #6746

Description

@giles17

Follow-up to #6671 (.NET).

The Python agent-framework-github-copilot provider currently enforces function approval itself: it wraps every FunctionTool in an SDK tool-handler that, for tools declared with approval_mode="always_require", awaits an on_function_approval callback before executing (denying by default when none is configured).

Since the GitHub Copilot SDK already provides a native pre-execution hook (on_pre_tool_use) that can return "ask" and route to on_permission_request, this AF-level callback duplicates SDK functionality. For consistency with the .NET provider (see #6671), Python should adopt the same model:

  • Install a default on_pre_tool_use hook (only when the user hasn't supplied their own) that returns "ask" for approval_mode="always_require" tools and defers otherwise.
  • If the user supplies their own on_pre_tool_use, theirs takes precedence; document it and log a warning when an approval-required tool would go unenforced.
  • Remove the bespoke on_function_approval enforcement path.

Scope

  • python/packages/github_copilot/agent_framework_github_copilot/_agent.py
  • Update tests and the package docs accordingly.

Metadata

Metadata

Assignees

Labels

pythonUsage: [Issues, PRs], Target: Python

Type

No type
No fields configured for issues without a type.

Projects

Status
Planned

Milestone

No milestone

Relationships

None yet

Development

No branches or pull requests

Issue actions