Files
awesome-copilot/cookbook/copilot-sdk/README.md
T
Jon GallowayandCopilot a19b3101cc Update .NET Copilot SDK cookbook for current SDK releases (#3548)
* Update .NET Copilot SDK cookbook: fix On<T> breaking change, add in-process runtime, tool search, and message provenance recipes

- Fix breaking change: Session.On is now generic (On<T> where T : SessionEvent).
  Updated all recipes that used the old non-generic session.On(evt => ...) pattern:
  error-handling, pr-visualization, managing-local-files, accessibility-report,
  ralph-loop (both .md and .cs where applicable).
- Add new 'In-Process Runtime' recipe (in-process-runtime.md + recipe/in-process-runtime.cs)
  demonstrating RuntimeConnection.ForInProcess(), live-tested.
- Document tool search / deferred loading (SessionConfig.ToolSearch / ToolSearchConfig)
  in pr-visualization.md, live-tested.
- Document typed message provenance (MessageOptions.Source / MessageSource) in
  error-handling.md, live-tested.
- Fix dotnet/README.md recipe index: it was missing Ralph Loop and Accessibility
  Report entries; also added the new In-Process Runtime entry.
- Add In-Process Runtime entry to the top-level cookbook/copilot-sdk/README.md
  .NET section.
- Update dotnet/recipe/README.md runnable-examples table with the new recipe.

All existing .NET cookbook recipes were rebuilt and rechecked against the current
GitHub Copilot SDK (Copilot CLI 1.0.85); no other breaking changes were found.

Co-authored-by: Copilot <223556219+Copilot@users.noreply.github.com>

* Update cookbook model names to current supported models

- Replace stale/nonexistent model IDs (gpt-5, claude-sonnet-4.5,
  claude-opus-4.6, gpt-5.1-codex-mini) with current values from the
  supported AI models list
- Prefer Model = "auto" wherever a specific model isn't load-bearing
  to the recipe's teaching point
- ralph-loop: pin gpt-5.3-codex (current codex-family GA model), since
  a dedicated coding model is a deliberate, documented choice for the
  autonomous loop
- multiple-sessions: reshape the model narrative so it demonstrates a
  real explicit-override use case (A/B testing via claude-sonnet-5)
  instead of two sessions sharing the same hardcoded model

Co-authored-by: Copilot <223556219+Copilot@users.noreply.github.com>

* Use SendAndWaitAsync in in-process runtime recipe

Replace the event-based TaskCompletionSource pattern with SendAndWaitAsync so the example waits for the final assistant response, propagates session errors, and uses the SDK timeout behavior.

Co-authored-by: Copilot <223556219+Copilot@users.noreply.github.com>

---------

Co-authored-by: Copilot <223556219+Copilot@users.noreply.github.com>
2026-09-22 00:15:06 +00:00

5.7 KiB
Raw Blame History

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 copy‑pasteable snippets and pointers to fuller examples and tests.

Recipes by Language

.NET (C#)

  • Ralph Loop: Build autonomous AI coding loops with fresh context per iteration, planning/building modes, and backpressure.
  • 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.
  • Accessibility Report: Generate WCAG accessibility reports using the Playwright MCP server.
  • In-Process Runtime: Run the Copilot runtime in-process instead of launching a separate CLI process.

Node.js / TypeScript

  • Ralph Loop: Build autonomous AI coding loops with fresh context per iteration, planning/building modes, and backpressure.
  • 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.
  • Accessibility Report: Generate WCAG accessibility reports using the Playwright MCP server.

Python

  • Ralph Loop: Build autonomous AI coding loops with fresh context per iteration, planning/building modes, and backpressure.
  • 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.
  • Accessibility Report: Generate WCAG accessibility reports using the Playwright MCP server.

Go

  • Ralph Loop: Build autonomous AI coding loops with fresh context per iteration, planning/building modes, and backpressure.
  • 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.
  • Accessibility Report: Generate WCAG accessibility reports using the Playwright MCP server.

Java

  • Ralph Loop: Build autonomous AI coding loops with fresh context per iteration, planning/building modes, and backpressure.
  • 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.
  • Accessibility Report: Generate WCAG accessibility reports using the Playwright MCP server.

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

Java

cd java/recipe
jbang <FileName>.java

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 7 recipes across all 5 supported languages. Each recipe includes both markdown documentation and runnable examples.