Python: Migrate GitHub Copilot package to SDK 0.2.x#5107
Open
droideronline wants to merge 11 commits intomicrosoft:mainfrom
Open
Python: Migrate GitHub Copilot package to SDK 0.2.x#5107droideronline wants to merge 11 commits intomicrosoft:mainfrom
droideronline wants to merge 11 commits intomicrosoft:mainfrom
Conversation
Replace all imports from the non-existent copilot.types module with correct SDK 0.2.x module paths (copilot.session, copilot.client, copilot.tools, copilot.generated.session_events). Fix PermissionRequest attribute access from dict-style .get() to dataclass attribute access. Add OTel telemetry support to Copilot samples via configure_otel_providers and document new telemetry environment variables in samples README.
Contributor
There was a problem hiding this comment.
Pull request overview
This PR updates the agent-framework-github-copilot Python integration to be compatible with github-copilot-sdk 0.2.x by migrating type imports away from the removed copilot.types module, updating session/tool invocation call shapes, and adding sample-level OpenTelemetry enablement plus new Copilot CLI telemetry environment variables.
Changes:
- Bump dependency constraints to
github-copilot-sdk>=0.2.0,<0.3.0(and updateuv.lockaccordingly). - Migrate Copilot SDK imports and API usage (e.g.,
create_session(**kwargs),send(prompt)/send_and_wait(prompt)), and update tests/samples to match. - Add OTel instrumentation wrapper (
GitHubCopilotAgentviaAgentTelemetryLayer) and document Copilot CLI telemetry env vars in the samples README.
Reviewed changes
Copilot reviewed 14 out of 15 changed files in this pull request and generated 3 comments.
Show a summary per file
| File | Description |
|---|---|
| python/uv.lock | Locks github-copilot-sdk to 0.2.1 and updates resolver markers. |
| python/packages/github_copilot/pyproject.toml | Bumps github-copilot-sdk dependency range to 0.2.x. |
| python/packages/github_copilot/agent_framework_github_copilot/_agent.py | Migrates SDK imports/APIs, adds telemetry layer wrapper, adds default permission handler + CLI telemetry wiring. |
| python/packages/github_copilot/agent_framework_github_copilot/init.py | Exports RawGitHubCopilotAgent alongside the instrumented agent. |
| python/packages/core/agent_framework/github/init.py / init.pyi | Re-exports RawGitHubCopilotAgent from the core agent_framework.github shim. |
| python/packages/github_copilot/tests/test_github_copilot_agent.py | Updates mocks/assertions to reflect SDK 0.2.x API shapes and dataclass access. |
| python/samples/README.md | Documents new Copilot CLI telemetry environment variables. |
| python/samples/02-agents/providers/github_copilot/*.py | Updates import paths; enables OTel providers in select samples. |
python/packages/github_copilot/agent_framework_github_copilot/_agent.py
Outdated
Show resolved
Hide resolved
Contributor
Author
|
@dmytrostruk @eavanvalkenburg @moonbox3 @TaoChenOSU - requesting your review on this PR. Thanks! |
Contributor
Python Test Coverage Report •
Python Unit Test Overview
|
||||||||||||||||||||||||||||||
moonbox3
reviewed
Apr 7, 2026
python/packages/github_copilot/agent_framework_github_copilot/_agent.py
Outdated
Show resolved
Hide resolved
python/packages/github_copilot/agent_framework_github_copilot/_agent.py
Outdated
Show resolved
Hide resolved
python/packages/github_copilot/agent_framework_github_copilot/_agent.py
Outdated
Show resolved
Hide resolved
…tures - Remove RawGitHubCopilotAgent split and AgentTelemetryLayer inheritance - Remove TelemetryConfig plumbing and OTLP/file telemetry settings - Remove configure_otel_providers() calls from samples - Remove telemetry env var rows from samples README - Retain only: import path fixes, PermissionRequest attribute access fix, log_level default fix, session kwargs typed fix, dependency pin
moonbox3
approved these changes
Apr 7, 2026
- SubprocessConfig replaces CopilotClientOptions dict - create_session and resume_session now use keyword args - send and send_and_wait take plain string prompt instead of MessageOptions - on_permission_request is always required; deny-all fallback replaces omission
Tighten the upper bound from <0.3.0 to <=0.2.0 to avoid pulling in 0.2.1+ which has breaking API changes relative to 0.2.0. The lower bound stays at >=0.2.0 since this migration requires the 0.2.x import paths; 0.1.x would fail at import time.
5 tasks
Contributor
Author
|
@eavanvalkenburg @moonbox3 - Can I get any update on this, we need Otel in one of our use case. |
Contributor
|
@eavanvalkenburg please have a look when you can. |
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 #5106
Summary
Scoped to SDK 0.2.x compatibility fixes only. OTel/telemetry integration will follow in a separate PR.
copilot.typesmodule with correct SDK 0.2.x module paths across_agent.py, the test file, all 7 samples, and the sample validation scriptPermissionRequest.get("kind")dict-style access to.kindattribute access (PermissionRequestis a dataclass in 0.2.x, not aTypedDict)start()to useSubprocessConfiginstead of the removedCopilotClientOptionsdict; only passlog_levelwhen explicitly set to preserve SDK default behavior_create_sessionand_resume_sessionto call the SDK with direct keyword arguments instead of the removedSessionConfig/ResumeSessionConfigTypedDicts; add_deny_all_permissionsfallback sinceon_permission_requestis now requiredpyproject.tomldependency constraint togithub-copilot-sdk>=0.2.0,<0.3.0Root Cause
copilot.typesdoes not exist in SDK 0.2.x. Types were reorganised:PermissionRequest,SessionEvent,SessionEventTypecopilot.generated.session_eventsPermissionRequestResult,MCPServerConfig,SystemMessageConfigcopilot.sessionTool,ToolInvocation,ToolResultcopilot.toolsAdditionally the following APIs changed:
CopilotClientOptionsdict removed;CopilotClientnow takesSubprocessConfigSessionConfig/ResumeSessionConfigTypedDicts removed;create_session/resume_sessionnow take keyword argumentssend/send_and_waitnow take a plainstrprompt instead of aMessageOptionsdicton_permission_requestis now a required parameter forcreate_session/resume_sessionTest Plan
uv run poe testpasses (77 tests, 0 failures)uv run poe lintpasses (ruff, pyright, mypy)ModuleNotFoundError