Skip to content

Python: pin enable_file_hooks off by default in Copilot sessions - #7519

Open
he-yufeng wants to merge 1 commit into
microsoft:mainfrom
he-yufeng:fix/copilot-file-hooks-default
Open

Python: pin enable_file_hooks off by default in Copilot sessions#7519
he-yufeng wants to merge 1 commit into
microsoft:mainfrom
he-yufeng:fix/copilot-file-hooks-default

Conversation

@he-yufeng

Copy link
Copy Markdown
Contributor

Fixes #7516.

The Copilot SDK's default for enable_file_hooks reads .github/hooks/ from the process working directory, so two identical agents could behave differently depending only on where the process was started, and the option sat outside anything the caller could see. _build_session_kwargs now pins enable_file_hooks to False unless the caller opts in through default_options or per-run options, and the key is documented as a first-class GitHubCopilotOptions key so there is one place to see and control it. Options that only shape prompt context (e.g. enable_host_git_operations) are untouched.

Verification

New passthrough tests in TestGitHubCopilotAgentOptionsPassthrough: the default sends enable_file_hooks=False to create_session, and an explicit opt-in through default_options wins. The session-management test now expects the pinned key on the resume path too. Full test_github_copilot_agent.py suite: 157 passed, 6 skipped.

The Copilot SDK's default reads `.github/hooks/` from the process
working directory, so the same agent with the same options behaved
differently depending on where the process started, with no way for a
caller to see or control it. `_build_session_kwargs` now pins
enable_file_hooks to False unless the caller opts in through
default_options or per-run options, and the key is documented in
GitHubCopilotOptions. Options that only shape prompt context, such as
enable_host_git_operations, are untouched.

Fixes microsoft#7516
Copilot AI lite review requested due to automatic review settings August 4, 2026 21:41
@he-yufeng
he-yufeng temporarily deployed to github-app-auth August 4, 2026 21:41 — with GitHub Actions Inactive
@he-yufeng
he-yufeng temporarily deployed to github-app-auth August 4, 2026 21:41 — with GitHub Actions Inactive
@he-yufeng
he-yufeng temporarily deployed to github-app-auth August 4, 2026 21:41 — with GitHub Actions Inactive
@he-yufeng
he-yufeng temporarily deployed to github-app-auth August 4, 2026 21:42 — with GitHub Actions Inactive
@agent-framework-automation agent-framework-automation Bot added the python Usage: [Issues, PRs], Target: Python label Aug 4, 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.

Pull request overview

Pins Copilot session creation/resumption to a deterministic default for enable_file_hooks in the Python GitHubCopilotAgent, preventing implicit behavior changes based solely on the process working directory, while still allowing callers to explicitly opt in via options.

Changes:

  • Document enable_file_hooks as a first-class GitHubCopilotOptions key with rationale and opt-in guidance.
  • Pin enable_file_hooks to False by default in _build_session_kwargs (unless explicitly set by caller options).
  • Add/adjust tests to verify default behavior and opt-in behavior for session creation (and include the key on resume assertions).

Reviewed changes

Copilot reviewed 2 out of 2 changed files in this pull request and generated 1 comment.

File Description
python/packages/github_copilot/agent_framework_github_copilot/_agent.py Adds typed/docs surfaced option and pins enable_file_hooks=False by default in session kwargs.
python/packages/github_copilot/tests/test_github_copilot_agent.py Adds passthrough tests for default/opt-in behavior and updates session resumption expectations.

model=unittest.mock.ANY,
on_permission_request=unittest.mock.ANY,
hooks=unittest.mock.ANY,
enable_file_hooks=unittest.mock.ANY,
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

python Usage: [Issues, PRs], Target: Python

Projects

None yet

Development

Successfully merging this pull request may close these issues.

Python: GitHubCopilotAgent session behavior varies with the working directory

2 participants