Skip to content

Instantly share code, notes, and snippets.

View wullemsb's full-sized avatar

Wullems Bart wullemsb

View GitHub Profile
using GitHub.Copilot.SDK;
await using var client = new CopilotClient();
await client.StartAsync();
await using var session = await client.CreateSessionAsync(new SessionConfig
{
OnPermissionRequest = async (request, invocation) =>
{
// request.Kind — string discriminator for the type of operation being requested:
using GitHub.Copilot.SDK;
await using var client = new CopilotClient();
await client.StartAsync();
await using var session = await client.CreateSessionAsync(new SessionConfig
{
OnPermissionRequest = PermissionHandler.ApproveAll,
});
using GitHub.Copilot.SDK;
await using var client = new CopilotClient();
await client.StartAsync();
var session = await client.CreateSessionAsync(new SessionConfig
{
Model = "gpt-4.1",
OnPermissionRequest = PermissionHandler.ApproveAll,
});
using GitHub.Copilot.SDK;
await using var client = new CopilotClient();
await client.StartAsync();
var session = await client.CreateSessionAsync(new SessionConfig
{
Model = "gpt-4.1",
OnPermissionRequest = PermissionHandler.ApproveAll,
Streaming = true
using GitHub.Copilot.SDK;
await using var client = new CopilotClient();
await client.StartAsync();
var session = await client.CreateSessionAsync(new SessionConfig
{
Model = "gpt-4.1"
OnPermissionRequest = PermissionHandler.ApproveAll,
});
using GitHub.Copilot.SDK;
using Microsoft.Extensions.AI;
// Define the tool
[AIFunction("get_current_weather", "Gets the current weather for a given city")]
static string GetCurrentWeather(string city)
{
// In a real app, call a weather API here
return $"It's 18°C and partly cloudy in {city}.";
}
wait using var client = new CopilotClient();
await using var session = await client.CreateSessionAsync(new SessionConfig
{
Model = "gpt-5.2-codex", // Your deployment name
Provider = new ProviderConfig
{
Type = "openai",
BaseUrl = "https://your-resource.openai.azure.com/openai/v1/",
WireApi = "responses", // Use "completions" for older models
ApiKey = Environment.GetEnvironmentVariable("FOUNDRY_API_KEY"),
var session = await client.CreateSessionAsync(new SessionConfig
{
Model = "gpt-4.1",
OnPermissionRequest = async (request, invocation) =>
{
// Approve read operations automatically, prompt for anything else
if (request.Kind == "read")
return new PermissionRequestResult() {Kind=PermissionRequestResultKind.Approved };
Console.WriteLine("Agent wants to perform: {request.Kind} — {request.Description}");
builder.Services.AddSingleton<CopilotClient>(sp =>
{
var clientOptions = new CopilotClientOptions();
clientOptions.AutoStart=true;
var client = new CopilotClient(clientOptions);
return client;
});
using GitHub.Copilot.SDK;
await using var client = new CopilotClient();
await using var session = await client.CreateSessionAsync(new SessionConfig
{
Model = "gpt-4.1",
OnPermissionRequest = PermissionHandler.ApproveAll
});
var response = await session.SendAndWaitAsync(new MessageOptions { Prompt = "What does this codebase do?" });