Skip to content

Python: [BREAKING] Upgrade github-copilot-sdk to v1.0.0 (stable)#6292

Merged
moonbox3 merged 6 commits into
microsoft:mainfrom
giles17:ghcp-v1-migration
Jun 4, 2026
Merged

Python: [BREAKING] Upgrade github-copilot-sdk to v1.0.0 (stable)#6292
moonbox3 merged 6 commits into
microsoft:mainfrom
giles17:ghcp-v1-migration

Conversation

@giles17
Copy link
Copy Markdown
Contributor

@giles17 giles17 commented Jun 2, 2026

Changes

Upgrades agent-framework-github-copilot from github-copilot-sdk 1.0.0b2 to the stable 1.0.0 release, adapting to all breaking API changes introduced in the GA version.

Source (_agent.py)

  • SubprocessConfig removed - use RuntimeConnection.for_stdio(path=...) + CopilotClient kwargs (connection, log_level, base_directory)
  • Import paths moved from copilot.generated.session_events to copilot.session_events
  • Settings rename: copilot_home to base_directory (env: GITHUB_COPILOT_BASE_DIRECTORY)
  • Default deny handler: returns PermissionDecisionUserNotAvailable() (matching SDK fallback behavior)

Tests

  • Updated imports and client-construction assertions (now kwargs-based, no positional SubprocessConfig)
  • Permission handler tests use concrete decision types (PermissionDecisionApproveOnce, PermissionDecisionDeniedInteractivelyByUser)

Samples

  • Permission handlers simplified to PermissionHandler.approve_all or sync approve_and_log pattern (v1.0.0 protocol v3 dispatches permission requests via asyncio.ensure_future, making blocking input() incompatible)
  • Function approval sample uses asyncio.to_thread for interactive prompts
  • All samples verified end-to-end

Breaking changes for consumers

  • GITHUB_COPILOT_COPILOT_HOME env var renamed to GITHUB_COPILOT_BASE_DIRECTORY
  • copilot_home option renamed to base_directory in GitHubCopilotSettings and default_options

Upgrade agent-framework-github-copilot from github-copilot-sdk 1.0.0b2 to the
stable 1.0.0 release, adapting to all breaking API changes.

Source changes (_agent.py):
- SubprocessConfig removed: use RuntimeConnection.for_stdio(path=...) +
  CopilotClient kwargs (connection, log_level, base_directory)
- Import paths: copilot.generated.session_events -> copilot.session_events
- Settings: copilot_home -> base_directory (env GITHUB_COPILOT_BASE_DIRECTORY)
- Default deny handler: PermissionDecisionUserNotAvailable() (from
  copilot.generated.rpc)

Test changes:
- Updated imports and client-construction assertions (kwargs-based)
- Permission handler tests use concrete decision types
  (PermissionDecisionApproveOnce, PermissionDecisionDeniedInteractivelyByUser)

Sample changes:
- Permission handlers use PermissionHandler.approve_all or sync
  approve_and_log pattern (v1.0.0 protocol v3 dispatch is incompatible
  with blocking input() in permission handlers)
- Function approval sample uses asyncio.to_thread for interactive prompts
- Simplified imports across all samples

Co-authored-by: Copilot <223556219+Copilot@users.noreply.github.com>
Copilot AI review requested due to automatic review settings June 2, 2026 23:44
@moonbox3 moonbox3 added documentation Improvements or additions to documentation python labels Jun 2, 2026
@giles17 giles17 changed the title Python: Upgrade github-copilot-sdk to v1.0.0 (stable) Python: [BREAKING} Upgrade github-copilot-sdk to v1.0.0 (stable) Jun 2, 2026
@giles17 giles17 changed the title Python: [BREAKING} Upgrade github-copilot-sdk to v1.0.0 (stable) Python: [BREAKING] Upgrade github-copilot-sdk to v1.0.0 (stable) Jun 2, 2026
Copy link
Copy Markdown
Contributor

Copilot AI left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Pull request overview

Updates the Python agent-framework-github-copilot integration to work with github-copilot-sdk v1.0.0 (stable), including adapting to GA API changes in client construction, settings/env var naming, and permission/decision types.

Changes:

  • Bumps github-copilot-sdk dependency constraints (and updates uv.lock) to target >=1.0.0,<2.
  • Refactors GitHubCopilotAgent client startup to use RuntimeConnection.for_stdio(...) and kwargs-based CopilotClient(...) construction; renames copilot_homebase_directory.
  • Updates tests and samples to the new import paths and permission decision patterns.

Reviewed changes

Copilot reviewed 13 out of 14 changed files in this pull request and generated 3 comments.

Show a summary per file
File Description
python/uv.lock Locks updated dependency graph for the SDK upgrade (incl. transitive bumps).
python/samples/02-agents/providers/github_copilot/README.md Documents env var rename to GITHUB_COPILOT_BASE_DIRECTORY.
python/samples/02-agents/providers/github_copilot/github_copilot_with_url.py Updates permission imports/handler pattern for URL fetching sample.
python/samples/02-agents/providers/github_copilot/github_copilot_with_shell.py Updates permission imports/handler pattern for shell sample.
python/samples/02-agents/providers/github_copilot/github_copilot_with_session.py Simplifies permission handler usage for session samples.
python/samples/02-agents/providers/github_copilot/github_copilot_with_multiple_permissions.py Updates permission imports/handler pattern for multi-permission sample.
python/samples/02-agents/providers/github_copilot/github_copilot_with_mcp.py Updates permission imports/handler pattern for MCP sample.
python/samples/02-agents/providers/github_copilot/github_copilot_with_instruction_directories.py Updates permission imports/handler pattern for instruction-directory sample.
python/samples/02-agents/providers/github_copilot/github_copilot_with_function_approval.py Adapts function-approval sample to async prompting and adds permission handler.
python/samples/02-agents/providers/github_copilot/github_copilot_with_file_operations.py Updates file-permission sample handler implementation for new decision types.
python/samples/02-agents/providers/github_copilot/github_copilot_basic.py Simplifies permission handler usage for basic sample.
python/packages/github_copilot/tests/test_github_copilot_agent.py Updates imports + asserts CopilotClient is constructed via kwargs and new decision types.
python/packages/github_copilot/pyproject.toml Updates dependency constraint to github-copilot-sdk>=1.0.0,<2.
python/packages/github_copilot/agent_framework_github_copilot/_agent.py Refactors settings/env var + client construction for SDK v1.0.0 API.

Comment thread python/samples/02-agents/providers/github_copilot/github_copilot_with_shell.py Outdated
Comment thread python/samples/02-agents/providers/github_copilot/github_copilot_with_url.py Outdated
Copy link
Copy Markdown

@github-actions github-actions Bot left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Automated Code Review

Reviewers: 4 | Confidence: 86%

✓ Correctness

Clean SDK upgrade from github-copilot-sdk 1.0.0b2 to 1.0.0. All changes are internally consistent: import paths updated, SubprocessConfig correctly replaced with RuntimeConnection.for_stdio + CopilotClient kwargs, copilot_home→base_directory rename is consistent across TypedDict, init, start(), and env var mapping via load_settings. The default deny handler correctly returns PermissionDecisionUserNotAvailable(). No correctness issues found.

✓ Security Reliability

This PR is a clean SDK upgrade from github-copilot-sdk 1.0.0b2 to 1.0.0. The security posture is maintained: the default permission handler still denies all requests (using PermissionDecisionUserNotAvailable which matches the SDK's own fallback behavior). The migration to asyncio.to_thread for interactive input in samples correctly prevents event loop blocking. No injection risks, secrets exposure, resource leaks, or unhandled failure modes were identified. The client construction changes properly gate optional kwargs behind truthiness checks, and the settings loader correctly maps GITHUB_COPILOT_BASE_DIRECTORY via the env_prefix mechanism.

✓ Test Coverage

The PR correctly adapts to the github-copilot-sdk 1.0.0 API changes with corresponding test updates. The main test coverage gap is that the behavioral change in _deny_all_permissions (now returning PermissionDecisionUserNotAvailable() instead of PermissionRequestResult()) has no test asserting the actual return value. The existing test test_session_config_uses_deny_all_when_no_permission_handler_set only verifies the handler is assigned, not what it returns when invoked.

✓ Design Approach

I found one design-level mismatch: the PR updates github_copilot_with_file_operations.py to use an async permission callback, but the package still exposes on_permission_request as a synchronous callback in its public contract and forwards it unchanged into session creation. That makes the sample demonstrate an API shape the framework itself does not yet promise to consumers.

Suggestions

  • If async permission handlers are now part of the supported SDK migration path, widen the framework contract to match (PermissionHandlerType and GitHubCopilotOptions.on_permission_request docs/types in python/packages/github_copilot/agent_framework_github_copilot/_agent.py) rather than only changing the sample.

Automated review by giles17's agents

@giles17 giles17 marked this pull request as draft June 3, 2026 00:15
@github-actions
Copy link
Copy Markdown

github-actions Bot commented Jun 3, 2026

Python Test Coverage

Python Test Coverage Report •
FileStmtsMissCoverMissing
packages/github_copilot/agent_framework_github_copilot
   _agent.py3411296%46–47, 53, 473, 488–489, 785–786, 824, 827, 894, 933
TOTAL37983442588% 

Python Unit Test Overview

Tests Skipped Failures Errors Time
7578 34 💤 0 ❌ 0 🔥 1m 57s ⏱️

- Shell sample: only approve kind='shell', deny others
- URL sample: only approve kind='url', deny others
- Use getattr() for kind-specific attributes to satisfy pyright
- Widen PermissionHandlerType to accept async handlers (matches SDK)
- Add test for _deny_all_permissions return value

Co-authored-by: Copilot <223556219+Copilot@users.noreply.github.com>
@giles17 giles17 marked this pull request as ready for review June 3, 2026 16:40
@giles17 giles17 requested a review from Copilot June 3, 2026 16:43
Copy link
Copy Markdown
Contributor

Copilot AI left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Pull request overview

Copilot reviewed 13 out of 14 changed files in this pull request and generated 2 comments.

Comment thread python/packages/github_copilot/tests/test_github_copilot_agent.py Outdated
Copy link
Copy Markdown

@github-actions github-actions Bot left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Automated Code Review

Reviewers: 4 | Confidence: 85% | Result: All clear

Reviewed: Correctness, Security Reliability, Test Coverage, Design Approach


Automated review by giles17's agents

- Update scripts/sample_validation/create_dynamic_workflow_executor.py to
  use copilot.session_events imports and PermissionHandler.approve_all
- Assert isinstance(result, PermissionDecisionUserNotAvailable) instead of
  stringly-typed kind check

Co-authored-by: Copilot <223556219+Copilot@users.noreply.github.com>
@giles17 giles17 marked this pull request as draft June 3, 2026 20:59
Add 6 integration tests mirroring .NET coverage:
- Basic non-streaming response
- Streaming response
- Function tool invocation
- Session context (multi-turn)
- Session resume by ID
- Shell command execution

Tests require COPILOT_GITHUB_TOKEN env var (skipped otherwise).
Each test cleans up its Copilot session via delete_session.

Co-authored-by: Copilot <223556219+Copilot@users.noreply.github.com>
@giles17 giles17 marked this pull request as ready for review June 3, 2026 21:01
Copy link
Copy Markdown

@github-actions github-actions Bot left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Automated Code Review

Reviewers: 4 | Confidence: 91% | Result: All clear

Reviewed: Correctness, Security Reliability, Test Coverage, Design Approach


Automated review by giles17's agents

Copy link
Copy Markdown
Contributor

@moonbox3 moonbox3 left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Shall we also make sure to update this doc with these breaking changes? https://learn.microsoft.com/en-us/agent-framework/support/upgrade/python-2026-significant-changes

@moonbox3 moonbox3 added this pull request to the merge queue Jun 4, 2026
Merged via the queue into microsoft:main with commit fe08574 Jun 4, 2026
37 checks passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

documentation Improvements or additions to documentation python

Projects

None yet

Development

Successfully merging this pull request may close these issues.

4 participants