Skip to content

.NET: Add GitHub Copilot BYOK sample#7337

Open
droideronline wants to merge 2 commits into
microsoft:mainfrom
droideronline:sample/github-copilot-byok-dotnet
Open

.NET: Add GitHub Copilot BYOK sample#7337
droideronline wants to merge 2 commits into
microsoft:mainfrom
droideronline:sample/github-copilot-byok-dotnet

Conversation

@droideronline

Copy link
Copy Markdown
Contributor

Motivation & Context

GitHub Copilot supports BYOK (Bring Your Own Key — https://docs.github.com/en/copilot/how-tos/copilot-sdk/auth/byok), letting requests be routed through a custom OpenAI/Azure/Anthropic-compatible endpoint instead of the default GitHub Copilot backend. SessionConfig.Provider is already passed straight through by GitHubCopilotAgent (see CopyResumeSessionConfig), but there was no sample demonstrating the scenario end-to-end.

Description & Review Guide

  • What are the major changes? Adds a new Agent_With_GitHubCopilot_BYOK sample project under dotnet/samples/02-agents/AgentProviders/github-copilot/, showing how to set SessionConfig { Model, Provider = new ProviderConfig { Type, WireApi, BaseUrl, ApiKey, ModelId } } to route through a custom endpoint, reading BYOK_BASE_URL/BYOK_API_KEY/BYOK_MODEL_ID from the environment. Wires the project into agent-framework-dotnet.slnx, adds a row to AgentProviders/README.md, and registers a SampleDefinition in eng/verify-samples/AgentsSamples.cs (skipped automatically when the required env vars are unset).
  • What is the impact of these changes? Documentation/sample only — no changes to library code.
  • What do you want reviewers to focus on? Whether the ProviderConfig properties used match current guidance.
  • Note: I could not build locally because this repo pins the .NET 10 SDK and only .NET 8 was available in my environment. I instead verified every type, property, and namespace used (ProviderConfig, SessionConfig.Provider, SessionConfig.Model) against the github/copilot-sdk source at tag v1.0.5, which matches the version pinned in Directory.Packages.props. Please run a build/CI pass to confirm.

Related Issue

Fixes #

Contribution Checklist

  • The code builds clean without any errors or warnings
  • All unit tests pass, and I have added new tests where possible
  • The PR follows the Contribution Guidelines
  • This PR is linked to an issue and there is no other open PR for this issue (see Related Issue above).
  • This is not a breaking change.

Demonstrates routing GitHubCopilotAgent requests through a custom OpenAI-compatible
endpoint via SessionConfig.Provider instead of the default GitHub Copilot backend.
Copilot AI review requested due to automatic review settings July 26, 2026 17:49
@agent-framework-automation agent-framework-automation Bot added documentation Usage: [Issues, PRs], Target: documentation in the code base and learn docs .NET Usage: [Issues, PRs], Target: .Net labels Jul 26, 2026

Copilot AI left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

Pull request overview

Adds a new .NET sample demonstrating GitHub Copilot SDK BYOK (Bring Your Own Key) usage via SessionConfig.Provider, so developers can route agent requests through their own OpenAI-compatible endpoint rather than the default GitHub Copilot backend.

Changes:

  • Added a new Agent_With_GitHubCopilot_BYOK sample (README + runnable Program.cs) that reads BYOK_BASE_URL / BYOK_API_KEY / BYOK_MODEL_ID and configures ProviderConfig.
  • Registered the sample in the .NET solution (agent-framework-dotnet.slnx) and in the sample verifier (eng/verify-samples/AgentsSamples.cs) with env-var gating.
  • Documented the sample in dotnet/samples/02-agents/AgentProviders/README.md.

Reviewed changes

Copilot reviewed 6 out of 6 changed files in this pull request and generated 1 comment.

Show a summary per file
File Description
dotnet/samples/02-agents/AgentProviders/README.md Adds the BYOK sample entry to the AgentProviders index.
dotnet/samples/02-agents/AgentProviders/github-copilot/Agent_With_GitHubCopilot_BYOK/README.md Documents how to run/configure the BYOK Copilot provider sample.
dotnet/samples/02-agents/AgentProviders/github-copilot/Agent_With_GitHubCopilot_BYOK/Program.cs Implements the BYOK session/provider configuration and streaming run loop.
dotnet/samples/02-agents/AgentProviders/github-copilot/Agent_With_GitHubCopilot_BYOK/Agent_With_GitHubCopilot_BYOK.csproj Adds the new sample project referencing Copilot SDK + AF Copilot adapter project.
dotnet/eng/verify-samples/AgentsSamples.cs Registers the new sample for verification with required/optional env vars.
dotnet/agent-framework-dotnet.slnx Includes the new sample project in the solution.

Co-authored-by: Copilot Autofix powered by AI <175728472+Copilot@users.noreply.github.com>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

documentation Usage: [Issues, PRs], Target: documentation in the code base and learn docs .NET Usage: [Issues, PRs], Target: .Net

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants