Skip to content

Fix Python Quick Start example to compile with current SDK#1310

Merged
stephentoub merged 1 commit into
mainfrom
stephentoub/fix-issue-1079
May 16, 2026
Merged

Fix Python Quick Start example to compile with current SDK#1310
stephentoub merged 1 commit into
mainfrom
stephentoub/fix-issue-1079

Conversation

@stephentoub
Copy link
Copy Markdown
Collaborator

The Quick Start snippet in python/README.md was the first thing a new user copy-pasted, and it failed immediately with:

TypeError: CopilotClient.create_session() missing 1 required keyword-only argument: 'on_permission_request'

CopilotClient.create_session declares on_permission_request as a required keyword-only parameter (no default), but the snippet called create_session(model="gpt-5") without it.

Fix

python/README.md only — no source changes.

  • Quick Start example: add from copilot.session import PermissionHandler and pass on_permission_request=PermissionHandler.approve_all.
  • API Reference example directly below: same one-line fix. PermissionHandler was already imported there, but the call still omitted the kwarg, so it would have failed the same way.

Kept model="gpt-5" instead of changing the model name — the bug was the missing permission handler, not the model, and "gpt-5" is what the rest of the README uses.

Validation

  • Both snippets pass python -m py_compile and ast.parse.
  • Both calls successfully inspect.signature.bind() against the real CopilotClient.create_session signature (no missing required kwargs, no unknown kwargs).
  • Reproduced the original TypeError against the unpatched snippet and confirmed the patched snippet no longer raises it.

Fixes #1079

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>
@stephentoub stephentoub requested a review from a team as a code owner May 16, 2026 18:34
Copilot AI review requested due to automatic review settings May 16, 2026 18:34
@stephentoub stephentoub merged commit 59f0981 into main May 16, 2026
15 checks passed
@stephentoub stephentoub deleted the stephentoub/fix-issue-1079 branch May 16, 2026 18:35
Copy link
Copy Markdown
Contributor

Copilot AI left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Pull request overview

This PR updates Python README examples so CopilotClient.create_session() includes the required permission handler argument.

Changes:

  • Imports PermissionHandler in the Quick Start snippet.
  • Passes on_permission_request=PermissionHandler.approve_all in two README create_session() examples.
Show a summary per file
File Description
python/README.md Updates Python documentation snippets to include the required permission handler argument.

Copilot's findings

  • Files reviewed: 1/1 changed files
  • Comments generated: 1

Comment thread python/README.md
Comment on lines +120 to +123
async with await client.create_session(
on_permission_request=PermissionHandler.approve_all,
model="gpt-5",
) as session:
@github-actions
Copy link
Copy Markdown
Contributor

Cross-SDK Consistency Review ✅

This PR only modifies python/README.md (documentation-only, no source changes), fixing two create_session() call sites that were missing the required on_permission_request kwarg.

Consistency check across other SDKs:

SDK Quick Start example Status
Node.js createSession({ model: "gpt-5", onPermissionRequest: approveAll }) ✅ Already correct
Go CreateSession(ctx, &copilot.SessionConfig{ OnPermissionRequest: ... }) ✅ Already correct
.NET CreateSessionAsync(new SessionConfig { OnPermissionRequest = ... }) ✅ Already correct
Python Fixed by this PR ✅ Now correct

The fix is accurate and necessary — Python enforces keyword-only arguments at runtime, so the missing on_permission_request parameter would have caused an immediate TypeError for any user copying the Quick Start snippet. No other SDK READMEs have the same critical defect in their Quick Start sections.

No cross-SDK consistency issues to flag. The change is approved from a consistency perspective.

Generated by SDK Consistency Review Agent for issue #1310 · ● 260.6K ·

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

The quick start Python example does not compile with Python SDK version 0.2.2

3 participants