From 7605d9e0fc1f5944528ebeb9ee37eefb43cac4e1 Mon Sep 17 00:00:00 2001 From: Real Python Bot <42617967+realpython-bot@users.noreply.github.com> Date: Thu, 3 Dec 2026 12:39:26 +0000 Subject: [PATCH 1/3] Rename github-copilot-sdk to microsoft-copilot-sdk and update to SDK 2.0 The GitHub Copilot SDK was rebranded as the Microsoft Copilot SDK in v2.0.0, and github-copilot-sdk is deprecated on PyPI. Move the folder to match the tutorial's new slug, pin microsoft-copilot-sdk==2.0.6 and pydantic==2.14.4, and port all four scripts to the 2.x API (required mode, nested github, permissions, tools, and events options). Co-Authored-By: Claude Opus 5.5 --- github-copilot-sdk/README.md | 3 --- github-copilot-sdk/requirements.txt | 2 -- microsoft-copilot-sdk/README.md | 3 +++ .../ci_agent.py | 7 +++++-- .../hello_agent.py | 9 ++++++--- .../issue_agent.py | 11 +++++++---- .../project/shopping.py | 0 .../project/test_shopping.py | 0 .../refactor_agent.py | 9 ++++++--- microsoft-copilot-sdk/requirements.txt | 2 ++ .../tracker/issues.json | 0 11 files changed, 29 insertions(+), 17 deletions(-) delete mode 100644 github-copilot-sdk/README.md delete mode 100644 github-copilot-sdk/requirements.txt create mode 100644 microsoft-copilot-sdk/README.md rename {github-copilot-sdk => microsoft-copilot-sdk}/ci_agent.py (89%) rename {github-copilot-sdk => microsoft-copilot-sdk}/hello_agent.py (65%) rename {github-copilot-sdk => microsoft-copilot-sdk}/issue_agent.py (77%) rename {github-copilot-sdk => microsoft-copilot-sdk}/project/shopping.py (100%) rename {github-copilot-sdk => microsoft-copilot-sdk}/project/test_shopping.py (100%) rename {github-copilot-sdk => microsoft-copilot-sdk}/refactor_agent.py (85%) create mode 100644 microsoft-copilot-sdk/requirements.txt rename {github-copilot-sdk => microsoft-copilot-sdk}/tracker/issues.json (100%) diff --git a/github-copilot-sdk/README.md b/github-copilot-sdk/README.md deleted file mode 100644 index c8842ba90a..0000000000 --- a/github-copilot-sdk/README.md +++ /dev/null @@ -1,3 +0,0 @@ -# GitHub Copilot SDK: Put a Coding Agent in Your Python Code - -This folder provides the code examples for the Real Python tutorial [GitHub Copilot SDK: Put a Coding Agent in Your Python Code](https://realpython.com/github-copilot-sdk/) diff --git a/github-copilot-sdk/requirements.txt b/github-copilot-sdk/requirements.txt deleted file mode 100644 index 025c457ca8..0000000000 --- a/github-copilot-sdk/requirements.txt +++ /dev/null @@ -1,2 +0,0 @@ -github-copilot-sdk==1.0.26 -pydantic==2.14.1 diff --git a/microsoft-copilot-sdk/README.md b/microsoft-copilot-sdk/README.md new file mode 100644 index 0000000000..2e22e902d7 --- /dev/null +++ b/microsoft-copilot-sdk/README.md @@ -0,0 +1,3 @@ +# Microsoft Copilot SDK: Put a Coding Agent in Your Python App + +This folder provides the code examples for the Real Python tutorial [Microsoft Copilot SDK: Put a Coding Agent in Your Python App](https://realpython.com/microsoft-copilot-sdk/) diff --git a/github-copilot-sdk/ci_agent.py b/microsoft-copilot-sdk/ci_agent.py similarity index 89% rename from github-copilot-sdk/ci_agent.py rename to microsoft-copilot-sdk/ci_agent.py index 9ea2a1c223..aff89b50eb 100644 --- a/github-copilot-sdk/ci_agent.py +++ b/microsoft-copilot-sdk/ci_agent.py @@ -28,9 +28,12 @@ def policy(request, invocation): async def main() -> int: token = os.environ["COPILOT_GITHUB_TOKEN"] - async with CopilotClient(github_token=token) as client: + async with CopilotClient( + mode="coding-agent", + github={"token": token}, + ) as client: session = await client.create_session( - on_permission_request=policy, + permissions={"on_request": policy}, model="claude-haiku-5.5", ) reply = await session.send_and_wait( diff --git a/github-copilot-sdk/hello_agent.py b/microsoft-copilot-sdk/hello_agent.py similarity index 65% rename from github-copilot-sdk/hello_agent.py rename to microsoft-copilot-sdk/hello_agent.py index 8c3fb1a28c..86c940f591 100644 --- a/github-copilot-sdk/hello_agent.py +++ b/microsoft-copilot-sdk/hello_agent.py @@ -6,15 +6,18 @@ async def main(): token = os.environ["COPILOT_GITHUB_TOKEN"] - async with CopilotClient(github_token=token) as client: + async with CopilotClient( + mode="coding-agent", + github={"token": token}, + ) as client: session = await client.create_session( - on_permission_request=PermissionHandler.approve_all, + permissions={"on_request": PermissionHandler.approve_all}, model="claude-haiku-5.5", ) reply = await session.send_and_wait( "What is the walrus operator in Python? One sentence." ) - print(reply.data.content) + print(reply.data.content if reply else "No reply") await session.disconnect() diff --git a/github-copilot-sdk/issue_agent.py b/microsoft-copilot-sdk/issue_agent.py similarity index 77% rename from github-copilot-sdk/issue_agent.py rename to microsoft-copilot-sdk/issue_agent.py index ad08d17fa8..d1614a0c77 100644 --- a/github-copilot-sdk/issue_agent.py +++ b/microsoft-copilot-sdk/issue_agent.py @@ -27,16 +27,19 @@ async def list_issues(params: ListIssuesParams): async def main(): token = os.environ["COPILOT_GITHUB_TOKEN"] - async with CopilotClient(github_token=token) as client: + async with CopilotClient( + mode="coding-agent", + github={"token": token}, + ) as client: session = await client.create_session( - tools=[list_issues], - on_permission_request=PermissionHandler.approve_all, + tools={"definitions": [list_issues]}, + permissions={"on_request": PermissionHandler.approve_all}, model="claude-haiku-5.5", ) reply = await session.send_and_wait( "Which open bugs are assigned to Ana? Use the tracker tool." ) - print(reply.data.content) + print(reply.data.content if reply else "No reply") await session.disconnect() diff --git a/github-copilot-sdk/project/shopping.py b/microsoft-copilot-sdk/project/shopping.py similarity index 100% rename from github-copilot-sdk/project/shopping.py rename to microsoft-copilot-sdk/project/shopping.py diff --git a/github-copilot-sdk/project/test_shopping.py b/microsoft-copilot-sdk/project/test_shopping.py similarity index 100% rename from github-copilot-sdk/project/test_shopping.py rename to microsoft-copilot-sdk/project/test_shopping.py diff --git a/github-copilot-sdk/refactor_agent.py b/microsoft-copilot-sdk/refactor_agent.py similarity index 85% rename from github-copilot-sdk/refactor_agent.py rename to microsoft-copilot-sdk/refactor_agent.py index f274d62673..1525c52ae9 100644 --- a/github-copilot-sdk/refactor_agent.py +++ b/microsoft-copilot-sdk/refactor_agent.py @@ -27,11 +27,14 @@ async def main(): shutil.copytree(PROJECT, workdir) print(f"Working in {workdir}") token = os.environ["COPILOT_GITHUB_TOKEN"] - async with CopilotClient(github_token=token) as client: + async with CopilotClient( + mode="coding-agent", + github={"token": token}, + ) as client: session = await client.create_session( - streaming=True, + events={"streaming": True}, working_directory=str(workdir), - on_permission_request=PermissionHandler.approve_all, + permissions={"on_request": PermissionHandler.approve_all}, model="claude-haiku-5.5", ) session.on(on_event) diff --git a/microsoft-copilot-sdk/requirements.txt b/microsoft-copilot-sdk/requirements.txt new file mode 100644 index 0000000000..c17c59f0f6 --- /dev/null +++ b/microsoft-copilot-sdk/requirements.txt @@ -0,0 +1,2 @@ +microsoft-copilot-sdk==2.0.6 +pydantic==2.14.4 diff --git a/github-copilot-sdk/tracker/issues.json b/microsoft-copilot-sdk/tracker/issues.json similarity index 100% rename from github-copilot-sdk/tracker/issues.json rename to microsoft-copilot-sdk/tracker/issues.json From 00a260111abbffdfb946e1f7c4ff670a90cf8046 Mon Sep 17 00:00:00 2001 From: Real Python Bot <42617967+realpython-bot@users.noreply.github.com> Date: Thu, 3 Dec 2026 13:17:08 +0000 Subject: [PATCH 2/3] Rename microsoft-copilot-sdk folder to copilot-sdk Match the tutorial's brand-neutral slug, chosen after Ahrefs showed "copilot sdk" as the strongest current keyphrase. Co-Authored-By: Claude Opus 5.5 --- {microsoft-copilot-sdk => copilot-sdk}/README.md | 2 +- {microsoft-copilot-sdk => copilot-sdk}/ci_agent.py | 0 {microsoft-copilot-sdk => copilot-sdk}/hello_agent.py | 0 {microsoft-copilot-sdk => copilot-sdk}/issue_agent.py | 0 {microsoft-copilot-sdk => copilot-sdk}/project/shopping.py | 0 {microsoft-copilot-sdk => copilot-sdk}/project/test_shopping.py | 0 {microsoft-copilot-sdk => copilot-sdk}/refactor_agent.py | 0 {microsoft-copilot-sdk => copilot-sdk}/requirements.txt | 0 {microsoft-copilot-sdk => copilot-sdk}/tracker/issues.json | 0 9 files changed, 1 insertion(+), 1 deletion(-) rename {microsoft-copilot-sdk => copilot-sdk}/README.md (79%) rename {microsoft-copilot-sdk => copilot-sdk}/ci_agent.py (100%) rename {microsoft-copilot-sdk => copilot-sdk}/hello_agent.py (100%) rename {microsoft-copilot-sdk => copilot-sdk}/issue_agent.py (100%) rename {microsoft-copilot-sdk => copilot-sdk}/project/shopping.py (100%) rename {microsoft-copilot-sdk => copilot-sdk}/project/test_shopping.py (100%) rename {microsoft-copilot-sdk => copilot-sdk}/refactor_agent.py (100%) rename {microsoft-copilot-sdk => copilot-sdk}/requirements.txt (100%) rename {microsoft-copilot-sdk => copilot-sdk}/tracker/issues.json (100%) diff --git a/microsoft-copilot-sdk/README.md b/copilot-sdk/README.md similarity index 79% rename from microsoft-copilot-sdk/README.md rename to copilot-sdk/README.md index 2e22e902d7..462770f216 100644 --- a/microsoft-copilot-sdk/README.md +++ b/copilot-sdk/README.md @@ -1,3 +1,3 @@ # Microsoft Copilot SDK: Put a Coding Agent in Your Python App -This folder provides the code examples for the Real Python tutorial [Microsoft Copilot SDK: Put a Coding Agent in Your Python App](https://realpython.com/microsoft-copilot-sdk/) +This folder provides the code examples for the Real Python tutorial [Microsoft Copilot SDK: Put a Coding Agent in Your Python App](https://realpython.com/copilot-sdk/) diff --git a/microsoft-copilot-sdk/ci_agent.py b/copilot-sdk/ci_agent.py similarity index 100% rename from microsoft-copilot-sdk/ci_agent.py rename to copilot-sdk/ci_agent.py diff --git a/microsoft-copilot-sdk/hello_agent.py b/copilot-sdk/hello_agent.py similarity index 100% rename from microsoft-copilot-sdk/hello_agent.py rename to copilot-sdk/hello_agent.py diff --git a/microsoft-copilot-sdk/issue_agent.py b/copilot-sdk/issue_agent.py similarity index 100% rename from microsoft-copilot-sdk/issue_agent.py rename to copilot-sdk/issue_agent.py diff --git a/microsoft-copilot-sdk/project/shopping.py b/copilot-sdk/project/shopping.py similarity index 100% rename from microsoft-copilot-sdk/project/shopping.py rename to copilot-sdk/project/shopping.py diff --git a/microsoft-copilot-sdk/project/test_shopping.py b/copilot-sdk/project/test_shopping.py similarity index 100% rename from microsoft-copilot-sdk/project/test_shopping.py rename to copilot-sdk/project/test_shopping.py diff --git a/microsoft-copilot-sdk/refactor_agent.py b/copilot-sdk/refactor_agent.py similarity index 100% rename from microsoft-copilot-sdk/refactor_agent.py rename to copilot-sdk/refactor_agent.py diff --git a/microsoft-copilot-sdk/requirements.txt b/copilot-sdk/requirements.txt similarity index 100% rename from microsoft-copilot-sdk/requirements.txt rename to copilot-sdk/requirements.txt diff --git a/microsoft-copilot-sdk/tracker/issues.json b/copilot-sdk/tracker/issues.json similarity index 100% rename from microsoft-copilot-sdk/tracker/issues.json rename to copilot-sdk/tracker/issues.json From a53457b60863845bd4a5544dd96f156e2edd7f5e Mon Sep 17 00:00:00 2001 From: Real Python Bot <42617967+realpython-bot@users.noreply.github.com> Date: Thu, 3 Dec 2026 13:28:49 +0000 Subject: [PATCH 3/3] Update copilot-sdk README to the tutorial's new title Co-Authored-By: Claude Opus 5.5 --- copilot-sdk/README.md | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/copilot-sdk/README.md b/copilot-sdk/README.md index 462770f216..876899d644 100644 --- a/copilot-sdk/README.md +++ b/copilot-sdk/README.md @@ -1,3 +1,3 @@ -# Microsoft Copilot SDK: Put a Coding Agent in Your Python App +# Copilot SDK: Put a Coding Agent in Your Python Code -This folder provides the code examples for the Real Python tutorial [Microsoft Copilot SDK: Put a Coding Agent in Your Python App](https://realpython.com/copilot-sdk/) +This folder provides the code examples for the Real Python tutorial [Copilot SDK: Put a Coding Agent in Your Python Code](https://realpython.com/copilot-sdk/)