GitHub Copilot is a programmable AI platform — let me show you how!
JavaOne | 2026
github.com/github/copilot-sdk-java
🏗️ The SDK
🤖 Built with AI Agents
Whether you want to extend Copilot or rethink how you ship software with AI, this talk has something for you.
What most developers use today: inline suggestions, chat, code review.
A standalone process you can spawn and control programmatically — the foundation of the SDK.
Autonomous agent that can open PRs, fix issues, run tests — orchestrated through GitHub.
The Copilot CLI exposes a JSON-RPC API over stdio.
The SDK wraps that API with idiomatic Java — sessions, events, tools.
<dependency>
<groupId>com.github</groupId>
<artifactId>copilot-sdk-java</artifactId>
<version>0.1.32-java.0</version>
</dependency>
The CLI handles auth, protocol, model routing. Your app just sends messages and handles events.
// Works with JBang — no project setup needed!
// //DEPS com.github:copilot-sdk-java:0.1.32-java.0
import com.github.copilot.sdk.*;
import com.github.copilot.sdk.events.*;
import com.github.copilot.sdk.json.*;
try (var client = new CopilotClient()) {
client.start().get(); // spawn Copilot CLI
var session = client.createSession(
new SessionConfig()
.setOnPermissionRequest(PermissionHandler.APPROVE_ALL)
.setModel("claude-sonnet-4.5")
).get();
var response = session.sendAndWait(
new MessageOptions().setPrompt("What is 2 + 2?")
).get();
System.out.println(response.getData().content()); // 4
}
CopilotClient · CopilotSession · MessageOptionsvar done = new CompletableFuture<Void>();
// Print each word as it arrives
session.on(AssistantMessageDeltaEvent.class, delta -> {
System.out.print(delta.getData().deltaContent()); // streaming chunk
});
// Know exactly when the model is done
session.on(SessionIdleEvent.class, idle -> {
System.out.println();
done.complete(null);
});
// Track token consumption
session.on(SessionUsageInfoEvent.class, usage -> {
var d = usage.getData();
System.out.printf("Tokens: %d / %d%n",
(int) d.currentTokens(), (int) d.tokenLimit());
});
session.send(new MessageOptions().setPrompt("Tell me a haiku about Java")).get();
done.get();
// Give Copilot the ability to call your code
var weatherTool = ToolDefinition.create(
"get_weather",
"Return current weather for a city",
Map.of(
"type", "object",
"properties", Map.of(
"city", Map.of("type", "string", "description", "City name")
),
"required", List.of("city")
),
invocation -> {
String city = (String) invocation.getArguments().get("city");
String weather = MyWeatherService.fetch(city); // your logic
return CompletableFuture.completedFuture(
new ToolResult().setContent(weather)
);
}
);
var session = client.createSession(
new SessionConfig()
.setOnPermissionRequest(PermissionHandler.APPROVE_ALL)
.setTools(List.of(weatherTool))
).get();
Mount a Model Context Protocol server and Copilot gains tools automatically.
// Give Copilot access to your filesystem
Map<String, Object> fsServer = Map.of(
"type", "local",
"command", "npx",
"args", List.of(
"-y",
"@modelcontextprotocol/server-filesystem",
"/tmp"
),
"tools", List.of("*")
);
var session = client.createSession(
new SessionConfig()
.setOnPermissionRequest(
PermissionHandler.APPROVE_ALL)
.setMcpServers(Map.of("fs", fsServer))
).get();
Map.of(
"type", "http",
"url", "https://api.example.com/mcp",
"headers", Map.of(
"Authorization", "Bearer " + token),
"tools", List.of("*")
)
// Save
String id = session.getSessionId();
// Later…
var s2 = client.resumeSession(
new ResumeSessionConfig()
.setSessionId(id)
.setOnPermissionRequest(...)
).get();
// Run sessions concurrently
var coder = client.createSession(
new SessionConfig()
.setModel("gpt-5")).get();
var reviewer = client.createSession(
new SessionConfig()
.setModel("claude-sonnet-4.5")
).get();
// Summarise history to
// stay within token limit
session.compact().get();
// Hot-swap model mid-chat
session.setModel("o3").get();
// Every createSession / resumeSession MUST provide a permission handler
var session = client.createSession(
new SessionConfig()
.setOnPermissionRequest((request, invocation) -> {
// request.getPermissionKind() — what is being asked
// invocation.getToolName() — which tool wants permission
// invocation.getArguments() — what arguments it will use
if (request.getPermissionKind().equals("write_file")) {
boolean ok = promptUser("Allow writing to " + invocation.getArguments().get("path") + "?");
return CompletableFuture.completedFuture(
new PermissionRequestResult().setKind(ok ? "allow" : "deny")
);
}
// Approve everything else (convenient for development)
return CompletableFuture.completedFuture(
new PermissionRequestResult().setKind("allow")
);
})
).get();
onPermissionRequest · onBeforeToolExecution · onAfterToolExecution · onBeforeUserInput · onUserInputThe JMeter Copilot Plugin (github.com/brunoborges/jmeter-copilot-plugin) adds an AI-powered load-test assistant to Apache JMeter.
CopilotSession on plugin startupHow we used GitHub Copilot's own agentic capabilities
to build and maintain the SDK
The SDK tracks the official .NET reference implementation.
upstream-syncTracks the last upstream commit SHA.
a3f91cb
Each release records the upstream sync point in CHANGELOG.md.
The merge workflow is a .prompt.md file — 11 explicit steps, referenced by VS Code Copilot Chat as a slash command.
A reusable prompt asks the agent to audit documentation against the public API.
DocumentationSamplesTest guards against regressions:
Every pull request in this repo follows an agentic workflow:
Agent creates a feature branch, implements the change, runs mvn spotless:apply.
Runs mvn verify, triggers code_review and codeql_checker tools, addresses feedback.
commit-as-pull-request skill: creates branch, pushes, opens PR, squash-merges, syncs main.
The agent uses the SDK it is maintaining to orchestrate its own merge workflows — meta AI engineering.
Custom skills defined as .prompt.md files are registered in .github/copilot-instructions.md.
/agentic-merge-upstream — port .NET changes to Java/documentation-coverage — audit docs vs public API/commit-as-pull-request — automate the full PR workflowSkills can be invoked from:
/skill-nameTreating prompts as versioned, testable code (not chat history) is what makes agentic workflows repeatable and maintainable.
✅ What worked well
⚠️ Watch out for
Build a Copilot-powered CLI in 15 minutes with JBang — no project setup needed.
A single .java file that asks Copilot questions from the terminal. Add custom tools, streaming, and session persistence.
jbang init MyCopilot.java
# add //DEPS header
# run with: jbang MyCopilot.java
A Maven plugin that adds an AI-assisted copilot:review goal to any project.
mvn archetype:generate \
-DarchetypeArtifactId=\
maven-archetype-plugin
# add SDK dependency
# run: mvn copilot:review
Lab instructions → docs/javaone/lab.md in the repository
SDK
Related
Try it right now
# Run the example directly from GitHub
jbang https://github.com/github/copilot-sdk-java/blob/latest/jbang-example.java
Lab files
docs/javaone/
slides.html ← you are here
lab.md ← hands-on instructions
GitHub Copilot is a programmable AI platform.
The Java SDK lets you build with it natively in the JVM ecosystem.
And the whole thing was built — and is maintained — with AI agents.
github.com/github/copilot-sdk-java
⚠️ Unofficial, community-driven SDK. Not supported or endorsed by GitHub.