Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
41 commits
Select commit Hold shift + click to select a range
4c55bd9
Initial plan
Copilot Jan 22, 2026
5a39df4
Add GitHub Copilot SDK AIAgent implementation with tests
Copilot Jan 22, 2026
9178095
Add projects to solution and fix sample imports
Copilot Jan 22, 2026
b365707
Improve pragma comment clarity in GithubCopilotAgentThread
Copilot Jan 22, 2026
44f3ab6
Address PR feedback: internal constructor/setter, remove CopilotClien…
Copilot Jan 23, 2026
09d526f
Merge branch 'main' into copilot/add-aiagent-implementation
westey-m Jan 23, 2026
52ba627
Add ownsClient parameter to allow caller control over client disposal
Copilot Jan 23, 2026
c348e7d
Fix unit tests by removing await using to avoid StreamJsonRpc disposa…
Copilot Jan 23, 2026
b45d14a
Fix file encoding: add UTF-8 BOM to Program.cs
Copilot Jan 23, 2026
c3f94cb
Fix dotnet-format errors: UTF-8 BOM, remove unused logger, add this q…
Copilot Jan 23, 2026
97f4457
Fix test file encoding and remove redundant cast
Copilot Jan 23, 2026
4ae34d3
Merge branch 'main' into copilot/add-aiagent-implementation
westey-m Jan 23, 2026
a5b7aeb
Add AsAIAgent extension methods for CopilotClient with tests
Copilot Jan 23, 2026
02e6c0e
Merge branch 'main' into copilot/add-aiagent-implementation
dmytrostruk Jan 23, 2026
c643abc
Remove IL suppressions, use TryComplete for channel writer, remove TC…
Copilot Jan 25, 2026
7f82795
Keep session alive across calls, add tools overload, add tests
Copilot Jan 25, 2026
4d781b8
Revert session persistence changes - sessions dispose after each call
Copilot Jan 25, 2026
8501a5d
Add CreatedAt property mapping using DateTimeOffset.UtcNow
Copilot Jan 25, 2026
a8dd828
Add DataContent handling via temp files and attachments
Copilot Jan 25, 2026
e28bb5e
Fix formatting: remove extra indentation, simplify Path references, r…
Copilot Jan 25, 2026
6836ca1
Refactor: extract helper methods to reduce duplication in DataContent…
Copilot Jan 25, 2026
9172cac
Merge branch 'main' into copilot/add-aiagent-implementation
dmytrostruk Jan 26, 2026
67d7b11
Updated sample and session config mapping
dmytrostruk Jan 26, 2026
efef054
Added instructions parameter
dmytrostruk Jan 26, 2026
7c9d36c
Updated README
dmytrostruk Jan 26, 2026
5b07a21
Address PR feedback: reorder params, optimize dictionary, update pref…
Copilot Jan 26, 2026
8ec23a1
Remove StreamJsonRpc reference from sample project
Copilot Jan 26, 2026
251ad7c
Fix parameter ordering: tools now after description, rename to s_medi…
Copilot Jan 26, 2026
ced7299
Fix streaming prompt: change Python to C# for Fibonacci example
Copilot Jan 26, 2026
396d0aa
Handle all SDK events, add UsageContent support, fix model name, remo…
Copilot Jan 26, 2026
105ce0b
Merge branch 'main' into copilot/add-aiagent-implementation
dmytrostruk Jan 26, 2026
1a38887
Merge branch 'main' into copilot/add-aiagent-implementation
dmytrostruk Jan 26, 2026
77b50d7
Resolved build errors
dmytrostruk Jan 26, 2026
9cb4c1f
Addressed comments
dmytrostruk Jan 26, 2026
6e36901
Small fix
dmytrostruk Jan 26, 2026
493536b
Addressed comment
dmytrostruk Jan 26, 2026
50f7c47
Small fix
dmytrostruk Jan 26, 2026
0ae50a6
Addressed comments
dmytrostruk Jan 26, 2026
c9b4753
Added integration tests
dmytrostruk Jan 27, 2026
6ccde66
Small update
dmytrostruk Jan 27, 2026
6803d49
Merge branch 'main' into copilot/add-aiagent-implementation
dmytrostruk Jan 27, 2026
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
1 change: 1 addition & 0 deletions dotnet/Directory.Packages.props
Original file line number Diff line number Diff line change
Expand Up @@ -89,6 +89,7 @@
<PackageVersion Include="Microsoft.SemanticKernel.Agents.AzureAI" Version="1.67.0-preview" />
<PackageVersion Include="Microsoft.SemanticKernel.Plugins.OpenApi" Version="1.67.0" />
<!-- Agent SDKs -->
<PackageVersion Include="GitHub.Copilot.SDK" Version="0.1.18" />
<PackageVersion Include="Microsoft.Agents.CopilotStudio.Client" Version="1.3.171-beta" />
<!-- M365 Agents SDK -->
<PackageVersion Include="AdaptiveCards" Version="3.1.0" />
Expand Down
4 changes: 4 additions & 0 deletions dotnet/agent-framework-dotnet.slnx
Original file line number Diff line number Diff line change
Expand Up @@ -65,6 +65,7 @@
<Project Path="samples/GettingStarted/AgentProviders/Agent_With_AzureOpenAIChatCompletion/Agent_With_AzureOpenAIChatCompletion.csproj" />
<Project Path="samples/GettingStarted/AgentProviders/Agent_With_AzureOpenAIResponses/Agent_With_AzureOpenAIResponses.csproj" />
<Project Path="samples/GettingStarted/AgentProviders/Agent_With_CustomImplementation/Agent_With_CustomImplementation.csproj" />
<Project Path="samples/GettingStarted/AgentProviders/Agent_With_GithubCopilot/Agent_With_GithubCopilot.csproj" />
<Project Path="samples/GettingStarted/AgentProviders/Agent_With_GoogleGemini/Agent_With_GoogleGemini.csproj" />
<Project Path="samples/GettingStarted/AgentProviders/Agent_With_Ollama/Agent_With_Ollama.csproj" />
<Project Path="samples/GettingStarted/AgentProviders/Agent_With_ONNX/Agent_With_ONNX.csproj" />
Expand Down Expand Up @@ -395,6 +396,7 @@
<Project Path="src/Microsoft.Agents.AI.Abstractions/Microsoft.Agents.AI.Abstractions.csproj" />
<Project Path="src/Microsoft.Agents.AI.AGUI/Microsoft.Agents.AI.AGUI.csproj" />
<Project Path="src/Microsoft.Agents.AI.Anthropic/Microsoft.Agents.AI.Anthropic.csproj" />
<Project Path="src/Microsoft.Agents.AI.GithubCopilot/Microsoft.Agents.AI.GithubCopilot.csproj" />
<Project Path="src/Microsoft.Agents.AI.AzureAI.Persistent/Microsoft.Agents.AI.AzureAI.Persistent.csproj" />
<Project Path="src/Microsoft.Agents.AI.AzureAI/Microsoft.Agents.AI.AzureAI.csproj" />
<Project Path="src/Microsoft.Agents.AI.CopilotStudio/Microsoft.Agents.AI.CopilotStudio.csproj" />
Expand Down Expand Up @@ -424,6 +426,7 @@
<Project Path="tests/AzureAI.IntegrationTests/AzureAI.IntegrationTests.csproj" />
<Project Path="tests/AzureAIAgentsPersistent.IntegrationTests/AzureAIAgentsPersistent.IntegrationTests.csproj" />
<Project Path="tests/CopilotStudio.IntegrationTests/CopilotStudio.IntegrationTests.csproj" />
<Project Path="tests/Microsoft.Agents.AI.GithubCopilot.IntegrationTests/Microsoft.Agents.AI.GithubCopilot.IntegrationTests.csproj" />
<Project Path="tests/Microsoft.Agents.AI.DurableTask.IntegrationTests/Microsoft.Agents.AI.DurableTask.IntegrationTests.csproj" />
<Project Path="tests/Microsoft.Agents.AI.Hosting.AGUI.AspNetCore.IntegrationTests/Microsoft.Agents.AI.Hosting.AGUI.AspNetCore.IntegrationTests.csproj" />
<Project Path="tests/Microsoft.Agents.AI.Hosting.AzureFunctions.IntegrationTests/Microsoft.Agents.AI.Hosting.AzureFunctions.IntegrationTests.csproj" />
Expand All @@ -438,6 +441,7 @@
<Project Path="tests/Microsoft.Agents.AI.Abstractions.UnitTests/Microsoft.Agents.AI.Abstractions.UnitTests.csproj" />
<Project Path="tests/Microsoft.Agents.AI.AGUI.UnitTests/Microsoft.Agents.AI.AGUI.UnitTests.csproj" />
<Project Path="tests/Microsoft.Agents.AI.Anthropic.UnitTests/Microsoft.Agents.AI.Anthropic.UnitTests.csproj" />
<Project Path="tests/Microsoft.Agents.AI.GithubCopilot.UnitTests/Microsoft.Agents.AI.GithubCopilot.UnitTests.csproj" />
<Project Path="tests/Microsoft.Agents.AI.AzureAI.Persistent.UnitTests/Microsoft.Agents.AI.AzureAI.Persistent.UnitTests.csproj" />
<Project Path="tests/Microsoft.Agents.AI.AzureAI.UnitTests/Microsoft.Agents.AI.AzureAI.UnitTests.csproj" />
<Project Path="tests/Microsoft.Agents.AI.CosmosNoSql.UnitTests/Microsoft.Agents.AI.CosmosNoSql.UnitTests.csproj" />
Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1,19 @@
<Project Sdk="Microsoft.NET.Sdk">

<PropertyGroup>
<OutputType>Exe</OutputType>
<TargetFrameworks>net10.0</TargetFrameworks>

<Nullable>enable</Nullable>
<ImplicitUsings>enable</ImplicitUsings>
</PropertyGroup>

<ItemGroup>
<PackageReference Include="GitHub.Copilot.SDK" />
</ItemGroup>

<ItemGroup>
<ProjectReference Include="..\..\..\..\src\Microsoft.Agents.AI.GithubCopilot\Microsoft.Agents.AI.GithubCopilot.csproj" />
</ItemGroup>

</Project>
Original file line number Diff line number Diff line change
@@ -0,0 +1,51 @@
// Copyright (c) Microsoft. All rights reserved.

// This sample shows how to create a GitHub Copilot agent with shell command permissions.

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

// Permission handler that prompts the user for approval
static Task<PermissionRequestResult> PromptPermission(PermissionRequest request, PermissionInvocation invocation)
{
Console.WriteLine($"\n[Permission Request: {request.Kind}]");
Console.Write("Approve? (y/n): ");

string? input = Console.ReadLine()?.Trim().ToUpperInvariant();
string kind = input is "Y" or "YES" ? "approved" : "denied-interactively-by-user";

return Task.FromResult(new PermissionRequestResult { Kind = kind });
}

// Create and start a Copilot client
await using CopilotClient copilotClient = new();
await copilotClient.StartAsync();

// Create an agent with a session config that enables permission handling
SessionConfig sessionConfig = new()
{
OnPermissionRequest = PromptPermission,
};

AIAgent agent = copilotClient.AsAIAgent(sessionConfig, ownsClient: true);

// Toggle between streaming and non-streaming modes
bool useStreaming = true;

string prompt = "List all files in the current directory";
Console.WriteLine($"User: {prompt}\n");

if (useStreaming)
{
await foreach (AgentResponseUpdate update in agent.RunStreamingAsync(prompt))
{
Console.Write(update);
}

Console.WriteLine();
}
else
{
AgentResponse response = await agent.RunAsync(prompt);
Console.WriteLine(response);
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,76 @@
# Prerequisites

> **⚠️ WARNING: Container Recommendation**
>
> GitHub Copilot can execute tools and commands that may interact with your system. For safety, it is strongly recommended to run this sample in a containerized environment (e.g., Docker, Dev Container) to avoid unintended consequences to your machine.

Before you begin, ensure you have the following prerequisites:

- .NET 10 SDK or later
- GitHub Copilot CLI installed and available in your PATH (or provide a custom path)

## Setting up GitHub Copilot CLI

To use this sample, you need to have the GitHub Copilot CLI installed. You can install it by following the instructions at:
https://github.com/github/copilot-sdk

Once installed, ensure the `copilot` command is available in your PATH, or configure a custom path using `CopilotClientOptions`.

## Running the Sample

No additional environment variables are required if using default configuration. The sample will:

1. Create a GitHub Copilot client with default options
2. Create an AI agent using the Copilot SDK
3. Send a message to the agent
4. Display the response

Run the sample:

```powershell
dotnet run
```

## Advanced Usage

You can customize the agent by providing additional configuration:

```csharp
using GitHub.Copilot.SDK;
using Microsoft.Agents.AI;

// Create and start a Copilot client
await using CopilotClient copilotClient = new();
await copilotClient.StartAsync();

// Create session configuration with specific model
SessionConfig sessionConfig = new()
{
Model = "claude-opus-4.5",
Streaming = false
};

// Create an agent with custom configuration using the extension method
AIAgent agent = copilotClient.AsAIAgent(
sessionConfig,
ownsClient: true,
id: "my-copilot-agent",
name: "My Copilot Assistant",
description: "A helpful AI assistant powered by GitHub Copilot"
);

// Use the agent - ask it to write code for us
AgentResponse response = await agent.RunAsync("Write a small .NET 10 C# hello world single file application");
Console.WriteLine(response);
```

## Streaming Responses

To get streaming responses:

```csharp
await foreach (AgentResponseUpdate update in agent.RunStreamingAsync("Write a C# function to calculate Fibonacci numbers"))
{
Console.Write(update.Text);
}
```
1 change: 1 addition & 0 deletions dotnet/samples/GettingStarted/AgentProviders/README.md
Original file line number Diff line number Diff line change
Expand Up @@ -22,6 +22,7 @@ See the README.md for each sample for the prerequisites for that sample.
|[Creating an AIAgent with Azure OpenAI ChatCompletion](./Agent_With_AzureOpenAIChatCompletion/)|This sample demonstrates how to create an AIAgent using Azure OpenAI ChatCompletion as the underlying inference service|
|[Creating an AIAgent with Azure OpenAI Responses](./Agent_With_AzureOpenAIResponses/)|This sample demonstrates how to create an AIAgent using Azure OpenAI Responses as the underlying inference service|
|[Creating an AIAgent with a custom implementation](./Agent_With_CustomImplementation/)|This sample demonstrates how to create an AIAgent with a custom implementation|
|[Creating an AIAgent with GitHub Copilot](./Agent_With_GithubCopilot/)|This sample demonstrates how to create an AIAgent using GitHub Copilot SDK as the underlying inference service|
|[Creating an AIAgent with Ollama](./Agent_With_Ollama/)|This sample demonstrates how to create an AIAgent using Ollama as the underlying inference service|
|[Creating an AIAgent with ONNX](./Agent_With_ONNX/)|This sample demonstrates how to create an AIAgent using ONNX as the underlying inference service|
|[Creating an AIAgent with OpenAI Assistants](./Agent_With_OpenAIAssistants/)|This sample demonstrates how to create an AIAgent using OpenAI Assistants as the underlying inference service.</br>WARNING: The Assistants API is deprecated and will be shut down. For more information see the OpenAI documentation: https://platform.openai.com/docs/assistants/migration|
Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1,73 @@
// Copyright (c) Microsoft. All rights reserved.

using System.Collections.Generic;
using Microsoft.Agents.AI;
using Microsoft.Agents.AI.GithubCopilot;
using Microsoft.Extensions.AI;
using Microsoft.Shared.Diagnostics;

namespace GitHub.Copilot.SDK;

/// <summary>
/// Provides extension methods for <see cref="CopilotClient"/>
/// to simplify the creation of GitHub Copilot agents.
/// </summary>
/// <remarks>
/// These extensions bridge the gap between GitHub Copilot SDK client objects
/// and the Microsoft Agent Framework.
/// <para>
/// They allow developers to easily create AI agents that can interact
/// with GitHub Copilot by handling the conversion from Copilot clients to
/// <see cref="GithubCopilotAgent"/> instances that implement the <see cref="AIAgent"/> interface.
/// </para>
/// </remarks>
public static class CopilotClientExtensions
{
/// <summary>
/// Retrieves an instance of <see cref="AIAgent"/> for a GitHub Copilot client.
/// </summary>
/// <param name="client">The <see cref="CopilotClient"/> to use for the agent.</param>
/// <param name="sessionConfig">Optional session configuration for the agent.</param>
/// <param name="ownsClient">Whether the agent owns the client and should dispose it. Default is false.</param>
/// <param name="id">The unique identifier for the agent.</param>
/// <param name="name">The name of the agent.</param>
/// <param name="description">The description of the agent.</param>
/// <returns>An <see cref="AIAgent"/> instance backed by the GitHub Copilot client.</returns>
public static AIAgent AsAIAgent(
this CopilotClient client,
SessionConfig? sessionConfig = null,
bool ownsClient = false,
string? id = null,
string? name = null,
string? description = null)
{
Throw.IfNull(client);

return new GithubCopilotAgent(client, sessionConfig, ownsClient, id, name, description);
}

/// <summary>
/// Retrieves an instance of <see cref="AIAgent"/> for a GitHub Copilot client.
/// </summary>
/// <param name="client">The <see cref="CopilotClient"/> to use for the agent.</param>
/// <param name="ownsClient">Whether the agent owns the client and should dispose it. Default is false.</param>
/// <param name="id">The unique identifier for the agent.</param>
/// <param name="name">The name of the agent.</param>
/// <param name="description">The description of the agent.</param>
/// <param name="tools">The tools to make available to the agent.</param>
/// <param name="instructions">Optional instructions to append as a system message.</param>
/// <returns>An <see cref="AIAgent"/> instance backed by the GitHub Copilot client.</returns>
public static AIAgent AsAIAgent(
this CopilotClient client,
bool ownsClient = false,
string? id = null,
string? name = null,
string? description = null,
IList<AITool>? tools = null,
string? instructions = null)
{
Throw.IfNull(client);

return new GithubCopilotAgent(client, ownsClient, id, name, description, tools, instructions);
}
}
Loading
Loading