docs: add Java language tabs across all SDK documentation#1021
docs: add Java language tabs across all SDK documentation#1021patniko merged 13 commits intogithub:mainfrom
Conversation
Add Java code examples to all 22 language-tabbed documentation files, matching the existing Node.js, Python, Go, and .NET tabs. Files updated: - docs/getting-started.md (8 sections + telemetry table + text refs) - docs/features/ (7 files: index, hooks, custom-agents, image-input, streaming-events, steering-and-queueing, skills) - docs/hooks/ (6 files: index, pre-tool-use, post-tool-use, user-prompt-submitted, session-lifecycle, error-handling) - docs/auth/ (2 files: index, byok) - docs/setup/ (4 files: local-cli, bundled-cli, backend-services, github-oauth) - docs/observability/opentelemetry.md - docs/troubleshooting/debugging.md - docs/integrations/microsoft-agent-framework.md All Java examples use idiomatic patterns: CompletableFuture, try-with-resources, ToolDefinition.create(), PermissionHandler.APPROVE_ALL, typed event handlers, and builder-style configuration.
There was a problem hiding this comment.
Pull request overview
Adds Java as a first-class language tab across the SDK documentation in docs/, aiming to bring Java examples to parity with existing Node.js, Python, Go, and .NET snippets.
Changes:
- Added Java
<details>tabs and code samples across Getting Started, Features, Hooks, Auth/Setup, Observability, Troubleshooting, and Integrations docs. - Updated language lists/links and at least one cross-language configuration table to include Java.
- Documented Java-specific limitations/notes in a few places (e.g., no bundled CLI, MAF guidance).
Show a summary per file
| File | Description |
|---|---|
| docs/getting-started.md | Adds Java install + tutorial steps (first message, streaming, tools, assistant), plus references/links to Java SDK docs. |
| docs/features/index.md | Updates supported-language list to include Java. |
| docs/features/hooks.md | Adds Java hook registration + permission-control examples. |
| docs/features/custom-agents.md | Adds Java custom-agent configuration and sub-agent event examples. |
| docs/features/image-input.md | Adds Java file/blob attachment examples. |
| docs/features/streaming-events.md | Adds Java event subscription examples. |
| docs/features/steering-and-queueing.md | Adds Java steering/enqueue examples. |
| docs/features/skills.md | Adds Java skill directories + disabling skills examples. |
| docs/hooks/index.md | Adds Java hooks quickstart snippet. |
| docs/hooks/pre-tool-use.md | Adds Java pre-tool-use hook signature + usage example. |
| docs/hooks/post-tool-use.md | Adds Java post-tool-use hook signature + usage example. |
| docs/hooks/user-prompt-submitted.md | Adds Java user-prompt-submitted hook signature + usage example. |
| docs/hooks/session-lifecycle.md | Adds Java session start/end hook signatures. |
| docs/hooks/error-handling.md | Adds Java guidance for event error policy/handler in lieu of an error hook. |
| docs/auth/index.md | Adds Java examples for logged-in user, OAuth token usage, and disabling logged-in user. |
| docs/auth/byok.md | Adds Java BYOK/provider + custom model listing examples. |
| docs/setup/local-cli.md | Adds Java local-CLI quickstart snippet. |
| docs/setup/bundled-cli.md | Adds Java note about not bundling CLI + configuration example. |
| docs/setup/backend-services.md | Adds Java external CLI server connection example. |
| docs/setup/github-oauth.md | Adds Java per-user client creation example. |
| docs/observability/opentelemetry.md | Adds Java telemetry snippet and Java row in a table. |
| docs/troubleshooting/debugging.md | Adds Java debugging/logging configuration snippets and notes. |
| docs/integrations/microsoft-agent-framework.md | Adds Java guidance/snippets for using the standard SDK (no MAF integration package). |
Copilot's findings
Comments suppressed due to low confidence (4)
docs/integrations/microsoft-agent-framework.md:372
- These Java snippets use
getData().getContent()on the response objects, while other Java examples usedata.content()accessors. Please align on the correct Java API so these examples compile consistently.
).get();
var docs = documentor.sendAndWait(new MessageOptions()
.setPrompt("Write documentation for these changes: " + review.getData().getContent())).get();
System.out.println(docs.getData().getContent());
docs/integrations/microsoft-agent-framework.md:450
- These Java snippets use
getData().getContent()when printing the responses; other Java examples in the docs usedata.content(). Please align on the correct accessor to avoid non-compiling examples.
CompletableFuture.allOf(securityFuture, perfFuture).get();
System.out.println("Security: " + securityFuture.get().getData().getContent());
System.out.println("Performance: " + perfFuture.get().getData().getContent());
docs/features/steering-and-queueing.md:434
- This Java enqueue-mode example references
SessionConfig,PermissionHandler, andMessageOptionsbut only importsCopilotClient. Please add the missing SDK/json andjava.utilimports so the snippet compiles when copy/pasted.
```java
import com.github.copilot.sdk.CopilotClient;
try (var client = new CopilotClient()) {
client.start().get();
var session = client.createSession(
new SessionConfig()
.setModel("gpt-4.1")
.setOnPermissionRequest(PermissionHandler.APPROVE_ALL)
).get();
docs/features/image-input.md:452
- This Java blob-attachment snippet uses
SessionConfig,PermissionHandler,MessageOptions,List, andBlobAttachmentbut only importsCopilotClient. Please add the missingcom.github.copilot.sdk.json.*andjava.util.*imports (or fully qualify) so the example compiles.
```java
import com.github.copilot.sdk.CopilotClient;
try (var client = new CopilotClient()) {
client.start().get();
var session = client.createSession(
new SessionConfig()
.setModel("gpt-4.1")
.setOnPermissionRequest(PermissionHandler.APPROVE_ALL)
).get();
var base64ImageData = "..."; // your base64-encoded image
session.send(new MessageOptions()
.setPrompt("Describe what you see in this image")
.setAttachments(List.of(
new BlobAttachment()
.setData(base64ImageData)
.setMimeType("image/png")
.setDisplayName("screenshot.png")
))
- Files reviewed: 23/23 changed files
- Comments generated: 15
Co-authored-by: Copilot <175728472+Copilot@users.noreply.github.com>
Co-authored-by: Copilot <175728472+Copilot@users.noreply.github.com>
Co-authored-by: Copilot <175728472+Copilot@users.noreply.github.com>
Co-authored-by: Copilot <175728472+Copilot@users.noreply.github.com>
- Fix Maven coordinates: com.github:copilot-sdk-java with version property - Fix accessor: getContent() → content() (record-style) across all files - Fix accessor: input.toolName() → input.getToolName() (class-style) - Fix accessor: event.deltaContent() → event.getData().deltaContent() - Fix ToolDefinition: use factory method create() instead of constructor - Add missing imports (json.*, events.*) to feature doc snippets - Add client.start().get() and try-with-resources to hooks quickstart - Wrap OAuth usage example in try-with-resources
There was a problem hiding this comment.
Pull request overview
This PR updates the SDK documentation set to include Java alongside the existing TypeScript, Python, Go, and .NET examples, aiming to bring Java to parity across all language-tabbed docs.
Changes:
- Added Java
<details>tabs and example snippets across 23 documentation pages indocs/. - Updated language lists/tables to include Java (e.g., features index, telemetry option tables).
- Added Java-specific notes where feature parity differs (e.g., bundled CLI / some hook differences).
Show a summary per file
| File | Description |
|---|---|
| docs/getting-started.md | Adds Java install + tutorial steps (first message, streaming, tools, interactive assistant) and updates language references/tables. |
| docs/features/index.md | Adds Java to the list of supported languages in feature guides. |
| docs/features/hooks.md | Adds Java examples for hook registration and permission-control patterns. |
| docs/features/custom-agents.md | Adds Java examples for defining/selecting custom agents and handling sub-agent events. |
| docs/features/image-input.md | Adds Java examples for file and blob image attachments. |
| docs/features/streaming-events.md | Adds Java examples for subscribing to streaming events. |
| docs/features/steering-and-queueing.md | Adds Java examples for steering and enqueue modes. |
| docs/features/skills.md | Adds Java examples for skill directories and disabling skills. |
| docs/hooks/index.md | Adds Java quick start for session hooks. |
| docs/hooks/pre-tool-use.md | Adds Java hook signature + usage examples for pre-tool-use. |
| docs/hooks/post-tool-use.md | Adds Java hook signature + usage examples for post-tool-use. |
| docs/hooks/user-prompt-submitted.md | Adds Java hook signature + usage examples for user prompt submitted. |
| docs/hooks/session-lifecycle.md | Adds Java hook signature examples for session start/end. |
| docs/hooks/error-handling.md | Adds Java guidance for error handling (Java-specific approach). |
| docs/auth/index.md | Adds Java examples for logged-in user auth and explicit token auth. |
| docs/auth/byok.md | Adds Java BYOK configuration and custom model listing examples. |
| docs/setup/local-cli.md | Adds Java quick start for local CLI usage. |
| docs/setup/bundled-cli.md | Adds Java note + example clarifying Java does not bundle the CLI. |
| docs/setup/backend-services.md | Adds Java example for connecting to an external CLI server. |
| docs/setup/github-oauth.md | Adds Java per-user OAuth client/session example. |
| docs/observability/opentelemetry.md | Adds Java telemetry configuration example and extends TelemetryConfig options/dependency tables. |
| docs/troubleshooting/debugging.md | Adds Java snippets for enabling debug logging and troubleshooting setup/auth. |
| docs/integrations/microsoft-agent-framework.md | Adds Java guidance/examples for using the standard SDK directly (no MAF package). |
Copilot's findings
Comments suppressed due to low confidence (3)
docs/features/custom-agents.md:363
- This Java snippet uses
List.of(...)but doesn't include any imports. Please addimport java.util.List;(and the relevant SDK imports if needed) so the example is copy/pasteable.
var session = client.createSession(
new SessionConfig()
.setCustomAgents(List.of(
new CustomAgentConfig()
.setName("researcher")
docs/features/image-input.md:456
- This Java blob-attachment example uses
List.of(...)but doesn't importjava.util.List, so it won't compile as shown. Please add the missing import (or qualify it).
var base64ImageData = "..."; // your base64-encoded image
session.send(new MessageOptions()
.setPrompt("Describe what you see in this image")
.setAttachments(List.of(
new BlobAttachment()
.setData(base64ImageData)
.setMimeType("image/png")
.setDisplayName("screenshot.png")
))
docs/features/skills.md:285
- This Java skills snippet uses
List.of(...)but doesn't importjava.util.List, so it won't compile as shown. Please add the missing import (or qualify it).
var session = client.createSession(
new SessionConfig()
.setSkillDirectories(List.of("./skills"))
.setDisabledSkills(List.of("experimental-feature", "deprecated-tool"))
.setOnPermissionRequest(PermissionHandler.APPROVE_ALL)
).get();
- Files reviewed: 23/23 changed files
- Comments generated: 20
|
|
||
| var session = client.createSession(new SessionConfig() | ||
| .setModel("gpt-4.1")).get(); | ||
|
|
There was a problem hiding this comment.
This Java example creates a session without setOnPermissionRequest(...). The Java SDK docs indicate an on-permission handler is required; please add setOnPermissionRequest(PermissionHandler.APPROVE_ALL) (or another handler) to keep the snippet runnable.
docs/setup/backend-services.md
Outdated
| var session = client.createSession(new SessionConfig() | ||
| .setSessionId(String.format("user-%s-%d", userId, System.currentTimeMillis() / 1000)) | ||
| .setModel("gpt-4.1") | ||
| ).get(); | ||
|
|
||
| var response = session.sendAndWait(new MessageOptions() | ||
| .setPrompt(message)).get(); |
There was a problem hiding this comment.
The Java backend-services snippet uses userId and message but doesn't define them in the block, unlike the .NET example above. Please add minimal placeholder declarations so the example is self-contained.
| var session = client.createSession( | ||
| new SessionConfig() | ||
| .setModel("gpt-4.1") | ||
| .setStreaming(true) |
There was a problem hiding this comment.
This Java streaming example creates a session without setOnPermissionRequest(...). The Java SDK docs indicate an on-permission handler is required when creating sessions; please add it here to keep the tutorial runnable.
| .setStreaming(true) | |
| .setStreaming(true) | |
| .setOnPermissionRequest(request -> PermissionDecision.allow()) |
| import com.github.copilot.sdk.CopilotClient; | ||
| import com.github.copilot.sdk.CopilotClientOptions; | ||
|
|
||
| var client = new CopilotClient(new CopilotClientOptions() | ||
| .setTelemetry(new TelemetryConfig() | ||
| .setOtlpEndpoint("http://localhost:4318"))); | ||
| ``` |
There was a problem hiding this comment.
The Java telemetry snippet uses TelemetryConfig but doesn't import it (unlike other Java examples that import com.github.copilot.sdk.json.*). Please add the missing import so the snippet compiles as shown.
- Fix PreToolUseHookOutput: record cannot use setters, use deny() factory - Fix SessionStartHookOutput: record cannot use setters, use constructor - Fix session.getId() → session.getSessionId() - Fix input.getPrompt() → input.prompt() (record accessor) - Fix response.data() → response.getData() (class accessor) - Fix setOnListModels: wrap return in CompletableFuture.completedFuture() - Fix custom-agents event handler: use instanceof pattern matching (AbstractSessionEvent has no getData() method) - Fix streaming-events: remove event.getData() from generic handler - Fix SubagentCompleted/Failed: use agentName() not agentDisplayName() - Fix CopilotClientOptions import: class is in json package, not sdk - Fix hook type signatures: use PreToolUseHandler etc. instead of BiFunction
Co-authored-by: Copilot <175728472+Copilot@users.noreply.github.com>
Co-authored-by: Copilot <175728472+Copilot@users.noreply.github.com>
Co-authored-by: Copilot <175728472+Copilot@users.noreply.github.com>
Co-authored-by: Copilot <175728472+Copilot@users.noreply.github.com>
Co-authored-by: Copilot <175728472+Copilot@users.noreply.github.com>
Co-authored-by: Copilot <175728472+Copilot@users.noreply.github.com>
Summary
Adds Java code examples to all 23 language-tabbed documentation files in
docs/, bringing Java to parity with Node.js, Python, Go, and .NET.51 Java tabs added — matching exactly the 51 .NET tabs across the docs.
Files changed (23 files, +1,335 lines)
Getting Started
docs/getting-started.md— All 8 tutorial steps + telemetry table + text references + Learn More linksFeatures
docs/features/index.md— Updated language list to include Javadocs/features/hooks.md— Registering hooks, permission controldocs/features/custom-agents.md— Defining agents, selection, sub-agent eventsdocs/features/image-input.md— File and blob attachmentsdocs/features/streaming-events.md— Event subscriptiondocs/features/steering-and-queueing.md— Steering and queue modesdocs/features/skills.md— Loading and disabling skillsHooks Reference
docs/hooks/index.md— Quick startdocs/hooks/pre-tool-use.md— Signature, allow-all exampledocs/hooks/post-tool-use.md— Signature, logging exampledocs/hooks/user-prompt-submitted.md— Signature, logging exampledocs/hooks/session-lifecycle.md— Start and end hooksdocs/hooks/error-handling.md— Error policy and handlerAuth & Setup
docs/auth/index.md— Signed-in user, OAuth, auto-logindocs/auth/byok.md— Azure AI Foundry, custom model listingdocs/setup/local-cli.md— Quick startdocs/setup/bundled-cli.md— Note: Java doesn't bundle CLIdocs/setup/backend-services.md— External CLI serverdocs/setup/github-oauth.md— Per-user token configOther
docs/observability/opentelemetry.md— Telemetry config + tablesdocs/troubleshooting/debugging.md— Debug logging, CLI issuesdocs/integrations/microsoft-agent-framework.md— Standalone SDK usage (Java has no MAF package)Java SDK patterns used
All examples use idiomatic Java:
CompletableFuture.get()for blocking async callstry-with-resourcesfor client cleanup (AutoCloseable)ToolDefinition.create()/createOverride()/createSkipPermission()PermissionHandler.APPROVE_ALLsession.on(EventType.class, handler)new SessionConfig().setModel(...).setStreaming(true)