Skip to content

Commit 04af977

Browse files
stephentoubCopilot
andauthored
Fix Python Quick Start example to compile with current SDK (#1310)
The Quick Start snippet in python/README.md called create_session(model=...) without the required keyword-only on_permission_request argument, so running it raised: TypeError: CopilotClient.create_session() missing 1 required keyword-only argument: 'on_permission_request'. Add the PermissionHandler import and pass on_permission_request=PermissionHandler.approve_all. Apply the same one-line fix to the API Reference snippet directly below, which had the identical bug. Fixes #1079 Co-authored-by: Copilot <223556219+Copilot@users.noreply.github.com>
1 parent 709fe4b commit 04af977

1 file changed

Lines changed: 9 additions & 2 deletions

File tree

python/README.md

Lines changed: 9 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -28,12 +28,16 @@ import asyncio
2828

2929
from copilot import CopilotClient
3030
from copilot.generated.session_events import AssistantMessageData, SessionIdleData
31+
from copilot.session import PermissionHandler
3132

3233
async def main():
3334
# Client automatically starts on enter and cleans up on exit
3435
async with CopilotClient() as client:
3536
# Create a session with automatic cleanup
36-
async with await client.create_session(model="gpt-5") as session:
37+
async with await client.create_session(
38+
on_permission_request=PermissionHandler.approve_all,
39+
model="gpt-5",
40+
) as session:
3741
# Wait for response using session.idle event
3842
done = asyncio.Event()
3943

@@ -113,7 +117,10 @@ from copilot import CopilotClient, SubprocessConfig
113117
from copilot.session import PermissionHandler
114118

115119
async with CopilotClient() as client:
116-
async with await client.create_session(model="gpt-5") as session:
120+
async with await client.create_session(
121+
on_permission_request=PermissionHandler.approve_all,
122+
model="gpt-5",
123+
) as session:
117124
def on_event(event):
118125
print(f"Event: {event.type}")
119126

0 commit comments

Comments
 (0)