Skip to content

🤖 Add Copilot SDK Expert Agentic Workflow#1

Open
matheus-rech wants to merge 1 commit intomainfrom
copilot-sdk-setup
Open

🤖 Add Copilot SDK Expert Agentic Workflow#1
matheus-rech wants to merge 1 commit intomainfrom
copilot-sdk-setup

Conversation

@matheus-rech
Copy link
Copy Markdown
Owner

Adds two files to this repository:

  • .github/workflows/copilot-sdk-expert.md — A gh-aw agentic workflow that reviews PRs for SDK usage, triages issues, and responds to /sdk slash commands with expert Copilot SDK guidance across TypeScript, Python, Go, and .NET.

  • .github/copilot-instructions.md — Agent instructions that give any AI coding agent (Copilot, Claude, Codex) deep knowledge of the Copilot SDK when working in this repo.

To activate the workflow after merge:

gh aw compile .github/workflows/copilot-sdk-expert.md

Copilot AI review requested due to automatic review settings March 2, 2026 00:46
Copy link
Copy Markdown

@sourcery-ai sourcery-ai bot left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Sorry @matheus-rech, you have reached your weekly rate limit of 500000 diff characters.

Please try again later or upgrade to continue using Sourcery

@gemini-code-assist
Copy link
Copy Markdown

Summary of Changes

Hello, I'm Gemini Code Assist1! I'm currently reviewing this pull request and will post my feedback shortly. In the meantime, here's a summary to help you and other reviewers quickly get up to speed!

This pull request integrates a detailed set of instructions and best practices for the GitHub Copilot SDK into the repository. By providing AI coding agents with deep knowledge of the SDK's functionalities and recommended usage patterns, the change aims to improve the quality and consistency of AI-generated code that interacts with the Copilot SDK across various programming languages.

Highlights

  • Copilot SDK Agent Instructions: Introduced a new markdown file, .github/copilot-instructions.md, which serves as a comprehensive guide for AI coding agents to understand and utilize the GitHub Copilot SDK.
  • SDK Feature References: The guide provides quick references for SDK installation, basic "Hello World" examples across TypeScript, Python, Go, and .NET, and details on advanced features like streaming, custom tools, authentication, and debugging.
  • Repository Coding Standards: Established specific coding standards for using the Copilot SDK within the repository, emphasizing proper cleanup, error handling, token security, and tool schema validation.
Changelog
  • .github/copilot-instructions.md
    • Added a new markdown file providing comprehensive instructions and quick references for AI coding agents on how to effectively use the GitHub Copilot SDK.
Ignored Files
  • Ignored by pattern: .github/workflows/** (1)
    • .github/workflows/copilot-sdk-expert.md
Activity
  • No human activity has been recorded on this pull request yet.
Using Gemini Code Assist

The full guide for Gemini Code Assist can be found on our documentation page, here are some quick tips.

Invoking Gemini

You can request assistance from Gemini at any point by creating a comment using either /gemini <command> or @gemini-code-assist <command>. Below is a summary of the supported commands on the current page.

Feature Command Description
Code Review /gemini review Performs a code review for the current pull request in its current state.
Pull Request Summary /gemini summary Provides a summary of the current pull request in its current state.
Comment @gemini-code-assist Responds in comments when explicitly tagged, both in pull request comments and review comments.
Help /gemini help Displays a list of available commands.

Customization

To customize Gemini Code Assist for GitHub experience, repository maintainers can create a configuration file and/or provide a custom code review style guide (such as PEP-8 for Python) by creating and adding files to a .gemini/ folder in the base of the repository. Detailed instructions can be found here.

Limitations & Feedback

Gemini Code Assist may make mistakes. Please leave feedback on any instances where its feedback is incorrect or counter productive. You can react with 👍 and 👎 on @gemini-code-assist comments. If you're interested in giving your feedback about your experience with Gemini Code Assist for Github and other Google products, sign up here.

You can also get AI-powered code generation, chat, as well as code reviews directly in the IDE at no cost with the Gemini Code Assist IDE Extension.

Footnotes

  1. Review the Privacy Notices, Generative AI Prohibited Use Policy, Terms of Service, and learn how to configure Gemini Code Assist in GitHub here. Gemini can make mistakes, so double check it and use code with caution.

Copy link
Copy Markdown

@gemini-code-assist gemini-code-assist bot left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Code Review

This pull request introduces a new agent instruction file for the GitHub Copilot SDK. The file is well-structured and provides a comprehensive overview. I've identified a few inconsistencies in the code examples where they don't adhere to the best practices defined in the same document. I've suggested corrections to ensure the examples are robust and align with the stated coding standards, which is crucial for correctly instructing an AI agent.

Comment on lines +38 to +42
const client = new CopilotClient();
const session = await client.createSession({ model: "gpt-4.1" });
const response = await session.sendAndWait({ prompt: "Hello!" });
console.log(response?.data.content);
await client.stop();
Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

high

The TypeScript example doesn't follow the cleanup best practice mentioned in the 'Coding Standards for This Repository' section (rule #1). If an error occurs during session creation or sending the prompt, client.stop() will not be called, potentially leaving a CLI process orphaned. Using a try...finally block ensures cleanup happens even if errors occur.

Suggested change
const client = new CopilotClient();
const session = await client.createSession({ model: "gpt-4.1" });
const response = await session.sendAndWait({ prompt: "Hello!" });
console.log(response?.data.content);
await client.stop();
const client = new CopilotClient();
try {
const session = await client.createSession({ model: "gpt-4.1" });
const response = await session.sendAndWait({ prompt: "Hello!" });
console.log(response?.data.content);
} finally {
await client.stop();
}

Comment on lines +50 to +56
async def main():
client = CopilotClient()
await client.start()
session = await client.create_session({"model": "gpt-4.1"})
response = await session.send_and_wait({"prompt": "Hello!"})
print(response.data.content)
await client.stop()
Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

high

The Python example doesn't follow the cleanup best practice mentioned in the 'Coding Standards for This Repository' section (rule #1). If an error occurs after starting the client, client.stop() will not be called, potentially leaving a CLI process orphaned. Using a try...finally block ensures the client is always stopped.

Suggested change
async def main():
client = CopilotClient()
await client.start()
session = await client.create_session({"model": "gpt-4.1"})
response = await session.send_and_wait({"prompt": "Hello!"})
print(response.data.content)
await client.stop()
async def main():
client = CopilotClient()
try:
await client.start()
session = await client.create_session({"model": "gpt-4.1"})
response = await session.send_and_wait({"prompt": "Hello!"})
print(response.data.content)
finally:
await client.stop()

Comment on lines +65 to +69
_ = client.Start(ctx)
defer client.Stop()
session, _ := client.CreateSession(ctx, &copilot.SessionConfig{Model: "gpt-4.1"})
response, _ := session.SendAndWait(ctx, copilot.MessageOptions{Prompt: "Hello!"})
fmt.Println(*response.Data.Content)
Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

high

The Go example ignores potential errors from client.Start, client.CreateSession, and session.SendAndWait, which contradicts rule google-gemini#2 of the 'Coding Standards' ("Handle errors"). Additionally, it directly dereferences response.Data.Content without checking for nil, which could lead to a panic. The example should demonstrate proper error handling and nil checks.

Suggested change
_ = client.Start(ctx)
defer client.Stop()
session, _ := client.CreateSession(ctx, &copilot.SessionConfig{Model: "gpt-4.1"})
response, _ := session.SendAndWait(ctx, copilot.MessageOptions{Prompt: "Hello!"})
fmt.Println(*response.Data.Content)
if err := client.Start(ctx); err != nil {
log.Fatalf("failed to start client: %v", err)
}
defer client.Stop()
session, err := client.CreateSession(ctx, &copilot.SessionConfig{Model: "gpt-4.1"})
if err != nil {
log.Fatalf("failed to create session: %v", err)
}
response, err := session.SendAndWait(ctx, copilot.MessageOptions{Prompt: "Hello!"})
if err != nil {
log.Fatalf("failed to send message: %v", err)
}
if response != nil && response.Data != nil && response.Data.Content != nil {
fmt.Println(*response.Data.Content)
}

Copy link
Copy Markdown

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

Adds an agentic “Copilot SDK Expert” workflow plus repository-wide agent instructions to help AI coding agents review/triage Copilot SDK usage and respond to /sdk slash commands with SDK-specific guidance.

Changes:

  • Added a gh-aw agentic workflow to review PRs/issues for Copilot SDK usage and respond to /sdk and /copilot-sdk commands.
  • Added .github/copilot-instructions.md to provide SDK architecture, usage patterns, and repo coding standards for AI agents.

Reviewed changes

Copilot reviewed 2 out of 2 changed files in this pull request and generated 5 comments.

File Description
.github/workflows/copilot-sdk-expert.md Introduces the agentic workflow definition, tools/network allowances, and the embedded SDK “knowledge base” + task prompts.
.github/copilot-instructions.md Adds persistent agent instructions and quick-start examples for Copilot SDK usage across languages.

💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.

Comment on lines +18 to +19
issues: read
pull-requests: read
Copy link

Copilot AI Mar 2, 2026

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

The workflow is configured to add comments, add labels, and create/submit PR reviews, but the declared GitHub permissions are read-only for issues and pull-requests. This will prevent add-comment, add-labels, and PR review actions from succeeding. Update permissions to include the minimum required write scopes (typically issues: write and pull-requests: write; contents: read can remain read-only).

Suggested change
issues: read
pull-requests: read
issues: write
pull-requests: write

Copilot uses AI. Check for mistakes.
Comment on lines +65 to +69
_ = client.Start(ctx)
defer client.Stop()
session, _ := client.CreateSession(ctx, &copilot.SessionConfig{Model: "gpt-4.1"})
response, _ := session.SendAndWait(ctx, copilot.MessageOptions{Prompt: "Hello!"})
fmt.Println(*response.Data.Content)
Copy link

Copilot AI Mar 2, 2026

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This Go example discards errors from Start, CreateSession, and SendAndWait, and then unconditionally dereferences *response.Data.Content, which can panic if response, Data, or Content is nil. Since this is a “Hello World” meant to be copied, it should demonstrate basic error handling and safe printing (or at least avoid unsafe dereferences).

Suggested change
_ = client.Start(ctx)
defer client.Stop()
session, _ := client.CreateSession(ctx, &copilot.SessionConfig{Model: "gpt-4.1"})
response, _ := session.SendAndWait(ctx, copilot.MessageOptions{Prompt: "Hello!"})
fmt.Println(*response.Data.Content)
if err := client.Start(ctx); err != nil {
log.Fatalf("failed to start client: %v", err)
}
defer client.Stop()
session, err := client.CreateSession(ctx, &copilot.SessionConfig{Model: "gpt-4.1"})
if err != nil {
log.Fatalf("failed to create session: %v", err)
}
response, err := session.SendAndWait(ctx, copilot.MessageOptions{Prompt: "Hello!"})
if err != nil {
log.Fatalf("failed to send message: %v", err)
}
if response != nil && response.Data != nil && response.Data.Content != nil {
fmt.Println(*response.Data.Content)
}

Copilot uses AI. Check for mistakes.
Comment on lines +39 to +42
const session = await client.createSession({ model: "gpt-4.1" });
const response = await session.sendAndWait({ prompt: "Hello!" });
console.log(response?.data.content);
await client.stop();
Copy link

Copilot AI Mar 2, 2026

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

The TypeScript quick-start stops the client only on the happy path. If createSession / sendAndWait throws, the CLI process may be left running. Since this document later mandates cleanup via finally, update the minimal example to reflect that guidance (e.g., ensure client.stop() runs even on errors).

Suggested change
const session = await client.createSession({ model: "gpt-4.1" });
const response = await session.sendAndWait({ prompt: "Hello!" });
console.log(response?.data.content);
await client.stop();
try {
const session = await client.createSession({ model: "gpt-4.1" });
const response = await session.sendAndWait({ prompt: "Hello!" });
console.log(response?.data.content);
} finally {
await client.stop();
}

Copilot uses AI. Check for mistakes.
Comment on lines +53 to +56
session = await client.create_session({"model": "gpt-4.1"})
response = await session.send_and_wait({"prompt": "Hello!"})
print(response.data.content)
await client.stop()
Copy link

Copilot AI Mar 2, 2026

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Similar to the TS example, the Python quick-start stops the client only on the success path. If a call raises, client.stop() won’t run. Since these instructions emphasize avoiding orphaned CLI processes, consider wrapping the body in try/finally so cleanup is guaranteed.

Suggested change
session = await client.create_session({"model": "gpt-4.1"})
response = await session.send_and_wait({"prompt": "Hello!"})
print(response.data.content)
await client.stop()
try:
session = await client.create_session({"model": "gpt-4.1"})
response = await session.send_and_wait({"prompt": "Hello!"})
print(response.data.content)
finally:
await client.stop()

Copilot uses AI. Check for mistakes.
Comment on lines +201 to +203
By default the SDK operates with `--allow-all`, enabling all first-party tools
(file system, Git, web requests). Customize via session config.

Copy link

Copilot AI Mar 2, 2026

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This statement (even if accurate) describes a highly permissive default that enables filesystem/Git/web-capable tools, which can be unsafe when copied into real deployments. Consider adding an explicit warning and a least-privilege recommendation (e.g., disable/limit tools by default and only enable what’s required) so the workflow/instructions don’t normalize broad tool access.

Suggested change
By default the SDK operates with `--allow-all`, enabling all first-party tools
(file system, Git, web requests). Customize via session config.
Some examples and setups may use `--allow-all`, which enables all first-party tools
(file system, Git, web requests). This is a highly permissive mode and can be unsafe
in production or when working with untrusted code or data.
For production and security-sensitive environments, follow a least-privilege model:
start with tools disabled or minimally scoped, and explicitly enable only the specific
capabilities you need (for example, read-only filesystem access, and no Git/web access
unless strictly required) via session configuration or CLI flags.

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