mirror of
https://github.com/microsoft/agent-framework.git
synced 2026-06-16 21:04:09 +08:00
fe08574a7c
* Python: Upgrade github-copilot-sdk to v1.0.0 (stable) 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> * Address PR review: scope permission handlers, widen type, add test - 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> * Fix validation script and strengthen test assertion - 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> * Add integration tests for GitHubCopilotAgent 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> --------- Co-authored-by: Copilot <223556219+Copilot@users.noreply.github.com>
fe08574a7c
ยท
2026-06-04 08:42:35 +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
- GitHub Copilot CLI: Install and authenticate the Copilot CLI
- GitHub Copilot Subscription: An active GitHub Copilot subscription
- 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 |
GITHUB_COPILOT_BASE_DIRECTORY |
Directory for CLI session state and config | ~/.copilot |
Observability
GitHubCopilotAgent has OpenTelemetry tracing built-in. To enable it, call configure_otel_providers() before running the agent:
from agent_framework.observability import configure_otel_providers
from agent_framework.github import GitHubCopilotAgent
configure_otel_providers(enable_console_exporters=True)
async with GitHubCopilotAgent() as agent:
response = await agent.run("Hello!")
See the observability samples for full examples with OTLP exporters.
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_instruction_directories.py |
Shows how to configure custom instruction directories for project-specific or team-shared guidelines. |
github_copilot_with_multiple_permissions.py |
Shows how to combine multiple permission types for complex tasks that require shell, read, and write access. |