Python: Migrate GitHub Copilot package to SDK 0.2.x#5107
Python: Migrate GitHub Copilot package to SDK 0.2.x#5107droideronline wants to merge 9 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.
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
|
@dmytrostruk @eavanvalkenburg @moonbox3 @TaoChenOSU - requesting your review on this PR. Thanks! |
Python Test Coverage Report •
Python Unit Test Overview
|
||||||||||||||||||||||||||||||
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
- 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
| dependencies = [ | ||
| "agent-framework-core>=1.0.0,<2", | ||
| "github-copilot-sdk>=0.1.31,<0.1.33; python_version >= '3.11'", | ||
| "github-copilot-sdk>=0.2.0,<0.3.0; python_version >= '3.11'", |
There was a problem hiding this comment.
we prefer to have smaller increments allowed when dealing with pre-release packages like this, could we make it so that we allow:
| "github-copilot-sdk>=0.2.0,<0.3.0; python_version >= '3.11'", | |
| "github-copilot-sdk>=0.1.31,<=0.2.0; python_version >= '3.11'", |
That way existing users are not broken, and we don't go too far up to the latest and potentially pull in breaking packages, I noticed in the 0.2.1 release notes that that has breaking changes compared to 0.2.0 so the proposed range is too broad already.
There was a problem hiding this comment.
Good point - fixed in the latest commit. Applied <=0.2.0 as the upper bound to avoid pulling in 0.2.1+ breaking changes. I kept >=0.2.0 as the lower bound (rather than >=0.1.31) because this migration changes all import paths to 0.2.x-only modules (copilot.generated.session_events, copilot.session, copilot.tools) - installing 0.1.31 would satisfy the constraint but fail at import time. So the effective range is pinned to exactly 0.2.0 for now. uv.lock updated alongside.
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.
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