Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
3 changes: 3 additions & 0 deletions copilot-sdk/README.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
# Copilot SDK: Put a Coding Agent in Your Python Code

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/)
7 changes: 5 additions & 2 deletions github-copilot-sdk/ci_agent.py → copilot-sdk/ci_agent.py
Original file line number Diff line number Diff line change
Expand Up @@ -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(
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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()


Expand Down
11 changes: 7 additions & 4 deletions github-copilot-sdk/issue_agent.py → copilot-sdk/issue_agent.py
Original file line number Diff line number Diff line change
Expand Up @@ -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()


Expand Down
File renamed without changes.
Original file line number Diff line number Diff line change
Expand Up @@ -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)
Expand Down
2 changes: 2 additions & 0 deletions copilot-sdk/requirements.txt
Original file line number Diff line number Diff line change
@@ -0,0 +1,2 @@
microsoft-copilot-sdk==2.0.6
pydantic==2.14.4
File renamed without changes.
3 changes: 0 additions & 3 deletions github-copilot-sdk/README.md

This file was deleted.

2 changes: 0 additions & 2 deletions github-copilot-sdk/requirements.txt

This file was deleted.

Loading