GitHub Copilot integration for Microsoft Agent Framework
The `agent-framework-github-copilot` library integrates the GitHub Copilot SDK with the Microsoft Agent Framework, providing Python developers with powerful coding-oriented AI capabilities. These capabilities include shell command execution, file operations, URL fetching, and Model Context Protocol (MCP) server integration. It is part of the broader Microsoft Agent Framework, which has unified previously separate AI frameworks like Semantic Kernel and AutoGen. The library is actively developed, with its current version being 1.0.0b260409, and receives regular updates.
Common errors
-
Copilot coding agent tasks may fail because the agent runtime will be unable to communicate with GitHub systems.
cause Network configuration changes for the Copilot coding agent (effective February 27, 2026) mean it connects to new, plan-specific hostnames. If your network (e.g., for self-hosted runners) doesn't allow these, communication will fail.fixUpdate your network configuration (firewalls, proxy settings, etc.) to allow outgoing connections to the new GitHub Copilot hostnames: `api.business.githubcopilot.com`, `api.enterprise.githubcopilot.com`, and `api.individual.githubcopilot.com`, depending on the Copilot plan(s) in use. -
ModuleNotFoundError: No module named 'agent_framework.github'
cause The `agent-framework-github-copilot` package, or the encompassing `agent-framework` package, has not been installed correctly, or the Python environment is not configured to find it.fixEnsure the package is installed using `pip install agent-framework-github-copilot`. If you intend to use the full framework, `pip install agent-framework` installs all sub-packages, including the GitHub Copilot integration. -
Visual Studio: 'parts of my existing code get unexpectedly deleted, and the output is often incomplete — leaving the file in a broken, unbuildable state.'
cause The GitHub Copilot Agent in Visual Studio can sometimes interfere with existing code, resulting in incomplete outputs or corrupted file structures during code generation or editing, which leads to build errors.fixWhile a direct fix for this behavior is not yet available, it is a known issue. It is recommended to save your work frequently, use version control to track changes, and meticulously review any code generated or modified by the Copilot Agent in Visual Studio. If issues occur, manually revert or correct the code.
Warnings
- breaking Version 1.0.0 introduced breaking changes related to `ToolInvocation` and `ToolResult` types, requiring updates to agent implementations. Additionally, dependency floors now mandate released `>=1.0.0,<2` packages, breaking compatibility with older Release Candidate (RC) installs.
- gotcha The GitHub Copilot CLI must be installed and authenticated separately for the `agent-framework-github-copilot` to function. This is a crucial prerequisite for utilizing the library's features.
- breaking Effective February 27, 2026, the Copilot coding agent will use subscription-based network routing, connecting to different hostnames (e.g., `api.business.githubcopilot.com`, `api.enterprise.githubcopilot.com`, `api.individual.githubcopilot.com`). Self-hosted runners or those with Azure private networking need to allow these new hostnames.
- gotcha The Copilot Agent may struggle to obtain results from shell commands that have longer execution times, potentially limiting its effectiveness for complex or time-consuming tasks.
- gotcha Users have reported issues in Visual Studio where the GitHub Copilot Agent can cause code loss or introduce build-breaking errors due to incomplete or improperly applied code generation/editing.
Install
-
pip install agent-framework-github-copilot
Imports
- GitHubCopilotAgent
from agent_framework.github import GitHubCopilotAgent
- GitHubCopilotOptions
from agent_framework.github import GitHubCopilotOptions
Quickstart
import asyncio
import os
from agent_framework.github import GitHubCopilotAgent, GitHubCopilotOptions
async def main():
# Ensure GitHub Copilot CLI is installed and authenticated.
# For this example, we assume authentication is handled externally or via environment variables.
# Replace with your actual authentication token or method if needed.
# os.environ['GITHUB_TOKEN'] = os.environ.get('GITHUB_TOKEN', 'YOUR_GITHUB_TOKEN')
options = GitHubCopilotOptions()
agent = GitHubCopilotAgent(options)
print("Asking the GitHub Copilot Agent: What is a Python list comprehension?")
response = await agent.run_async("What is a Python list comprehension?")
print(f"Agent Response: {response.output}")
if __name__ == "__main__":
asyncio.run(main())