Add Copilot SDK Java instructions file#13
Merged
brunoborges merged 6 commits intomainfrom Mar 17, 2026
Merged
Conversation
Add instructions/copilot-sdk-java.instructions.md modeled after the C# equivalent in github/awesome-copilot. Covers client initialization, session management, event handling, streaming, custom tools, BYOK, permissions, and common usage patterns for Java developers. Co-authored-by: Copilot <223556219+Copilot@users.noreply.github.com>
Contributor
There was a problem hiding this comment.
Pull request overview
Adds a new Copilot instruction file intended to guide Java developers in using copilot-sdk-java, covering client/session setup, event handling, streaming, tools, hooks, and BYOK provider configuration.
Changes:
- Introduces
instructions/copilot-sdk-java.instructions.mdwith end-to-end usage patterns for the SDK. - Documents key SDK APIs (client options, session config, events, tools, permissions, user input, etc.).
- Includes copy/paste code samples for common workflows (streaming, tools, hooks, BYOK).
Comments suppressed due to low confidence (5)
instructions/copilot-sdk-java.instructions.md:31
- Gradle example uses the wrong groupId (
com.github.copilot). It should match the published coordinates used by this project (groupIdcom.github, artifactIdcopilot-sdk-java).
```groovy
implementation 'com.github.copilot:copilot-sdk-java:LATEST'
**instructions/copilot-sdk-java.instructions.md:760**
* `SessionHooks.setOnPostToolUse(...)` also takes `(input, invocation)` and returns `CompletableFuture<PostToolUseHookOutput>` (nullable). The one-parameter lambda in this snippet won’t compile; update it to match the handler signature.
.setOnPostToolUse(hook -> {
System.out.println("Tool execution complete: " + hook);
return CompletableFuture.completedFuture(null);
}))
**instructions/copilot-sdk-java.instructions.md:242**
* `setEventErrorHandler` expects an `EventErrorHandler` with signature `(event, exception) -> { ... }`, not a single-parameter lambda. Update the sample to accept both the event being dispatched and the thrown exception.
// Set a custom error handler
session.setEventErrorHandler(ex -> {
logger.error("Event handler error", ex);
});
**instructions/copilot-sdk-java.instructions.md:394**
* The permission result kind string in this example ("user-denied") doesn’t match the well-known kinds used elsewhere in this SDK/tests (e.g., "denied-interactively-by-user" or `PermissionRequestResultKind.DENIED_INTERACTIVELY_BY_USER`). Using the well-known values (or the `PermissionRequestResultKind` constants) avoids interoperability issues with the CLI.
if ("dangerous-action".equals(request.getKind())) {
return CompletableFuture.completedFuture(
new PermissionRequestResult().setKind("user-denied")
);
}
**instructions/copilot-sdk-java.instructions.md:531**
* This Azure BYOK example won’t compile against the current SDK: `AzureOptions` only supports `setApiVersion(...)`, and the tested provider type is `"azure-openai"` with `ProviderConfig.setBaseUrl(...)` + `setApiKey(...)` (see `ProviderConfigTest`). Please update the snippet to match the actual `ProviderConfig`/`AzureOptions` API so users can copy/paste it successfully.
var session = client.createSession(new SessionConfig()
.setProvider(new ProviderConfig()
.setType("azure")
.setAzure(new AzureOptions()
.setEndpoint("https://my-resource.openai.azure.com")
.setDeployment("gpt-4"))
</details>
---
You can also share your feedback on Copilot code review. [Take the survey](https://www.surveymonkey.com/r/XP6L3XJ).
Co-authored-by: Copilot Autofix powered by AI <175728472+Copilot@users.noreply.github.com>
Co-authored-by: Copilot Autofix powered by AI <175728472+Copilot@users.noreply.github.com>
Co-authored-by: Copilot Autofix powered by AI <175728472+Copilot@users.noreply.github.com>
Co-authored-by: Copilot Autofix powered by AI <175728472+Copilot@users.noreply.github.com>
Co-authored-by: Copilot Autofix powered by AI <175728472+Copilot@users.noreply.github.com>
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Adds
instructions/copilot-sdk-java.instructions.md— a comprehensive guide for building Java applications with the Copilot SDK.Modeled after the C# equivalent at
github/awesome-copilot, adapted to Java idioms:CopilotClientandCopilotClientOptionson()subscriptions and pattern matchingToolDefinition.create()with type-safe argument deserializationThe frontmatter
applyTotargets**.javaand**/pom.xmlfiles.