* 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>
Runnable Recipe Examples
This folder contains standalone, executable C# examples for each cookbook recipe. These are file-based apps that can be run directly with dotnet run.
Prerequisites
- .NET 10.0 or later
- GitHub Copilot SDK package (referenced automatically)
Running Examples
Each .cs file is a complete, runnable program. Simply use:
dotnet run <filename>.cs
Available Recipes
| Recipe | Command | Description |
|---|---|---|
| Error Handling | dotnet run error-handling.cs |
Demonstrates error handling patterns |
| Multiple Sessions | dotnet run multiple-sessions.cs |
Manages multiple independent conversations |
| Managing Local Files ⚠️ | dotnet run managing-local-files.cs |
Organizes files using AI grouping |
| PR Visualization ℹ️ | dotnet run pr-visualization.cs |
Generates PR age charts |
| Persisting Sessions | dotnet run persisting-sessions.cs |
Save and resume sessions across restarts |
| Accessibility Report ℹ️ | dotnet run accessibility-report.cs |
Analyzes web page accessibility |
| Ralph Loop ⚠️ | dotnet run ralph-loop.cs |
Autonomous development loop |
| In-Process Runtime | dotnet run in-process-runtime.cs |
Runs the Copilot runtime in-process |
Examples with Arguments
PR Visualization with specific repo:
dotnet run pr-visualization.cs -- --repo github/copilot-sdk
Managing Local Files (edit the file to change target folder):
# Edit the targetFolder variable in managing-local-files.cs first
dotnet run managing-local-files.cs
Safety & Prerequisites
Some recipes have side effects or external dependencies. Expand each section for safe testing patterns and prerequisites.
⚠️ Managing Local Files — Modifies your filesystem
Before running on a real directory, test it on a copy first. Run these snippets from this recipe directory so the recipe path is captured before switching to the temporary folder.
PowerShell:
$recipeDir = (Get-Location).Path
$tempDir = New-Item -ItemType Directory -Path ([IO.Path]::Combine([IO.Path]::GetTempPath(), "copilot-test-files"))
@("document1.txt", "image1.png", "data.json") | ForEach-Object {
New-Item -Path "$tempDir/$_" -ItemType File
}
cd $tempDir
dotnet run "$recipeDir/managing-local-files.cs"
# Inspect results, then clean up
Remove-Item $tempDir -Recurse
Bash:
recipeDir=$(pwd)
tempDir=$(mktemp -d)
touch "$tempDir"/{document1.txt,image1.png,data.json}
cd "$tempDir"
dotnet run "$recipeDir/managing-local-files.cs"
# Inspect results, then clean up
rm -rf "$tempDir"
Edit the targetFolder variable in the .cs file to point to your test directory before running.
⚠️ Ralph Loop — Creates git commits and modifies files
Always run it in an isolated git repository first to verify behavior. Run these snippets from this recipe directory so the recipe path is captured before switching to the temporary repository.
PowerShell:
$recipeDir = (Get-Location).Path
$tempDir = New-Item -ItemType Directory -Path ([IO.Path]::Combine([IO.Path]::GetTempPath(), "copilot-test-repo"))
cd $tempDir
git init
git config user.email "test@example.com"
git config user.name "Test User"
# Create a PROMPT_task.md for the recipe to work with
"# Task`nCreate a simple README" | Out-File PROMPT_task.md
dotnet run "$recipeDir/ralph-loop.cs"
# Review commits and changes
git log --oneline
git diff
# Clean up
cd ..
Remove-Item $tempDir -Recurse
Bash:
recipeDir=$(pwd)
tempDir=$(mktemp -d)
cd "$tempDir"
git init
git config user.email "test@example.com"
git config user.name "Test User"
# Create a PROMPT_task.md for the recipe to work with
echo -e "# Task\nCreate a simple README" > PROMPT_task.md
dotnet run "$recipeDir/ralph-loop.cs"
# Review commits and changes
git log --oneline
git diff
# Clean up
cd ..
rm -rf "$tempDir"
The recipe requires a git repository with at least one PROMPT_*.md file and will run in an infinite loop until manually stopped.
ℹ️ Accessibility Report — Requires Playwright MCP
This recipe requires Playwright MCP to be installed and available:
npm install -g @playwright/mcp
Or let Node Package Manager install it on-demand. The recipe will attempt to launch npx @playwright/mcp automatically. Run the recipe as normal:
dotnet run accessibility-report.cs
The recipe will prompt you for a URL to analyze and generate an accessibility report.
ℹ️ PR Visualization — Requires GitHub API access
This recipe requires:
- Access to a GitHub repository (public or private, with appropriate credentials)
ghCLI tool installed and authenticated: https://cli.github.com/
Run with a repository argument:
dotnet run pr-visualization.cs -- --repo owner/repo-name
Example:
dotnet run pr-visualization.cs -- --repo github/copilot-sdk
Note: GitHub API requests are rate-limited. Large repositories or frequent runs may hit rate limits. See GitHub API rate limiting for details.
File-Based Apps
These examples use .NET's file-based app feature, which allows single-file C# programs to:
- Run without a project file
- Automatically reference common packages
- Support top-level statements