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.

Activity

  1. changed the title [-]Python: Align GitHub Copilot provider function approval to use SDK on_pre_tool_use hook[/-] [+].NET: Python: Align GitHub Copilot provider function approval to use SDK on_pre_tool_use hook[/+] on Jun 25, 2026
  2. changed the title [-].NET: Python: Align GitHub Copilot provider function approval to use SDK on_pre_tool_use hook[/-] [+]Python: Align GitHub Copilot provider function approval to use SDK on_pre_tool_use hook[/+] on Jun 25, 2026
  3. added a commit that references this issue on Jun 30, 2026
    4cb1a66
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Labels

pythonUsage: [Issues, PRs], Target: Python

Type

No type

Projects

Milestone

No milestone

Relationships

None yet

Development

No branches or pull requests

Issue actions