Python: pin enable_file_hooks off by default in Copilot sessions - #7519
Open
he-yufeng wants to merge 1 commit into
Open
Python: pin enable_file_hooks off by default in Copilot sessions#7519he-yufeng wants to merge 1 commit into
he-yufeng wants to merge 1 commit into
Conversation
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
he-yufeng
temporarily deployed
to
github-app-auth
August 4, 2026 21:41 — with
GitHub Actions
Inactive
he-yufeng
temporarily deployed
to
github-app-auth
August 4, 2026 21:41 — with
GitHub Actions
Inactive
he-yufeng
temporarily deployed
to
github-app-auth
August 4, 2026 21:41 — with
GitHub Actions
Inactive
he-yufeng
temporarily deployed
to
github-app-auth
August 4, 2026 21:42 — with
GitHub Actions
Inactive
Contributor
There was a problem hiding this comment.
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_hooksas a first-classGitHubCopilotOptionskey with rationale and opt-in guidance. - Pin
enable_file_hookstoFalseby 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, |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Fixes #7516.
The Copilot SDK's default for
enable_file_hooksreads.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_kwargsnow pinsenable_file_hookstoFalseunless the caller opts in throughdefault_optionsor per-run options, and the key is documented as a first-classGitHubCopilotOptionskey 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 sendsenable_file_hooks=Falsetocreate_session, and an explicit opt-in throughdefault_optionswins. The session-management test now expects the pinned key on the resume path too. Fulltest_github_copilot_agent.pysuite: 157 passed, 6 skipped.