Skip to content

Python: Forward provider config to SessionConfig in GitHubCopilotAgent (fixes…#5195

Open
Serjbory wants to merge 2 commits intomicrosoft:mainfrom
Serjbory:fix/issue_5190
Open

Python: Forward provider config to SessionConfig in GitHubCopilotAgent (fixes…#5195
Serjbory wants to merge 2 commits intomicrosoft:mainfrom
Serjbory:fix/issue_5190

Conversation

@Serjbory
Copy link
Copy Markdown

@Serjbory Serjbory commented Apr 9, 2026

Fixes #5190

Motivation and Context

GitHubCopilotAgent does not forward the provider field from default_options (or runtime options) to the Copilot SDK's SessionConfig / ResumeSessionConfig. This makes BYOK (Bring Your Own Key) and Azure Managed Identity authentication impossible through the Agent Framework wrapper, even though the underlying github-copilot-sdk fully supports ProviderConfig on both config types.

Description

Follow the established mcp_servers pattern to add provider passthrough:

  • Import ProviderConfig from copilot.types.
  • GitHubCopilotOptions TypedDict: Add provider: ProviderConfig field with docstring for discoverability and type safety.
  • __init__: Pop provider from the options dict and store it as self._provider (same as mcp_servers, on_permission_request, etc.), so it does not leak into _default_options.
  • _create_session: Resolve provider from runtime_options first, falling back to self._provider, and forward it to SessionConfig.
  • _resume_session: Forward self._provider to ResumeSessionConfig.
  • Tests: Add TestGitHubCopilotAgentProvider class with 7 tests covering:
    • Provider passed to create_session (Azure + bearer_token)
    • Provider passed to resume_session
    • Config excludes provider when not set (both create and resume)
    • Runtime provider takes precedence over default
    • Provider is popped from opts and not leaked into _default_options
    • Provider coexists with model, tools, and mcp_servers

Contribution Checklist

  • The code builds clean without any errors or warnings
  • The PR follows the Contribution Guidelines
  • All unit tests pass, and I have added new tests where possible
  • Is this a breaking change? If yes, add "[BREAKING]" prefix to the title of the PR. — No, this is a purely additive change.

@moonbox3 moonbox3 added the python label Apr 9, 2026
@github-actions github-actions bot changed the title Forward provider config to SessionConfig in GitHubCopilotAgent (fixes… Python: Forward provider config to SessionConfig in GitHubCopilotAgent (fixes… Apr 9, 2026
@eavanvalkenburg
Copy link
Copy Markdown
Member

@Serjbory please pull in the latest changes and make the updates!

@Serjbory
Copy link
Copy Markdown
Author

@Serjbory please pull in the latest changes and make the updates!

@eavanvalkenburg updates are done. Could you review it, please?

@moonbox3
Copy link
Copy Markdown
Contributor

Python Test Coverage

Python Test Coverage Report •
FileStmtsMissCoverMissing
packages/github_copilot/agent_framework_github_copilot
   _agent.py2681295%37–38, 44, 63, 370–371, 646–647, 662, 665, 732, 757
TOTAL27205318488% 

Python Unit Test Overview

Tests Skipped Failures Errors Time
5446 20 💤 0 ❌ 0 🔥 1m 29s ⏱️

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

Labels

Projects

None yet

Development

Successfully merging this pull request may close these issues.

Python: GitHubCopilotAgent does not forward provider config to SessionConfig, BYOK not working

3 participants