-
Notifications
You must be signed in to change notification settings - Fork 634
Copilot SDK Cookbook #80
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Conversation
- Central hub for all language cookbooks - Links to 4 languages with 4 recipes each - Quick-start commands for each language
Recipes: - error-handling: try-catch patterns, specific error handling, timeouts - multiple-sessions: manage independent conversations simultaneously - managing-local-files: organize files by metadata with AI - pr-visualization: interactive PR age chart CLI tool Each recipe includes: - Markdown documentation with code examples - File-based app runnable example (.cs) - PublishAot=false directive for compatibility
Recipes: - error-handling: defer cleanup, error wrapping, timeouts with context - multiple-sessions: concurrent session management - managing-local-files: organize files by metadata with AI - pr-visualization: interactive PR age chart CLI tool with flag parsing Each recipe includes: - Markdown documentation with Go idiomatic code - Standalone runnable example (.go) - Proper error handling with defer patterns - CLI flag support where applicable
Recipes: - error-handling: try-catch async patterns, error types - multiple-sessions: concurrent session management - managing-local-files: organize files by metadata with AI - pr-visualization: interactive PR age chart CLI tool Each recipe includes: - Markdown documentation with TypeScript code - Standalone runnable example (.ts) - package.json with local SDK reference (file:../../..) - npm scripts for easy execution - ESM with top-level await support
Recipes: - error_handling: exception handling, context managers - multiple_sessions: concurrent session management - managing_local_files: organize files by metadata with AI - pr_visualization: interactive PR age chart CLI tool Each recipe includes: - Markdown documentation with Python examples - Standalone runnable example (.py) - requirements.txt with local SDK (editable install) - Shebang for direct execution - PEP 8 naming conventions (snake_case)
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Pull request overview
This pull request introduces a comprehensive cookbook section for the GitHub Copilot SDK, providing practical recipes and runnable examples across four languages (Python, Node.js/TypeScript, Go, and .NET/C#). The cookbook includes five recipes per language covering error handling, session management, file organization, and PR visualization.
Changes:
- Added cookbook documentation structure with language-specific guides
- Created 20+ runnable code examples (5 recipes × 4 languages)
- Established consistent patterns for SDK usage across languages
Reviewed changes
Copilot reviewed 51 out of 52 changed files in this pull request and generated 15 comments.
Show a summary per file
| File | Description |
|---|---|
| cookbook/README.md | Root cookbook index linking to all language-specific recipes |
| python/cookbook/* | Python recipes with markdown docs and runnable examples |
| nodejs/cookbook/* | Node.js/TypeScript recipes with package configuration |
| go/cookbook/* | Go recipes with standalone executable examples |
| dotnet/cookbook/* | .NET/C# recipes using file-based app model |
| /recipe/.{py,ts,go,cs} | Executable example code for each recipe |
| */recipe/README.md | Language-specific instructions for running examples |
Files not reviewed (1)
- nodejs/cookbook/recipe/package-lock.json: Language not supported
Comments suppressed due to low confidence (6)
python/cookbook/pr-visualization.md:33
- The command reference uses "pr_breakdown.py" but the actual filename is "pr_visualization.py". This inconsistency should be corrected.
python/cookbook/pr-visualization.md:36 - The heading says "Full example: pr_breakdown.py" but the actual filename is "pr_visualization.py". This should be corrected for consistency.
nodejs/cookbook/pr-visialisation.md:35 - The command reference uses "pr-breakdown.ts" but the actual filename is "pr-visualization.ts". This inconsistency should be corrected.
nodejs/cookbook/pr-visialisation.md:38 - The heading says "Full example: pr-breakdown.ts" but the actual filename is "pr-visualization.ts". This should be corrected for consistency.
python/cookbook/recipe/multiple_sessions.py:10 - Keyword argument 'model' is not a supported parameter name of method CopilotClient.create_session.
python/cookbook/recipe/multiple_sessions.py:11 - Keyword argument 'model' is not a supported parameter name of method CopilotClient.create_session.
💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.
|
|
||
| ```bash | ||
| # Auto-detect from current git repo | ||
| python pr_breakdown.py |
Copilot
AI
Jan 22, 2026
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
The command reference uses "pr_breakdown.py" but the actual filename is "pr_visualization.py". This inconsistency should be corrected.
This issue also appears in the following locations of the same file:
- line 33
- line 36
|
|
||
| ```bash | ||
| # Auto-detect from current git repo | ||
| npx tsx pr-breakdown.ts |
Copilot
AI
Jan 22, 2026
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
The command reference uses "pr-breakdown.ts" but the actual filename is "pr-visualization.ts". This inconsistency should be corrected.
This issue also appears in the following locations of the same file:
- line 35
- line 38
| "persisting-sessions": "tsx persisting-sessions.ts" | ||
| }, | ||
| "dependencies": { | ||
| "@github/copilot-sdk": "file:../../src" |
Copilot
AI
Jan 22, 2026
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
The reference path "../../src" in package.json appears incorrect. Based on the file structure, the SDK source should be at "../../../src" (going up to nodejs, then to root, then to src), not "../../src".
| - [Error Handling](error-handling.md): Handle errors gracefully including connection failures, timeouts, and cleanup. | ||
| - [Multiple Sessions](multiple-sessions.md): Manage multiple independent conversations simultaneously. | ||
| - [Managing Local Files](managing-local-files.md): Organize files by metadata using AI-powered grouping strategies. | ||
| - [PR Visualization](pr-visialisation.md): Generate interactive PR age charts using GitHub MCP Server. |
Copilot
AI
Jan 22, 2026
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
The link reference "pr-visialisation.md" contains a spelling error and should be "pr-visualization.md" to match the correct filename.
| - [PR Visualization](pr-visialisation.md): Generate interactive PR age charts using GitHub MCP Server. | |
| - [PR Visualization](pr-visualization.md): Generate interactive PR age charts using GitHub MCP Server. |
| - [Error Handling](nodejs/cookbook/error-handling.md): Handle errors gracefully including connection failures, timeouts, and cleanup. | ||
| - [Multiple Sessions](nodejs/cookbook/multiple-sessions.md): Manage multiple independent conversations simultaneously. | ||
| - [Managing Local Files](nodejs/cookbook/managing-local-files.md): Organize files by metadata using AI-powered grouping strategies. | ||
| - [PR Visualization](nodejs/cookbook/pr-visialisation.md): Generate interactive PR age charts using GitHub MCP Server. |
Copilot
AI
Jan 22, 2026
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
The link reference "pr-visialisation.md" contains a spelling error and should be "pr-visualization.md".
| - [PR Visualization](nodejs/cookbook/pr-visialisation.md): Generate interactive PR age charts using GitHub MCP Server. | |
| - [PR Visualization](nodejs/cookbook/pr-visualization.md): Generate interactive PR age charts using GitHub MCP Server. |
| client.start() | ||
|
|
||
| # Create session | ||
| session = client.create_session(model="gpt-5") |
Copilot
AI
Jan 22, 2026
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Keyword argument 'model' is not a supported parameter name of method CopilotClient.create_session.
| client.start() | ||
|
|
||
| # Create multiple independent sessions | ||
| session1 = client.create_session(model="gpt-5") |
Copilot
AI
Jan 22, 2026
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Keyword argument 'model' is not a supported parameter name of method CopilotClient.create_session.
This issue also appears in the following locations of the same file:
- line 10
- line 11
| session = client.create_session( | ||
| session_id="user-123-conversation", | ||
| model="gpt-5", | ||
| ) |
Copilot
AI
Jan 22, 2026
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Keyword argument 'model' is not a supported parameter name of method CopilotClient.create_session.
Keyword argument 'session_id' is not a supported parameter name of method CopilotClient.create_session.
| session = client.create_session( | ||
| model="gpt-5", | ||
| system_message={ | ||
| "content": f""" | ||
| <context> | ||
| You are analyzing pull requests for the GitHub repository: {owner}/{repo_name} | ||
| The current working directory is: {os.getcwd()} | ||
| </context> | ||
|
|
||
| <instructions> | ||
| - Use the GitHub MCP Server tools to fetch PR data | ||
| - Use your file and code execution tools to generate charts | ||
| - Save any generated images to the current working directory | ||
| - Be concise in your responses | ||
| </instructions> | ||
| """ | ||
| } | ||
| ) |
Copilot
AI
Jan 22, 2026
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Keyword argument 'model' is not a supported parameter name of method CopilotClient.create_session.
Keyword argument 'system_message' is not a supported parameter name of method CopilotClient.create_session.
| owner, repo_name = repo.split("/", 1) | ||
|
|
||
| # Create Copilot client - no custom tools needed! | ||
| client = CopilotClient(log_level="error") |
Copilot
AI
Jan 22, 2026
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Keyword argument 'log_level' is not a supported parameter name of CopilotClient.init.
This pull request introduces a new "cookbook" section for the GitHub Copilot SDK, providing practical, language-specific recipes and runnable examples for common tasks in .NET (C#). The changes establish a clear structure for documentation and examples, making it easier for developers to learn and apply the SDK through concise guides and copy‑pasteable code. The initial set of recipes covers error handling, managing multiple sessions, organizing local files, and visualizing pull request data.