Skip to content

Instantly share code, notes, and snippets.

@wullemsb
Created May 8, 2026 20:18
Show Gist options
  • Select an option

  • Save wullemsb/abf3059f361e5a348ea4088b4e1e9304 to your computer and use it in GitHub Desktop.

Select an option

Save wullemsb/abf3059f361e5a348ea4088b4e1e9304 to your computer and use it in GitHub Desktop.
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
});
var tcs = new TaskCompletionSource<bool>(TaskCreationOptions.RunContinuationsAsynchronously);
session.On("assistant.message_delta", (evt) =>
{
Console.Write(evt.Data.DeltaContent);
});
session.On("session.idle", (_) =>
{
Console.WriteLine();
});
await session.SendAndWaitAsync(new MessageOptions
{
Prompt = "Explain how the Copilot SDK execution loop works."
});
await client.StopAsync();
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment