Skip to content

Python: Migrate GitHub Copilot package to SDK 0.2.x#5107

Open
droideronline wants to merge 9 commits intomicrosoft:mainfrom
droideronline:dinesh/fix-github-copilot-sdk-0.2x-compatibility
Open

Python: Migrate GitHub Copilot package to SDK 0.2.x#5107
droideronline wants to merge 9 commits intomicrosoft:mainfrom
droideronline:dinesh/fix-github-copilot-sdk-0.2x-compatibility

Conversation

@droideronline
Copy link
Copy Markdown
Contributor

@droideronline droideronline commented Apr 5, 2026

Fixes #5106

Summary

Scoped to SDK 0.2.x compatibility fixes only. OTel/telemetry integration will follow in a separate PR.

  • Replace all imports from the non-existent copilot.types module with correct SDK 0.2.x module paths across _agent.py, the test file, all 7 samples, and the sample validation script
  • Fix PermissionRequest.get("kind") dict-style access to .kind attribute access (PermissionRequest is a dataclass in 0.2.x, not a TypedDict)
  • Update start() to use SubprocessConfig instead of the removed CopilotClientOptions dict; only pass log_level when explicitly set to preserve SDK default behavior
  • Update _create_session and _resume_session to call the SDK with direct keyword arguments instead of the removed SessionConfig / ResumeSessionConfig TypedDicts; add _deny_all_permissions fallback since on_permission_request is now required
  • Update pyproject.toml dependency constraint to github-copilot-sdk>=0.2.0,<0.3.0
  • Update tests to match new SDK API shapes

Root Cause

copilot.types does not exist in SDK 0.2.x. Types were reorganised:

Type 0.2.x module
PermissionRequest, SessionEvent, SessionEventType copilot.generated.session_events
PermissionRequestResult, MCPServerConfig, SystemMessageConfig copilot.session
Tool, ToolInvocation, ToolResult copilot.tools

Additionally the following APIs changed:

  • CopilotClientOptions dict removed; CopilotClient now takes SubprocessConfig
  • SessionConfig / ResumeSessionConfig TypedDicts removed; create_session / resume_session now take keyword arguments
  • send / send_and_wait now take a plain str prompt instead of a MessageOptions dict
  • on_permission_request is now a required parameter for create_session / resume_session

Test Plan

  • uv run poe test passes (77 tests, 0 failures)
  • uv run poe lint passes (ruff, pyright, mypy)
  • All 7 samples import without ModuleNotFoundError

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.
Copilot AI review requested due to automatic review settings April 5, 2026 18:13
@markwallace-microsoft markwallace-microsoft added documentation Improvements or additions to documentation python labels Apr 5, 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

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 update uv.lock accordingly).
  • 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 (GitHubCopilotAgent via AgentTelemetryLayer) 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.

@droideronline
Copy link
Copy Markdown
Contributor Author

@dmytrostruk @eavanvalkenburg @moonbox3 @TaoChenOSU - requesting your review on this PR. Thanks!

@moonbox3
Copy link
Copy Markdown
Contributor

moonbox3 commented Apr 7, 2026

Python Test Coverage

Python Test Coverage Report •
FileStmtsMissCoverMissing
packages/github_copilot/agent_framework_github_copilot
   _agent.py3142093%39–40, 46, 65, 291, 294–296, 333, 335, 337, 340, 433–434, 709–710, 725, 728, 795, 826
TOTAL27092319788% 

Python Unit Test Overview

Tests Skipped Failures Errors Time
5373 20 💤 0 ❌ 0 🔥 1m 30s ⏱️

…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'",
Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

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

we prefer to have smaller increments allowed when dealing with pre-release packages like this, could we make it so that we allow:

Suggested change
"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.

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

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

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.
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.

Python: [Bug]: GitHub Copilot package incompatible with github-copilot-sdk 0.2.x

5 participants