Skip to content

Conversation

@aaronpowell
Copy link
Contributor

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.

- 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)
@patniko patniko marked this pull request as ready for review January 22, 2026 01:26
@patniko patniko requested a review from a team as a code owner January 22, 2026 01:26
Copilot AI review requested due to automatic review settings January 22, 2026 01:26
@patniko patniko added this pull request to the merge queue Jan 22, 2026
Merged via the queue into github:main with commit f26e999 Jan 22, 2026
7 of 19 checks passed
Copy link
Contributor

Copilot AI left a 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
Copy link

Copilot AI Jan 22, 2026

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

Copilot uses AI. Check for mistakes.

```bash
# Auto-detect from current git repo
npx tsx pr-breakdown.ts
Copy link

Copilot AI Jan 22, 2026

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

Copilot uses AI. Check for mistakes.
"persisting-sessions": "tsx persisting-sessions.ts"
},
"dependencies": {
"@github/copilot-sdk": "file:../../src"
Copy link

Copilot AI Jan 22, 2026

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".

Copilot uses AI. Check for mistakes.
- [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.
Copy link

Copilot AI Jan 22, 2026

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.

Suggested change
- [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.

Copilot uses AI. Check for mistakes.
- [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.
Copy link

Copilot AI Jan 22, 2026

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".

Suggested change
- [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.

Copilot uses AI. Check for mistakes.
client.start()

# Create session
session = client.create_session(model="gpt-5")
Copy link

Copilot AI Jan 22, 2026

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.

Copilot uses AI. Check for mistakes.
client.start()

# Create multiple independent sessions
session1 = client.create_session(model="gpt-5")
Copy link

Copilot AI Jan 22, 2026

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

Copilot uses AI. Check for mistakes.
Comment on lines +9 to +12
session = client.create_session(
session_id="user-123-conversation",
model="gpt-5",
)
Copy link

Copilot AI Jan 22, 2026

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.

Copilot uses AI. Check for mistakes.
Comment on lines +95 to +112
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>
"""
}
)
Copy link

Copilot AI Jan 22, 2026

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.

Copilot uses AI. Check for mistakes.
owner, repo_name = repo.split("/", 1)

# Create Copilot client - no custom tools needed!
client = CopilotClient(log_level="error")
Copy link

Copilot AI Jan 22, 2026

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.

Copilot uses AI. Check for mistakes.
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants