Files
agent-framework/python/samples/02-agents/providers/github_copilot
T
Dineshsuriya D d4036c5aef Python: Migrate GitHub Copilot package to SDK 0.2.x (#5107)
* Python: Migrate GitHub Copilot package to SDK 0.2.x

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.

* Python: Fix remaining copilot.types import in sample validation script

* Python: Include model in default_options for telemetry span attributes

* Python: Address review feedback on log_level and session kwargs typing

* Python: Scope PR to SDK 0.2.x migration only, remove net-new OTel features

- 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

* Python: Update tests for SDK 0.2.x API changes

- 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

* Python: Pin github-copilot-sdk to >=0.2.0,<=0.2.0

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.

* Python: Pin github-copilot-sdk to >=0.2.1,<=0.2.1

---------

Co-authored-by: Evan Mattson <35585003+moonbox3@users.noreply.github.com>
d4036c5aef · 2026-04-10 01:07:14 +00:00
History
..

GitHub Copilot Agent Examples

This directory contains examples demonstrating how to use the GitHubCopilotAgent from the Microsoft Agent Framework.

Security Note: These examples demonstrate various permission types (shell, read, write, url). Only enable permissions that are necessary for your use case. Each permission grants the agent additional capabilities that could affect your system.

Prerequisites

  1. GitHub Copilot CLI: Install and authenticate the Copilot CLI
  2. GitHub Copilot Subscription: An active GitHub Copilot subscription
  3. Install the package:
    pip install agent-framework-github-copilot --pre
    

Environment Variables

The following environment variables can be configured:

Variable Description Default
GITHUB_COPILOT_CLI_PATH Path to the Copilot CLI executable copilot
GITHUB_COPILOT_MODEL Model to use (e.g., "gpt-5", "claude-sonnet-4") Server default
GITHUB_COPILOT_TIMEOUT Request timeout in seconds 60
GITHUB_COPILOT_LOG_LEVEL CLI log level info

Examples

File Description
github_copilot_basic.py The simplest way to create an agent using GitHubCopilotAgent. Demonstrates both streaming and non-streaming responses with function tools.
github_copilot_with_session.py Shows session management with automatic creation, persistence via session objects, and resuming sessions by ID.
github_copilot_with_shell.py Shows how to enable shell command execution permissions. Demonstrates running system commands like listing files and getting system information.
github_copilot_with_file_operations.py Shows how to enable file read and write permissions. Demonstrates reading file contents and creating new files.
github_copilot_with_url.py Shows how to enable URL fetching permissions. Demonstrates fetching and processing web content.
github_copilot_with_mcp.py Shows how to configure MCP (Model Context Protocol) servers, including local (stdio) and remote (HTTP) servers.
github_copilot_with_multiple_permissions.py Shows how to combine multiple permission types for complex tasks that require shell, read, and write access.