.NET: Python: [BREAKING] Renamed Github to GitHub (#3486)

* Renamed Github to GitHub

* Small fix

* Updated package versions
This commit is contained in:
Dmytro Struk
2026-01-28 11:58:31 -08:00
committed by GitHub
Unverified
parent fa74f27030
commit 45a020be43
55 changed files with 251 additions and 234 deletions
@@ -1,6 +1,6 @@
# GitHub Copilot Agent Examples
This directory contains examples demonstrating how to use the `GithubCopilotAgent` from the Microsoft Agent Framework.
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.
@@ -28,7 +28,7 @@ The following environment variables can be configured:
| File | Description |
|------|-------------|
| [`github_copilot_basic.py`](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_basic.py`](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`](github_copilot_with_session.py) | Shows session management with automatic creation, persistence via thread objects, and resuming sessions by ID. |
| [`github_copilot_with_shell.py`](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`](github_copilot_with_file_operations.py) | Shows how to enable file read and write permissions. Demonstrates reading file contents and creating new files. |
@@ -3,7 +3,7 @@
"""
GitHub Copilot Agent Basic Example
This sample demonstrates basic usage of GithubCopilotAgent.
This sample demonstrates basic usage of GitHubCopilotAgent.
Shows both streaming and non-streaming responses with function tools.
Environment variables (optional):
@@ -17,9 +17,10 @@ import asyncio
from random import randint
from typing import Annotated
from agent_framework.github import GithubCopilotAgent, GithubCopilotOptions
from pydantic import Field
from agent_framework import tool
from agent_framework.github import GitHubCopilotAgent, GitHubCopilotOptions
from pydantic import Field
# NOTE: approval_mode="never_require" is for sample brevity. Use "always_require" in production; see samples/getting_started/tools/function_tool_with_approval.py and samples/getting_started/tools/function_tool_with_approval_and_threads.py.
@tool(approval_mode="never_require")
@@ -35,7 +36,7 @@ async def non_streaming_example() -> None:
"""Example of non-streaming response (get the complete result at once)."""
print("=== Non-streaming Response Example ===")
agent: GithubCopilotAgent[GithubCopilotOptions] = GithubCopilotAgent(
agent: GitHubCopilotAgent[GitHubCopilotOptions] = GitHubCopilotAgent(
default_options={"instructions": "You are a helpful weather agent."},
tools=[get_weather],
)
@@ -51,7 +52,7 @@ async def streaming_example() -> None:
"""Example of streaming response (get results as they are generated)."""
print("=== Streaming Response Example ===")
agent: GithubCopilotAgent[GithubCopilotOptions] = GithubCopilotAgent(
agent: GitHubCopilotAgent[GitHubCopilotOptions] = GitHubCopilotAgent(
default_options={"instructions": "You are a helpful weather agent."},
tools=[get_weather],
)
@@ -3,7 +3,7 @@
"""
GitHub Copilot Agent with File Operation Permissions
This sample demonstrates how to enable file read and write operations with GithubCopilotAgent.
This sample demonstrates how to enable file read and write operations with GitHubCopilotAgent.
By providing a permission handler that approves "read" and/or "write" requests, the agent can
read from and write to files on the filesystem.
@@ -14,7 +14,7 @@ SECURITY NOTE: Only enable file permissions when you trust the agent's actions.
import asyncio
from agent_framework.github import GithubCopilotAgent, GithubCopilotOptions
from agent_framework.github import GitHubCopilotAgent, GitHubCopilotOptions
from copilot.types import PermissionRequest, PermissionRequestResult
@@ -35,7 +35,7 @@ def prompt_permission(request: PermissionRequest, context: dict[str, str]) -> Pe
async def main() -> None:
print("=== GitHub Copilot Agent with File Operation Permissions ===\n")
agent: GithubCopilotAgent[GithubCopilotOptions] = GithubCopilotAgent(
agent: GitHubCopilotAgent[GitHubCopilotOptions] = GitHubCopilotAgent(
default_options={
"instructions": "You are a helpful assistant that can read and write files.",
"on_permission_request": prompt_permission,
@@ -4,7 +4,7 @@
GitHub Copilot Agent with MCP Servers
This sample demonstrates how to configure MCP (Model Context Protocol) servers
with GithubCopilotAgent. It shows both local (stdio) and remote (HTTP) server
with GitHubCopilotAgent. It shows both local (stdio) and remote (HTTP) server
configurations, giving the agent access to external tools and data sources.
SECURITY NOTE: MCP servers can expose powerful capabilities. Only configure
@@ -14,7 +14,7 @@ of MCP-related actions.
import asyncio
from agent_framework.github import GithubCopilotAgent, GithubCopilotOptions
from agent_framework.github import GitHubCopilotAgent, GitHubCopilotOptions
from copilot.types import MCPServerConfig, PermissionRequest, PermissionRequestResult
@@ -49,7 +49,7 @@ async def main() -> None:
},
}
agent: GithubCopilotAgent[GithubCopilotOptions] = GithubCopilotAgent(
agent: GitHubCopilotAgent[GitHubCopilotOptions] = GitHubCopilotAgent(
default_options={
"instructions": "You are a helpful assistant with access to the local filesystem and Microsoft Learn.",
"on_permission_request": prompt_permission,
@@ -3,7 +3,7 @@
"""
GitHub Copilot Agent with Multiple Permissions
This sample demonstrates how to enable multiple permission types with GithubCopilotAgent.
This sample demonstrates how to enable multiple permission types with GitHubCopilotAgent.
By combining different permission kinds in the handler, the agent can perform complex tasks
that require multiple capabilities.
@@ -20,7 +20,7 @@ More permissions mean more potential for unintended actions.
import asyncio
from agent_framework.github import GithubCopilotAgent, GithubCopilotOptions
from agent_framework.github import GitHubCopilotAgent, GitHubCopilotOptions
from copilot.types import PermissionRequest, PermissionRequestResult
@@ -43,7 +43,7 @@ def prompt_permission(request: PermissionRequest, context: dict[str, str]) -> Pe
async def main() -> None:
print("=== GitHub Copilot Agent with Multiple Permissions ===\n")
agent: GithubCopilotAgent[GithubCopilotOptions] = GithubCopilotAgent(
agent: GitHubCopilotAgent[GitHubCopilotOptions] = GitHubCopilotAgent(
default_options={
"instructions": "You are a helpful development assistant that can read, write files and run commands.",
"on_permission_request": prompt_permission,
@@ -3,7 +3,7 @@
"""
GitHub Copilot Agent with Session Management
This sample demonstrates session management with GithubCopilotAgent, showing
This sample demonstrates session management with GitHubCopilotAgent, showing
persistent conversation capabilities. Sessions are automatically persisted
server-side by the Copilot CLI.
"""
@@ -12,9 +12,10 @@ import asyncio
from random import randint
from typing import Annotated
from agent_framework.github import GithubCopilotAgent, GithubCopilotOptions
from pydantic import Field
from agent_framework import tool
from agent_framework.github import GitHubCopilotAgent, GitHubCopilotOptions
from pydantic import Field
# NOTE: approval_mode="never_require" is for sample brevity. Use "always_require" in production; see samples/getting_started/tools/function_tool_with_approval.py and samples/getting_started/tools/function_tool_with_approval_and_threads.py.
@tool(approval_mode="never_require")
@@ -30,7 +31,7 @@ async def example_with_automatic_session_creation() -> None:
"""Each run() without thread creates a new session."""
print("=== Automatic Session Creation Example ===")
agent: GithubCopilotAgent[GithubCopilotOptions] = GithubCopilotAgent(
agent: GitHubCopilotAgent[GitHubCopilotOptions] = GitHubCopilotAgent(
default_options={"instructions": "You are a helpful weather agent."},
tools=[get_weather],
)
@@ -54,7 +55,7 @@ async def example_with_session_persistence() -> None:
"""Reuse session via thread object for multi-turn conversations."""
print("=== Session Persistence Example ===")
agent: GithubCopilotAgent[GithubCopilotOptions] = GithubCopilotAgent(
agent: GitHubCopilotAgent[GitHubCopilotOptions] = GitHubCopilotAgent(
default_options={"instructions": "You are a helpful weather agent."},
tools=[get_weather],
)
@@ -90,7 +91,7 @@ async def example_with_existing_session_id() -> None:
existing_session_id = None
# First agent instance - start a conversation
agent1: GithubCopilotAgent[GithubCopilotOptions] = GithubCopilotAgent(
agent1: GitHubCopilotAgent[GitHubCopilotOptions] = GitHubCopilotAgent(
default_options={"instructions": "You are a helpful weather agent."},
tools=[get_weather],
)
@@ -111,7 +112,7 @@ async def example_with_existing_session_id() -> None:
print("\n--- Continuing with the same session ID in a new agent instance ---")
# Second agent instance - resume the conversation
agent2: GithubCopilotAgent[GithubCopilotOptions] = GithubCopilotAgent(
agent2: GitHubCopilotAgent[GitHubCopilotOptions] = GitHubCopilotAgent(
default_options={"instructions": "You are a helpful weather agent."},
tools=[get_weather],
)
@@ -3,7 +3,7 @@
"""
GitHub Copilot Agent with Shell Permissions
This sample demonstrates how to enable shell command execution with GithubCopilotAgent.
This sample demonstrates how to enable shell command execution with GitHubCopilotAgent.
By providing a permission handler that approves "shell" requests, the agent can execute
shell commands to perform tasks like listing files, running scripts, or executing system commands.
@@ -13,7 +13,7 @@ Shell commands have full access to your system within the permissions of the run
import asyncio
from agent_framework.github import GithubCopilotAgent, GithubCopilotOptions
from agent_framework.github import GitHubCopilotAgent, GitHubCopilotOptions
from copilot.types import PermissionRequest, PermissionRequestResult
@@ -34,7 +34,7 @@ def prompt_permission(request: PermissionRequest, context: dict[str, str]) -> Pe
async def main() -> None:
print("=== GitHub Copilot Agent with Shell Permissions ===\n")
agent: GithubCopilotAgent[GithubCopilotOptions] = GithubCopilotAgent(
agent: GitHubCopilotAgent[GitHubCopilotOptions] = GitHubCopilotAgent(
default_options={
"instructions": "You are a helpful assistant that can execute shell commands.",
"on_permission_request": prompt_permission,
@@ -3,7 +3,7 @@
"""
GitHub Copilot Agent with URL Fetching
This sample demonstrates how to enable URL fetching with GithubCopilotAgent.
This sample demonstrates how to enable URL fetching with GitHubCopilotAgent.
By providing a permission handler that approves "url" requests, the agent can
fetch and process content from web URLs.
@@ -13,7 +13,7 @@ URL fetching allows the agent to access any URL accessible from your network.
import asyncio
from agent_framework.github import GithubCopilotAgent, GithubCopilotOptions
from agent_framework.github import GitHubCopilotAgent, GitHubCopilotOptions
from copilot.types import PermissionRequest, PermissionRequestResult
@@ -34,7 +34,7 @@ def prompt_permission(request: PermissionRequest, context: dict[str, str]) -> Pe
async def main() -> None:
print("=== GitHub Copilot Agent with URL Fetching ===\n")
agent: GithubCopilotAgent[GithubCopilotOptions] = GithubCopilotAgent(
agent: GitHubCopilotAgent[GitHubCopilotOptions] = GitHubCopilotAgent(
default_options={
"instructions": "You are a helpful assistant that can fetch and summarize web content.",
"on_permission_request": prompt_permission,
@@ -9,7 +9,7 @@ from agent_framework import tool
"""
This sample demonstrates how to expose an Agent as an MCP server.
To run this sample, set up your MCP host (like Claude Desktop or VSCode Github Copilot Agents)
To run this sample, set up your MCP host (like Claude Desktop or VSCode GitHub Copilot Agents)
with the following configuration:
```json
{