Skip to content

Conversation

Copy link
Contributor

Copilot AI commented Jan 22, 2026

Motivation and Context

Adds support for GitHub Copilot SDK as an agent provider, enabling agentic capabilities through the Copilot platform.

Description

New Project: Microsoft.Agents.AI.GithubCopilot

Implements GithubCopilotAgent following the established A2AAgent/CopilotStudioAgent pattern:

  • Wraps GitHub Copilot SDK's CopilotClient and CopilotSession
  • Supports both sync (RunAsync) and streaming (RunStreamingAsync) operations with real-time update delivery via channels
  • GithubCopilotAgentThread manages conversation sessions via session IDs (internal constructor and setter for proper encapsulation)
  • Implements IAsyncDisposable with optional client ownership via ownsClient parameter (defaults to false), allowing callers to control whether the agent disposes the CopilotClient
  • Provides AsAIAgent extension methods on CopilotClient for easy AIAgent creation (similar to A2AClientExtensions and AnthropicClientExtensions)
  • AOT-compatible via source-generated JSON serialization

Target Framework Constraint

Only targets .NET 8.0+ (TargetFrameworksCore) - GitHub.Copilot.SDK doesn't support netstandard2.0 or net472.

Usage Example

using GitHub.Copilot.SDK;
using Microsoft.Agents.AI;
using Microsoft.Agents.AI.GithubCopilot;

// Create and start a Copilot client
CopilotClient copilotClient = new(new CopilotClientOptions { AutoStart = true });
await copilotClient.StartAsync();

// Create an AIAgent using the extension method
AIAgent agent = copilotClient.AsAIAgent();

// Or with explicit ownership control
AIAgent agent = copilotClient.AsAIAgent(ownsClient: true);

// Ask Copilot to write code for us
AgentResponse response = await agent.RunAsync("Write a small .NET 10 C# hello world single file application");
Console.WriteLine(response);

Additional Changes

  • Added GitHub.Copilot.SDK v0.1.10 to central package management
  • Created sample in samples/GettingStarted/AgentProviders/Agent_With_GithubCopilot demonstrating code generation capabilities
  • Sample includes container safety warning (recommended to run in containerized environment)
  • Sample and README updated to use AsAIAgent extension method
  • 14 unit tests in Microsoft.Agents.AI.GithubCopilot.UnitTests (including 4 tests for extension methods)
  • Updated solution file and AgentProviders README

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.
Original prompt

This section details on the original issue you should resolve

<issue_title>.NET: Add AIAgent implementation for Github Copilot SDK</issue_title>
<issue_description>There is a new Github Copilot SDK:
https://github.com/github/copilot-sdk

It has a list of usage linked from this page:
https://github.com/github/copilot-sdk/blob/main/cookbook/dotnet/README.md

We should add a new .net project Microsoft.Agents.AI.GithubCopilot. This project should provide an AIAgent implementation that uses the copilot sdk to provide copilot agentic capabilities.

The implementation should follow a similar design to A2AAgent, CopilotStudioAgent and ChatClientAgent.

All the new capabilities should have unit tests associated and a sample in Samples/GettingStarted/AgentProviders.</issue_description>

Comments on the Issue (you are @copilot in this section)


💬 We'd love your input! Share your thoughts on Copilot coding agent in our 2 minute survey.

@stephentoub
Copy link
Member

@westey-m I was talking with @SteveSanderson earlier today about doing exactly this. :)

Copilot AI and others added 3 commits January 22, 2026 21:10
Co-authored-by: westey-m <164392973+westey-m@users.noreply.github.com>
Co-authored-by: westey-m <164392973+westey-m@users.noreply.github.com>
Co-authored-by: westey-m <164392973+westey-m@users.noreply.github.com>
Copilot AI changed the title [WIP] Add AIAgent implementation for Github Copilot SDK .NET: Add AIAgent implementation for GitHub Copilot SDK Jan 22, 2026
Copilot AI requested a review from westey-m January 22, 2026 21:23
@markwallace-microsoft markwallace-microsoft added documentation Improvements or additions to documentation .NET labels Jan 23, 2026
switch (evt)
{
case AssistantMessageDeltaEvent deltaEvent:
updates.Add(ConvertToAgentResponseUpdate(deltaEvent));
Copy link
Contributor

Choose a reason for hiding this comment

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

@copilot, can't we yield updates here as soon as we receive them instead of waiting till the end?

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Done in 44f3ab6. Changed to use a channel to yield updates as they arrive instead of collecting them.

…tOptions ctor, streaming improvements, better sample, container warning

Co-authored-by: westey-m <164392973+westey-m@users.noreply.github.com>
Copilot AI requested a review from westey-m January 23, 2026 09:42
Co-authored-by: westey-m <164392973+westey-m@users.noreply.github.com>
Co-authored-by: westey-m <164392973+westey-m@users.noreply.github.com>
Copy link
Contributor Author

Copilot AI commented Jan 23, 2026

@copilot, dotnet-format is failing with the following error. Please address.

...

Fixed in b45d14a. Added UTF-8 BOM to Program.cs to match repository encoding standards.

@westey-m
Copy link
Contributor

@copilot, I'm receiving some additional dotnet-format errors now, please fix.

/app/dotnet/src/Microsoft.Agents.AI.GithubCopilot/GithubCopilotAgent.cs(1,1): error CHARSET: Fix file encoding. [/app/dotnet/src/Microsoft.Agents.AI.GithubCopilot/Microsoft.Agents.AI.GithubCopilot.csproj]
/app/dotnet/src/Microsoft.Agents.AI.GithubCopilot/GithubCopilotAgentThread.cs(1,1): error CHARSET: Fix file encoding. [/app/dotnet/src/Microsoft.Agents.AI.GithubCopilot/Microsoft.Agents.AI.GithubCopilot.csproj]
/app/dotnet/src/Microsoft.Agents.AI.GithubCopilot/GithubCopilotJsonUtilities.cs(1,1): error CHARSET: Fix file encoding. [/app/dotnet/src/Microsoft.Agents.AI.GithubCopilot/Microsoft.Agents.AI.GithubCopilot.csproj]
/app/dotnet/src/Microsoft.Agents.AI.GithubCopilot/GithubCopilotAgent.cs(124,46): error IDE0009: Add 'this' or 'Me' qualification [/app/dotnet/src/Microsoft.Agents.AI.GithubCopilot/Microsoft.Agents.AI.GithubCopilot.csproj]
/app/dotnet/src/Microsoft.Agents.AI.GithubCopilot/GithubCopilotAgent.cs(28,30): error IDE0052: Private member 'GithubCopilotAgent._logger' can be removed as the value assigned to it is never read [/app/dotnet/src/Microsoft.Agents.AI.GithubCopilot/Microsoft.Agents.AI.GithubCopilot.csproj]
/app/dotnet/src/Microsoft.Agents.AI.GithubCopilot/GithubCopilotAgentThread.cs(3,1): error IDE0005: Using directive is unnecessary. [/app/dotnet/src/Microsoft.Agents.AI.GithubCopilot/Microsoft.Agents.AI.GithubCopilot.csproj]
/app/dotnet/src/Microsoft.Agents.AI.GithubCopilot/GithubCopilotAgentThread.cs(5,1): error IDE0005: Using directive is unnecessary. [/app/dotnet/src/Microsoft.Agents.AI.GithubCopilot/Microsoft.Agents.AI.GithubCopilot.csproj]
/app/dotnet/src/Microsoft.Agents.AI.GithubCopilot/GithubCopilotJsonUtilities.cs(7,1): error IDE0005: Using directive is unnecessary. [/app/dotnet/src/Microsoft.Agents.AI.GithubCopilot/Microsoft.Agents.AI.GithubCopilot.csproj]
/app/dotnet/src/Microsoft.Agents.AI.GithubCopilot/GithubCopilotAgent.cs(124,46): error IDE0009: Add 'this' or 'Me' qualification [/app/dotnet/src/Microsoft.Agents.AI.GithubCopilot/Microsoft.Agents.AI.GithubCopilot.csproj]
/app/dotnet/src/Microsoft.Agents.AI.GithubCopilot/GithubCopilotAgent.cs(28,30): error IDE0052: Private member 'GithubCopilotAgent._logger' can be removed as the value assigned to it is never read [/app/dotnet/src/Microsoft.Agents.AI.GithubCopilot/Microsoft.Agents.AI.GithubCopilot.csproj]
/app/dotnet/src/Microsoft.Agents.AI.GithubCopilot/GithubCopilotAgentThread.cs(3,1): error IDE0005: Using directive is unnecessary. [/app/dotnet/src/Microsoft.Agents.AI.GithubCopilot/Microsoft.Agents.AI.GithubCopilot.csproj]
/app/dotnet/src/Microsoft.Agents.AI.GithubCopilot/GithubCopilotAgentThread.cs(5,1): error IDE0005: Using directive is unnecessary. [/app/dotnet/src/Microsoft.Agents.AI.GithubCopilot/Microsoft.Agents.AI.GithubCopilot.csproj]
/app/dotnet/src/Microsoft.Agents.AI.GithubCopilot/GithubCopilotJsonUtilities.cs(7,1): error IDE0005: Using directive is unnecessary. [/app/dotnet/src/Microsoft.Agents.AI.GithubCopilot/Microsoft.Agents.AI.GithubCopilot.csproj]
/app/dotnet/src/Microsoft.Agents.AI.GithubCopilot/GithubCopilotAgent.cs(124,46): error IDE0009: Add 'this' or 'Me' qualification [/app/dotnet/src/Microsoft.Agents.AI.GithubCopilot/Microsoft.Agents.AI.GithubCopilot.csproj]
/app/dotnet/src/Microsoft.Agents.AI.GithubCopilot/GithubCopilotAgent.cs(28,30): error IDE0052: Private member 'GithubCopilotAgent._logger' can be removed as the value assigned to it is never read [/app/dotnet/src/Microsoft.Agents.AI.GithubCopilot/Microsoft.Agents.AI.GithubCopilot.csproj]
/app/dotnet/src/Microsoft.Agents.AI.GithubCopilot/GithubCopilotAgentThread.cs(3,1): error IDE0005: Using directive is unnecessary. [/app/dotnet/src/Microsoft.Agents.AI.GithubCopilot/Microsoft.Agents.AI.GithubCopilot.csproj]
/app/dotnet/src/Microsoft.Agents.AI.GithubCopilot/GithubCopilotAgentThread.cs(5,1): error IDE0005: Using directive is unnecessary. [/app/dotnet/src/Microsoft.Agents.AI.GithubCopilot/Microsoft.Agents.AI.GithubCopilot.csproj]
/app/dotnet/src/Microsoft.Agents.AI.GithubCopilot/GithubCopilotJsonUtilities.cs(7,1): error IDE0005: Using directive is unnecessary. [/app/dotnet/src/Microsoft.Agents.AI.GithubCopilot/Microsoft.Agents.AI.GithubCopilot.csproj]

…ualifier, remove unnecessary usings

Co-authored-by: westey-m <164392973+westey-m@users.noreply.github.com>
Copy link
Contributor Author

Copilot AI commented Jan 23, 2026

@copilot, I'm receiving some additional dotnet-format errors now, please fix.

...

Fixed in c3f94cb. Added UTF-8 BOM to all source files, removed unused _logger field, added this. qualification, and removed unnecessary using directives.

@westey-m
Copy link
Contributor

@copilot, here are some more dotnet-format errors to fix:

/app/dotnet/tests/Microsoft.Agents.AI.GithubCopilot.UnitTests/GithubCopilotAgentTests.cs(1,1): error CHARSET: Fix file encoding. [/app/dotnet/tests/Microsoft.Agents.AI.GithubCopilot.UnitTests/Microsoft.Agents.AI.GithubCopilot.UnitTests.csproj]
/app/dotnet/tests/Microsoft.Agents.AI.GithubCopilot.UnitTests/GithubCopilotAgentThreadTests.cs(1,1): error CHARSET: Fix file encoding. [/app/dotnet/tests/Microsoft.Agents.AI.GithubCopilot.UnitTests/Microsoft.Agents.AI.GithubCopilot.UnitTests.csproj]
/app/dotnet/tests/Microsoft.Agents.AI.GithubCopilot.UnitTests/GithubCopilotAgentTests.cs(36,75): error IDE0004: Cast is redundant. [/app/dotnet/tests/Microsoft.Agents.AI.GithubCopilot.UnitTests/Microsoft.Agents.AI.GithubCopilot.UnitTests.csproj]
/app/dotnet/tests/Microsoft.Agents.AI.GithubCopilot.UnitTests/GithubCopilotAgentThreadTests.cs(3,1): error IDE0005: Using directive is unnecessary. [/app/dotnet/tests/Microsoft.Agents.AI.GithubCopilot.UnitTests/Microsoft.Agents.AI.GithubCopilot.UnitTests.csproj]
/app/dotnet/tests/Microsoft.Agents.AI.GithubCopilot.UnitTests/GithubCopilotAgentTests.cs(36,75): error IDE0004: Cast is redundant. [/app/dotnet/tests/Microsoft.Agents.AI.GithubCopilot.UnitTests/Microsoft.Agents.AI.GithubCopilot.UnitTests.csproj]
/app/dotnet/tests/Microsoft.Agents.AI.GithubCopilot.UnitTests/GithubCopilotAgentThreadTests.cs(3,1): error IDE0005: Using directive is unnecessary. [/app/dotnet/tests/Microsoft.Agents.AI.GithubCopilot.UnitTests/Microsoft.Agents.AI.GithubCopilot.UnitTests.csproj]
/app/dotnet/tests/Microsoft.Agents.AI.GithubCopilot.UnitTests/GithubCopilotAgentTests.cs(36,75): error IDE0004: Cast is redundant. [/app/dotnet/tests/Microsoft.Agents.AI.GithubCopilot.UnitTests/Microsoft.Agents.AI.GithubCopilot.UnitTests.csproj]
/app/dotnet/tests/Microsoft.Agents.AI.GithubCopilot.UnitTests/GithubCopilotAgentThreadTests.cs(3,1): error IDE0005: Using directive is unnecessary. [/app/dotnet/tests/Microsoft.Agents.AI.GithubCopilot.UnitTests/Microsoft.Agents.AI.GithubCopilot.UnitTests.csproj]

Co-authored-by: westey-m <164392973+westey-m@users.noreply.github.com>
Copy link
Contributor Author

Copilot AI commented Jan 23, 2026

@copilot, here are some more dotnet-format errors to fix:

/app/dotnet/tests/Microsoft.Agents.AI.GithubCopilot.UnitTests/GithubCopilotAgentTests.cs(1,1): error CHARSET: Fix file encoding. [/app/d...

Fixed in 97f4457. Added UTF-8 BOM to test files, removed redundant cast, and removed unnecessary using directive.

@westey-m
Copy link
Contributor

@copilot, similar to other agents, we should have AsAIAgent extension methods on CopilotClient that allows us to easily create an AIAgent when we already have a CopilotClient.
See e.g. A2AClientExtensions and AnthropicClientExtensions.

Also make sure to add tests for the new code added.

Co-authored-by: westey-m <164392973+westey-m@users.noreply.github.com>
Copy link
Contributor Author

Copilot AI commented Jan 23, 2026

@copilot, similar to other agents, we should have AsAIAgent extension methods on CopilotClient that allows us to easily create an AIAgent when we already have a CopilotClient.
See e.g. A2AClientE...

Done in a5b7aeb. Added CopilotClientExtensions with AsAIAgent extension methods following the A2AClientExtensions pattern, along with 4 unit tests. Updated sample and README to use the extension method.

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

Labels

documentation Improvements or additions to documentation .NET

Projects

None yet

Development

Successfully merging this pull request may close these issues.

.NET: Add AIAgent implementation for Github Copilot SDK

5 participants