Skip to content

.NET: Add GitHub Copilot BYOK sample - #7337

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

.NET: Add GitHub Copilot BYOK sample#7337
droideronline wants to merge 8 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>
…ith_GitHubCopilot_BYOK/README.md

Co-authored-by: Roger Barreto <19890735+rogerbarreto@users.noreply.github.com>
…ith_GitHubCopilot_BYOK/README.md

Co-authored-by: Roger Barreto <19890735+rogerbarreto@users.noreply.github.com>
Comment thread dotnet/samples/02-agents/AgentProviders/README.md Outdated
- Make the provider type configurable via BYOK_PROVIDER_TYPE (default "openai") instead
  of hardcoding "openai", since the sample already documents Azure/Anthropic support.
- Stop calling the endpoint "OpenAI-compatible" everywhere; Anthropic isn't OpenAI-wire-
  compatible, so reword to "your own endpoint" and list the actual supported providers.
- Move the "About BYOK" explainer to the top of the README so the term is introduced
  before it's used, and finish applying the WireApi/ModelId comment suggestions.
- Reword the AgentProviders/README.md entry to match (not OpenAI-specific).
@droideronline

Copy link
Copy Markdown
Contributor Author

Thanks for the review, @rogerbarreto! All the feedback is addressed:

  • Provider type is now configurable via BYOK_PROVIDER_TYPE (default openai) instead of being hardcoded, since the sample already documents Azure/Anthropic support.
  • Dropped the "OpenAI-compatible" wording everywhere it incorrectly implied Anthropic — reworded to "your own endpoint" (README, sample header comment, and the AgentProviders/README.md entry).
  • Moved the "About BYOK" explainer to the top of the README so the term is introduced before it's used.
  • Finished applying the WireApi/ModelId comment suggestions.

Mirrored the same fixes into the Python sample (#7336) for consistency.

Please take another look when you get a chance. Thanks!

The repo's .editorconfig requires utf-8-bom for .cs files; check-format was
failing because the new file was written without one.
auto-merge was automatically disabled July 27, 2026 17:35

Head branch was pushed to by a user without write access

@rogerbarreto
rogerbarreto added this pull request to the merge queue Jul 27, 2026
@github-merge-queue
github-merge-queue Bot removed this pull request from the merge queue due to failed status checks Jul 27, 2026
@rogerbarreto
rogerbarreto added this pull request to the merge queue Jul 27, 2026
@github-merge-queue
github-merge-queue Bot removed this pull request from the merge queue due to failed status checks Jul 27, 2026
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.

4 participants