Files
awesome-copilot/cookbook/copilot-sdk
Anthony Shaw ab82accc08 Address review feedback: fix event handler leak, error handling, model alignment
- Move session.On handler outside loop to prevent handler accumulation (C#)
- Use TrySetResult instead of SetResult to avoid duplicate-set exceptions (C#)
- Wrap CreateSessionAsync in broader try/finally so client always stops (C#)
- Fix PersistentRalphLoop to use maxIterations parameter instead of hardcoded 10
- Align model name to gpt-5.1-codex-mini across all doc snippets
- Fix completion promise DONE -> COMPLETE in usage snippet
- Replace Claude references with generic model terminology
2026-02-11 06:35:14 -08:00
..
2026-02-11 05:48:44 -08:00
2026-02-11 05:48:44 -08:00

GitHub Copilot SDK Cookbook

This cookbook collects small, focused recipes showing how to accomplish common tasks with the GitHub Copilot SDK across languages. Each recipe is intentionally short and practical, with copypasteable snippets and pointers to fuller examples and tests.

Recipes by Language

.NET (C#)

  • RALPH-loop: Implement iterative self-referential AI loops for task completion with automatic retries.
  • Error Handling: Handle errors gracefully including connection failures, timeouts, and cleanup.
  • Multiple Sessions: Manage multiple independent conversations simultaneously.
  • Managing Local Files: Organize files by metadata using AI-powered grouping strategies.
  • PR Visualization: Generate interactive PR age charts using GitHub MCP Server.
  • Persisting Sessions: Save and resume sessions across restarts.

Node.js / TypeScript

  • RALPH-loop: Implement iterative self-referential AI loops for task completion with automatic retries.
  • Error Handling: Handle errors gracefully including connection failures, timeouts, and cleanup.
  • Multiple Sessions: Manage multiple independent conversations simultaneously.
  • Managing Local Files: Organize files by metadata using AI-powered grouping strategies.
  • PR Visualization: Generate interactive PR age charts using GitHub MCP Server.
  • Persisting Sessions: Save and resume sessions across restarts.

Python

  • RALPH-loop: Implement iterative self-referential AI loops for task completion with automatic retries.
  • Error Handling: Handle errors gracefully including connection failures, timeouts, and cleanup.
  • Multiple Sessions: Manage multiple independent conversations simultaneously.
  • Managing Local Files: Organize files by metadata using AI-powered grouping strategies.
  • PR Visualization: Generate interactive PR age charts using GitHub MCP Server.
  • Persisting Sessions: Save and resume sessions across restarts.

Go

  • RALPH-loop: Implement iterative self-referential AI loops for task completion with automatic retries.
  • Error Handling: Handle errors gracefully including connection failures, timeouts, and cleanup.
  • Multiple Sessions: Manage multiple independent conversations simultaneously.
  • Managing Local Files: Organize files by metadata using AI-powered grouping strategies.
  • PR Visualization: Generate interactive PR age charts using GitHub MCP Server.
  • Persisting Sessions: Save and resume sessions across restarts.

How to Use

  • Browse your language section above and open the recipe links
  • Each recipe includes runnable examples in a recipe/ subfolder with language-specific tooling
  • See existing examples and tests for working references:
    • Node.js examples: nodejs/examples/basic-example.ts
    • E2E tests: go/e2e, python/e2e, nodejs/test/e2e, dotnet/test/Harness

Running Examples

.NET

cd dotnet/cookbook/recipe
dotnet run <filename>.cs

Node.js

cd nodejs/cookbook/recipe
npm install
npx tsx <filename>.ts

Python

cd python/cookbook/recipe
pip install -r requirements.txt
python <filename>.py

Go

cd go/cookbook/recipe
go run <filename>.go

Contributing

  • Propose or add a new recipe by creating a markdown file in your language's cookbook/ folder and a runnable example in recipe/
  • Follow repository guidance in CONTRIBUTING.md

Status

Cookbook structure is complete with 6 recipes across all 4 supported languages. Each recipe includes both markdown documentation and runnable examples.