Conversation
There was a problem hiding this comment.
Sorry @matheus-rech, you have reached your weekly rate limit of 500000 diff characters.
Please try again later or upgrade to continue using Sourcery
Summary of ChangesHello, 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
Changelog
Ignored Files
Activity
Using Gemini Code AssistThe 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
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 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
|
There was a problem hiding this comment.
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.
| 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(); |
There was a problem hiding this comment.
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.
| 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(); | |
| } |
| 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() |
There was a problem hiding this comment.
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.
| 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() |
| _ = 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) |
There was a problem hiding this comment.
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.
| _ = 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) | |
| } |
There was a problem hiding this comment.
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
/sdkand/copilot-sdkcommands. - Added
.github/copilot-instructions.mdto 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.
| issues: read | ||
| pull-requests: read |
There was a problem hiding this comment.
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).
| issues: read | |
| pull-requests: read | |
| issues: write | |
| pull-requests: write |
| _ = 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) |
There was a problem hiding this comment.
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).
| _ = 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) | |
| } |
| const session = await client.createSession({ model: "gpt-4.1" }); | ||
| const response = await session.sendAndWait({ prompt: "Hello!" }); | ||
| console.log(response?.data.content); | ||
| await client.stop(); |
There was a problem hiding this comment.
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).
| 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(); | |
| } |
| session = await client.create_session({"model": "gpt-4.1"}) | ||
| response = await session.send_and_wait({"prompt": "Hello!"}) | ||
| print(response.data.content) | ||
| await client.stop() |
There was a problem hiding this comment.
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.
| 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() |
| By default the SDK operates with `--allow-all`, enabling all first-party tools | ||
| (file system, Git, web requests). Customize via session config. | ||
|
|
There was a problem hiding this comment.
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.
| 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. |
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/sdkslash 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: