{"id":4775,"date":"2026-08-10T19:46:29","date_gmt":"2026-08-10T19:46:29","guid":{"rendered":"https:\/\/rssfeedtelegrambot.bnaya.co.il\/index.php\/2026\/08\/10\/using-the-github-copilot-sdk-for-java\/"},"modified":"2026-08-10T19:46:29","modified_gmt":"2026-08-10T19:46:29","slug":"using-the-github-copilot-sdk-for-java","status":"publish","type":"post","link":"https:\/\/rssfeedtelegrambot.bnaya.co.il\/index.php\/2026\/08\/10\/using-the-github-copilot-sdk-for-java\/","title":{"rendered":"Using the GitHub Copilot SDK for Java"},"content":{"rendered":"<p class=\"wp-block-paragraph\">Java developers no longer have to rely on Java framework-specific approaches to drive AI from their enterprise apps.<\/p>\n<p class=\"wp-block-paragraph\">While it is true that Langchain4j empowered developers by disintermediating specific AI vendors, you still had a dependency on Langchain4j. And with Spring AI, well, of course you had a dependency on design choices made by Spring, if not on Spring itself.<\/p>\n<p class=\"wp-block-paragraph\">Now, GitHub Copilot SDK for Java is the first truly framework agnostic way to drive AI from Java. And with its BYOK support, GitHub Copilot SDK for Java is also AI vendor neutral.<\/p>\n<figure class=\"wp-block-table\">\n<table class=\"has-fixed-layout\">\n<tbody>\n<tr>\n<td>\ud83d\udca1 Even though it\u2019s called GitHub Copilot SDK, you can use it with any direct model provider, such as OpenAI, Azure, Anthropic, or OpenAI-compatible endpoints, by passing a <code>provider<\/code>\/<code>ProviderConfig<\/code> with your own <code>baseUrl<\/code> + <code>apiKey<\/code> (or bearer token). No Copilot subscription required.<\/td>\n<\/tr>\n<\/tbody>\n<\/table>\n<\/figure>\n<p class=\"wp-block-paragraph\">The GitHub Copilot SDK for Java is a client library that empowers your server-side Java code to create Copilot agent sessions, register tools, send prompts, and receive structured responses\u2014all programmatically. It works in server environments, including Jakarta EE and Spring. If you\u2019ve been building enterprise Java for any length of time, this SDK will feel like home: <code>CompletableFuture<\/code>, annotations, lambdas, virtual threads, it\u2019s all here.<\/p>\n<p class=\"wp-block-paragraph\">This post shows you how to use the SDK, walks through a complete Jakarta EE 11 sample application, and leaves you with concrete next steps to try it yourself. I chose Jakarta EE 11 for my demo because I was the lead release coordinator for that release. I believe in open standards as the best way to empower developers. For more on Jakarta EE 11 see <a href=\"https:\/\/www.infoq.com\/news\/2025\/07\/jakarta-ee-11-updates\/\">this InfoQ article<\/a>.<\/p>\n<p class=\"wp-block-paragraph\">This sample app is an agent harness using Jakarta EE 11. But, of course, developers can build their own agent harness using the well-known Java frameworks and libraries of their choice.<\/p>\n<p class=\"wp-block-paragraph\"><a href=\"https:\/\/github.com\/microsoft\/Build26-BRK206-your-agent-anywhere-multiclient-multidevice-with-github-copilot-sdk\">Clone the sample app and try it yourself &gt;<\/a><\/p>\n<h2 class=\"wp-block-heading\">Where to get it<\/h2>\n<p class=\"wp-block-paragraph\">The SDK is available as a Maven dependency:<\/p>\n<div class=\"wp-block-code-wrapper\">\n<pre class=\"wp-block-code\"><code>&lt;dependency&gt;\n    &lt;groupId&gt;com.github&lt;\/groupId&gt;\n    &lt;artifactId&gt;copilot-sdk-java&lt;\/artifactId&gt;\n    &lt;version&gt;1.0.7-preview.1&lt;\/version&gt;\n&lt;\/dependency&gt;<\/code><\/pre>\n<\/div>\n<p class=\"wp-block-paragraph\"><strong>Prerequisites:<\/strong><\/p>\n<ul class=\"wp-block-list\">\n<li>JDK 17 or 25 (25 recommended \u2014 unlocks virtual threads and other modern features)<\/li>\n<li>Maven 3.9+<\/li>\n<li>A GitHub account with an active Copilot subscription<\/li>\n<li>The Copilot CLI installed locally at version 1.0.71 or later.<\/li>\n<\/ul>\n<h2 class=\"wp-block-heading\">Walk through the sample app<\/h2>\n<p class=\"wp-block-paragraph\">The best way to see the SDK in action is to run <a href=\"https:\/\/github.com\/microsoft\/Build26-BRK206-your-agent-anywhere-multiclient-multidevice-with-github-copilot-sdk\">this sample application<\/a>.<\/p>\n<h3 class=\"wp-block-heading\">Get the code<\/h3>\n<div class=\"wp-block-code-wrapper\">\n<pre class=\"wp-block-code\"><code>git clone https:\/\/github.com\/microsoft\/Build26-BRK206-your-agent-anywhere-multiclient-multidevice-with-github-copilot-sdk.git\ncd Build26-BRK206-your-agent-anywhere-multiclient-multidevice-with-github-copilot-sdk\/src\/java-agent-orchestrator\nmvn clean package liberty:run\n# Open http:\/\/localhost:9080\/index.xhtml<\/code><\/pre>\n<\/div>\n<p class=\"wp-block-paragraph\">The Java demo is built on:<\/p>\n<figure class=\"wp-block-table\">\n<table class=\"has-fixed-layout\">\n<thead>\n<tr>\n<th>Concern<\/th>\n<th>Technology<\/th>\n<\/tr>\n<\/thead>\n<tbody>\n<tr>\n<td>Runtime<\/td>\n<td>Open Liberty 26.0.0.5<\/td>\n<\/tr>\n<tr>\n<td>Platform<\/td>\n<td>Jakarta EE 11 (Faces 4.1, CDI 4.1, WebSocket 2.2, Data 1.0, Persistence 3.2)<\/td>\n<\/tr>\n<tr>\n<td>UI<\/td>\n<td>PrimeFaces 15.0.16<\/td>\n<\/tr>\n<tr>\n<td>AI orchestration<\/td>\n<td>Copilot SDK for Java 1.0.7-preview.1<\/td>\n<\/tr>\n<tr>\n<td>Database<\/td>\n<td>H2 in-memory (10 seed property listings)<\/td>\n<\/tr>\n<\/tbody>\n<\/table>\n<\/figure>\n<h3 class=\"wp-block-heading\">What the app does<\/h3>\n<p class=\"wp-block-paragraph\">The application is a real-estate lead-management agent pipeline. A customer submits an enquiry (\u201cI\u2019m looking for a 3-bedroom house in London under \u00a3800,000\u201d), and the system spins up an isolated Copilot Agent on a virtual thread to process it through a pipeline:<\/p>\n<figure class=\"wp-block-image size-large\"><img data-opt-id=1042403069  fetchpriority=\"high\" decoding=\"async\" data-recalc-dims=\"1\" height=\"173\" width=\"1024\" src=\"https:\/\/github.blog\/wp-content\/uploads\/2026\/08\/figure-01-app-flow-diagram.png?resize=1024%2C173\" alt=\"Application flow diagram showing the pipeline stages: Customer Enquiry flows to QUEUED, then VALIDATING, which branches to either SEARCHING (if genuine) or REJECTED (if spam\/off-topic). SEARCHING leads to WRITING_REPORT (if matches found) or NO MATCHES. WRITING_REPORT completes at DONE.\" class=\"wp-image-98000\" \/><\/figure>\n<p class=\"wp-block-paragraph\">The architecture uses Jakarta WebSocket to push real-time status updates from the server to the browser, so you can watch agents progress through phases as the model calls tools:<\/p>\n<figure class=\"wp-block-image size-large\"><img data-opt-id=210883941  fetchpriority=\"high\" decoding=\"async\" data-recalc-dims=\"1\" height=\"628\" width=\"1024\" src=\"https:\/\/github.blog\/wp-content\/uploads\/2026\/08\/figure-02-app-architecture-diagram.png?resize=1024%2C628\" alt=\"Application architecture diagram showing Browser with Pipeline Dashboard connecting to Open Liberty server containing AppState, CopilotClient in EMPTY mode, virtual thread agents, and WebSocket push for real-time UI updates.\" class=\"wp-image-98001\" \/><\/figure>\n<p class=\"wp-block-paragraph\">Submit multiple inquiries simultaneously to see concurrent virtual-thread agents in action. Each one processes independently with its own Copilot session.<\/p>\n<figure class=\"wp-block-image size-large\"><img data-opt-id=1974925299  data-opt-src=\"https:\/\/github.blog\/wp-content\/uploads\/2026\/08\/figure-03-sample-app-01.png\"  decoding=\"async\" data-recalc-dims=\"1\" height=\"940\" width=\"1024\" src=\"data:image/svg+xml,%3Csvg%20viewBox%3D%220%200%20100%%20100%%22%20width%3D%22100%%22%20height%3D%22100%%22%20xmlns%3D%22http%3A%2F%2Fwww.w3.org%2F2000%2Fsvg%22%3E%3Crect%20width%3D%22100%%22%20height%3D%22100%%22%20fill%3D%22transparent%22%2F%3E%3C%2Fsvg%3E?resize=1024%2C940\" alt=\"Screenshot of the sample application showing the pipeline dashboard with multiple enquiries being processed concurrently.\" class=\"wp-image-98002\" \/><\/figure>\n<figure class=\"wp-block-image size-large\"><img data-opt-id=64731815  data-opt-src=\"https:\/\/github.blog\/wp-content\/uploads\/2026\/08\/figure-04-sample-app-02.png\"  decoding=\"async\" data-recalc-dims=\"1\" loading=\"lazy\" height=\"1024\" width=\"778\" src=\"data:image/svg+xml,%3Csvg%20viewBox%3D%220%200%20100%%20100%%22%20width%3D%22100%%22%20height%3D%22100%%22%20xmlns%3D%22http%3A%2F%2Fwww.w3.org%2F2000%2Fsvg%22%3E%3Crect%20width%3D%22100%%22%20height%3D%22100%%22%20fill%3D%22transparent%22%2F%3E%3C%2Fsvg%3E?resize=778%2C1024\" alt=\"Screenshot of the sample application showing detailed agent event log and property search results.\" class=\"wp-image-98003\" \/><\/figure>\n<h3 class=\"wp-block-heading\">SDK features in action<\/h3>\n<p class=\"wp-block-paragraph\">Let\u2019s walk through the key SDK features as they appear in the sample code.<\/p>\n<h4 class=\"wp-block-heading\">Defining tools with <code>@CopilotTool<\/code><\/h4>\n<p class=\"wp-block-paragraph\">This is the headline API. If you\u2019ve ever written a <code>@GET<\/code> endpoint in JAX-RS or an <code>@MessageDriven<\/code> bean, this will feel instantly familiar:<\/p>\n<div class=\"wp-block-code-wrapper\">\n<pre class=\"wp-block-code\"><code>@CopilotTool(value = \"Sets the current phase of the agent. Use this to report progress.\",\n             name = \"set_current_phase\")\npublic String setCurrentPhase(\n        @CopilotToolParam(\"The phase to transition to (VALIDATING, SEARCHING, \"\n                + \"WRITING_REPORT, REJECTED_GARBAGE, REJECTED_NO_MATCHES, or DONE)\")\n        String phaseName) {\n    phase = Phase.valueOf(phaseName.trim().toUpperCase(Locale.ROOT));\n    notifyUi();\n    return \"Phase set to \" + phase.getLabel();\n}<\/code><\/pre>\n<\/div>\n<p class=\"wp-block-paragraph\">The <code>@CopilotTool<\/code> annotation declares the method as a tool the model can call. The <code>@CopilotToolParam<\/code> annotation describes each parameter so the model knows what to pass. The SDK handles all the JSON Schema generation, argument parsing, and dispatch. You just write a normal Java method.<\/p>\n<p class=\"wp-block-paragraph\"><strong>Two build prerequisites for <code>@CopilotTool<\/code>.<\/strong> The annotation-based tool API is currently an experimental feature of the SDK, so you need to configure two things in your Maven build:<\/p>\n<ol class=\"wp-block-list\">\n<li><strong>Enable experimental APIs<\/strong>: pass <code>-Acopilot.experimental.allowed=true<\/code> to the compiler. Without this flag, the annotation processor will refuse to generate the tool metadata. For more details on the experimental APIs see <a href=\"https:\/\/github.com\/github\/copilot-sdk\/tree\/main\/java#using-experimental-apis\">Copilot SDK documentation<\/a>.<\/li>\n<li><strong>Register the annotation processor<\/strong>: add the SDK as an <code>annotationProcessorPath<\/code> so the compiler can find the <code>@CopilotTool<\/code> processor and generate the <code>$$CopilotToolMeta<\/code> classes at compile time.<\/li>\n<\/ol>\n<p class=\"wp-block-paragraph\">Both are configured in the <code>maven-compiler-plugin<\/code>:<\/p>\n<div class=\"wp-block-code-wrapper\">\n<pre class=\"wp-block-code\"><code>&lt;plugin&gt;\n    &lt;groupId&gt;org.apache.maven.plugins&lt;\/groupId&gt;\n    &lt;artifactId&gt;maven-compiler-plugin&lt;\/artifactId&gt;\n    &lt;version&gt;3.15.0&lt;\/version&gt;\n    &lt;configuration&gt;\n        &lt;compilerArgs&gt;\n            &lt;arg&gt;-Acopilot.experimental.allowed=true&lt;\/arg&gt;\n        &lt;\/compilerArgs&gt;\n        &lt;annotationProcessorPaths&gt;\n            &lt;path&gt;\n                &lt;groupId&gt;com.github&lt;\/groupId&gt;\n                &lt;artifactId&gt;copilot-sdk-java&lt;\/artifactId&gt;\n                &lt;version&gt;1.0.7-preview.1&lt;\/version&gt;\n            &lt;\/path&gt;\n        &lt;\/annotationProcessorPaths&gt;\n    &lt;\/configuration&gt;\n&lt;\/plugin&gt;<\/code><\/pre>\n<\/div>\n<p class=\"wp-block-paragraph\">To register all annotated tools from an object:<\/p>\n<div class=\"wp-block-code-wrapper\">\n<pre class=\"wp-block-code\"><code>List&lt;ToolDefinition&gt; annotatedTools = ToolDefinition.fromObject(this);<\/code><\/pre>\n<\/div>\n<h4 class=\"wp-block-heading\">Inline lambda tools with <code>ToolDefinition.from(...)<\/code><\/h4>\n<p class=\"wp-block-paragraph\">When you want a tool defined at the call site without a dedicated method, use the lambda style:<\/p>\n<div class=\"wp-block-code-wrapper\">\n<pre class=\"wp-block-code\"><code>ToolDefinition reportIntentTool = ToolDefinition\n        .from(\"report_intent\",\n              \"Reports the current intent of the agent\",\n              Param.of(String.class, \"intent\", \"Intent in max 4 words\"),\n              (String intent) -&gt; {\n                  currentIntent = intent;\n                  addEvent(Instant.now(), \"intent\", \"Intent updated\", intent);\n                  notifyUi();\n                  return \"ok\";\n              })\n        .overridesBuiltInTool(true);<\/code><\/pre>\n<\/div>\n<p class=\"wp-block-paragraph\">Notice <code>.overridesBuiltInTool(true)<\/code>. This tells the SDK that our <code>report_intent<\/code> tool deliberately replaces a built-in tool of the same name. This is useful when you need custom behaviour for a tool the model already knows about.<\/p>\n<h4 class=\"wp-block-heading\">Cross-class tool scanning<\/h4>\n<p class=\"wp-block-paragraph\">Tools don\u2019t have to live in the same class as your agent logic. Here\u2019s <code>searchProperties<\/code> defined in a separate CDI bean:<\/p>\n<div class=\"wp-block-code-wrapper\">\n<pre class=\"wp-block-code\"><code>@ApplicationScoped\npublic class PropertyDatabase {\n\n    @CopilotTool(value = \"Searches the real estate listings database. \"\n                       + \"Returns up to 10 matching properties.\",\n                 name = \"search_properties\")\n    public List&lt;Property&gt; searchProperties(\n            @CopilotToolParam(\"Property type substring (e.g. 'flat', 'house')\") String type,\n            @CopilotToolParam(\"City substring (e.g. 'London', 'Bristol')\") String city,\n            @CopilotToolParam(\"Minimum number of bedrooms (0 for no minimum)\") int minBedrooms,\n            @CopilotToolParam(\"Maximum price in GBP (0 for no maximum)\") double maxPriceGbp) {\n        \/\/ ... filter and return matching properties ...\n    }\n}<\/code><\/pre>\n<\/div>\n<p class=\"wp-block-paragraph\">You would normally register these with <code>ToolDefinition.fromObject(propertyDatabase)<\/code>. In the sample app, we use a lambda wrapper instead, because CDI client proxies can obscure the annotation metadata.<\/p>\n<h4 class=\"wp-block-heading\">Customizing the system message<\/h4>\n<p class=\"wp-block-paragraph\">The SDK gives you fine-grained control over the system message. Use <code>SystemMessageMode.CUSTOMIZE<\/code> to replace specific sections while preserving the rest:<\/p>\n<div class=\"wp-block-code-wrapper\">\n<pre class=\"wp-block-code\"><code>SystemMessageConfig systemMessage = new SystemMessageConfig()\n        .setMode(SystemMessageMode.CUSTOMIZE)\n        .setSections(Map.of(SystemMessageSections.IDENTITY,\n            new SectionOverride()\n                .setAction(SectionOverrideAction.REPLACE)\n                .setContent(\"\"\"\n                    You are part of a real estate recommendation system.\n                    You will receive enquiries from customers, and you must\n                    carry out the following workflow...\n                    \"\"\")));<\/code><\/pre>\n<\/div>\n<p class=\"wp-block-paragraph\">The text block (<code>\"\"\"...\"\"\"<\/code>) makes multi-line prompts readable without string concatenation. The <code>IDENTITY<\/code> section override replaces only the model\u2019s self-description while leaving safety guardrails intact. If you prefer a simpler approach, <code>SystemMessageMode.APPEND<\/code> adds your content after the default system message without replacing anything.<\/p>\n<h4 class=\"wp-block-heading\">The agentic loop: <code>sendAndWait(...)<\/code><\/h4>\n<p class=\"wp-block-paragraph\">One line kicks off the full agentic loop:<\/p>\n<div class=\"wp-block-code-wrapper\">\n<pre class=\"wp-block-code\"><code>session = client.createSession(sessionConfig).get();\n\/\/ ...\nAssistantMessageEvent result = session.sendAndWait(escapedEnquiry).get();<\/code><\/pre>\n<\/div>\n<p class=\"wp-block-paragraph\">Behind <code>.get()<\/code>, the model reasons, calls your tools (potentially multiple times), and returns its final response. On a virtual thread, <code>.get()<\/code> is cheap. No platform thread is consumed while waiting. The SDK dispatches tool calls to your registered handlers automatically and feeds results back to the model until it\u2019s done.<\/p>\n<h4 class=\"wp-block-heading\">Real-time event handling with <code>session.on(...)<\/code><\/h4>\n<p class=\"wp-block-paragraph\">Subscribe to session events to build responsive UIs:<\/p>\n<div class=\"wp-block-code-wrapper\">\n<pre class=\"wp-block-code\"><code>sessionSubscription = session.on(event -&gt; {\n    captureSessionEvent(event);\n    uiUpdateSocket.pushDetailUpdate(id);\n});<\/code><\/pre>\n<\/div>\n<p class=\"wp-block-paragraph\">Every tool call, every result, every assistant message fires an event. The sample app captures these events and pushes them to the browser via Jakarta WebSocket, so the pipeline dashboard updates in real time. You can use pattern matching to handle specific event types:<\/p>\n<div class=\"wp-block-code-wrapper\">\n<pre class=\"wp-block-code\"><code>if (event instanceof AssistantMessageEvent msg) {\n    finalReport = msg.getData().content();\n} else if (event instanceof ToolExecutionStartEvent start) {\n    \/\/ Tool is being invoked...\n}<\/code><\/pre>\n<\/div>\n<h4 class=\"wp-block-heading\">Headless client and permission handling<\/h4>\n<p class=\"wp-block-paragraph\">The client is configured for server-side operation:<\/p>\n<div class=\"wp-block-code-wrapper\">\n<pre class=\"wp-block-code\"><code>copilotClient = new CopilotClient(\n        new CopilotClientOptions()\n                .setMode(CopilotClientMode.EMPTY)\n                .setCopilotHome(copilotHome)\n                .setExecutor(contextualVirtualThreadExecutor));<\/code><\/pre>\n<\/div>\n<p class=\"wp-block-paragraph\"><code>CopilotClientMode.EMPTY<\/code> means no IDE integration \u2014 the client talks directly to the Copilot CLI. The custom <code>Executor<\/code> (discussed below) ensures tool callbacks run with container context.<\/p>\n<p class=\"wp-block-paragraph\">For permission handling, the sample uses:<\/p>\n<div class=\"wp-block-code-wrapper\">\n<pre class=\"wp-block-code\"><code>sessionConfig.setOnPermissionRequest(PermissionHandler.APPROVE_ALL);<\/code><\/pre>\n<\/div>\n<p class=\"wp-block-paragraph\"><code>APPROVE_ALL<\/code> is appropriate for demos and development. In production, implement a real permission policy that validates which tools the model is allowed to invoke.<\/p>\n<h3 class=\"wp-block-heading\">Jakarta EE integration patterns<\/h3>\n<p class=\"wp-block-paragraph\">The SDK is not a framework island. It composes naturally with Jakarta EE \u2014 and of course also with proprietary frameworks such as Spring.<\/p>\n<p class=\"wp-block-paragraph\"><strong>The <code>Executor<\/code> parameter is the key integration point.<\/strong> Jakarta Concurrency (\u00a75.2 in the 3.1 spec) requires that application-created threads be obtained from a <code>ManagedThreadFactory<\/code> so the container can:<\/p>\n<ol class=\"wp-block-list\">\n<li>Track the thread for lifecycle shutdown (<code>@PreDestroy<\/code> \/ server stop)<\/li>\n<li>Apply concurrency constraints and policies<\/li>\n<li>Propagate context automatically (without needing manual <code>contextualRunnable<\/code>)<\/li>\n<\/ol>\n<p class=\"wp-block-paragraph\">Open Liberty 26.x supports virtual-thread <code>ManagedThreadFactory<\/code> via the <code>virtual<\/code> attribute in <code>server.xml<\/code>.<\/p>\n<div class=\"wp-block-code-wrapper\">\n<pre class=\"wp-block-code\"><code>&lt;managedThreadFactory jndiName=\"concurrent\/virtualThreadFactory\" virtual=\"true\" \/&gt;<\/code><\/pre>\n<\/div>\n<p class=\"wp-block-paragraph\">Then, in <code>AppState.java<\/code> we inject the factory:<\/p>\n<div class=\"wp-block-code-wrapper\">\n<pre class=\"wp-block-code\"><code>@Resource(lookup = \"concurrent\/virtualThreadFactory\")\nprivate ManagedThreadFactory virtualThreadFactory;<\/code><\/pre>\n<\/div>\n<p class=\"wp-block-paragraph\">And use it to create the <code>Executor<\/code> we pass to the Copilot SDK.<\/p>\n<div class=\"wp-block-code-wrapper\">\n<pre class=\"wp-block-code\"><code>\/\/ The ManagedThreadFactory (virtual=true) creates container-managed virtual\n\/\/ threads that automatically propagate CDI, JNDI, and transaction context.\nExecutor managedVirtualExecutor = runnable -&gt;\n    virtualThreadFactory.newThread(runnable).start()\n\nString copilotHome = Path.of(System.getProperty(\"user.home\"), \".copilot\").toString();\nCopilotClientOptions copilotClientOptions = new CopilotClientOptions()\n        .setMode(CopilotClientMode.EMPTY)\n        .setCopilotHome(copilotHome)\n        .setExecutor(managedVirtualExecutor);\ncopilotClient = new CopilotClient(copilotClientOptions);<\/code><\/pre>\n<\/div>\n<p class=\"wp-block-paragraph\">This creates virtual threads that carry the container\u2019s context. When the SDK dispatches a tool call to <code>searchProperties()<\/code>, that method can <code>@Inject<\/code> a JPA repository and query the database, because the container context is present on the callback thread.<\/p>\n<p class=\"wp-block-paragraph\">Other integration patterns in the sample:<\/p>\n<ul class=\"wp-block-list\">\n<li><strong>CDI <code>@ApplicationScoped<\/code><\/strong> for the singleton <code>CopilotClient<\/code> (one client per application lifecycle).<\/li>\n<li><strong>Jakarta Faces <code>f:websocket<\/code> push<\/strong> for real-time browser updates via <code>PushContext<\/code>.<\/li>\n<li><strong>Jakarta Data <code>@Repository<\/code><\/strong> for type-safe database queries without raw JPA boilerplate.<\/li>\n<\/ul>\n<p class=\"wp-block-paragraph\"><strong>Fine-grained tool access control with <code>ToolSet<\/code>.<\/strong> The <code>SessionConfig<\/code> lets you specify exactly which tools each session can access:<\/p>\n<div class=\"wp-block-code-wrapper\">\n<pre class=\"wp-block-code\"><code>sessionConfig.setAvailableTools(new ToolSet()\n        .addCustom(\"*\")           \/\/ all registered custom tools\n        .addBuiltIn(\"web_fetch\")); \/\/ only the web_fetch built-in<\/code><\/pre>\n<\/div>\n<p class=\"wp-block-paragraph\">This is an important production concern. Rather than exposing every built-in tool (file system access, shell execution, etc.), you explicitly opt in to only what the agent needs. In the sample app, we allow all custom tools plus <code>web_fetch<\/code> so the agent can look up real-time property information during the Search phase.<\/p>\n<h2 class=\"wp-block-heading\">Summary<\/h2>\n<p class=\"wp-block-paragraph\">Here\u2019s what we covered:<\/p>\n<ul class=\"wp-block-list\">\n<li><strong>Java-native API<\/strong>: <code>CompletableFuture<\/code>, annotations, lambdas, and virtual threads make the SDK feel like idiomatic Java, not a ported-from-another-language afterthought.<\/li>\n<li><strong>Three tool-definition styles<\/strong>: annotations for enterprise patterns, lambdas for inline convenience, JSON Schema for full control.<\/li>\n<li><strong>System message customization<\/strong>: section-level overrides give you precise control over agent behaviour.<\/li>\n<li><strong>The agentic loop in one line<\/strong>: <code>sendAndWait(...)<\/code> handles the full tool-calling loop automatically.<\/li>\n<li><strong>Real-time event streaming<\/strong>: <code>session.on(...)<\/code> enables responsive UIs and observability.<\/li>\n<li><strong>Headless server-side operation<\/strong>: no IDE required; runs anywhere the Copilot CLI is available.<\/li>\n<li><strong>Natural composition with Jakarta EE<\/strong>: CDI, JPA, WebSocket, and virtual threads all work together through the <code>Executor<\/code> integration point.<\/li>\n<\/ul>\n<h2 class=\"wp-block-heading\">What to try next<\/h2>\n<ul class=\"wp-block-list\">\n<li><strong>Explore the BYOK support.<\/strong> The GitHub Copilot SDK can be used directly against model providers, for example OpenAI, Azure, Anthropic, or OpenAI-compatible endpoints, by passing a <code>provider<\/code>\/<code>ProviderConfig<\/code> with your own <code>baseUrl<\/code> + <code>apiKey<\/code> (or bearer token). No Copilot subscription required.<\/li>\n<li><strong>Clone the sample app<\/strong> and run it locally. Submit multiple enquiries simultaneously to see virtual threads in action.<\/li>\n<li><strong>Swap the model.<\/strong> Try <code>session.setModel(...)<\/code> to experiment with different Copilot models.<\/li>\n<li><strong>Add your own tool.<\/strong> Define a new <code>@CopilotTool<\/code> method (a mortgage calculator, a school-district lookup) and watch the agent discover and use it.<\/li>\n<li><strong>Deploy to Azure.<\/strong> Open Liberty runs great on Azure App Service, AKS, or Azure Container Apps. See the Jakarta EE on Azure guidance at <a href=\"https:\/\/aka.ms\/java\/ee\">https:\/\/aka.ms\/java\/ee<\/a>.<\/li>\n<\/ul>\n<p class=\"wp-block-paragraph\">The Copilot SDK for Java puts the full power of GitHub Copilot behind your Java code with no IDE required and no framework lock-in.<\/p>\n<div class=\"wp-block-group post-content-cta has-global-padding is-layout-constrained wp-block-group-is-layout-constrained\">\n<p class=\"wp-block-paragraph\"><a href=\"https:\/\/github.com\/microsoft\/Build26-BRK206-your-agent-anywhere-multiclient-multidevice-with-github-copilot-sdk\">Clone the sample app and try it yourself &gt;<\/a><\/p>\n<\/div>\n<p>The post <a href=\"https:\/\/github.blog\/engineering\/using-the-github-copilot-sdk-for-java\/\">Using the GitHub Copilot SDK for Java<\/a> appeared first on <a href=\"https:\/\/github.blog\/\">The GitHub Blog<\/a>.<\/p>","protected":false},"excerpt":{"rendered":"<p>Java developers no longer have to rely on Java framework-specific approaches to drive AI from their enterprise apps. While it [&hellip;]<\/p>\n","protected":false},"author":1,"featured_media":4776,"comment_status":"","ping_status":"","sticky":false,"template":"","format":"standard","meta":{"site-sidebar-layout":"default","site-content-layout":"","ast-site-content-layout":"default","site-content-style":"default","site-sidebar-style":"default","ast-global-header-display":"","ast-banner-title-visibility":"","ast-main-header-display":"","ast-hfb-above-header-display":"","ast-hfb-below-header-display":"","ast-hfb-mobile-header-display":"","site-post-title":"","ast-breadcrumbs-content":"","ast-featured-img":"","footer-sml-layout":"","ast-disable-related-posts":"","theme-transparent-header-meta":"","adv-header-id-meta":"","stick-header-meta":"","header-above-stick-meta":"","header-main-stick-meta":"","header-below-stick-meta":"","astra-migrate-meta-layouts":"default","ast-page-background-enabled":"default","ast-page-background-meta":{"desktop":{"background-color":"var(--ast-global-color-4)","background-image":"","background-repeat":"repeat","background-position":"center center","background-size":"auto","background-attachment":"scroll","background-type":"","background-media":"","overlay-type":"","overlay-color":"","overlay-opacity":"","overlay-gradient":""},"tablet":{"background-color":"","background-image":"","background-repeat":"repeat","background-position":"center center","background-size":"auto","background-attachment":"scroll","background-type":"","background-media":"","overlay-type":"","overlay-color":"","overlay-opacity":"","overlay-gradient":""},"mobile":{"background-color":"","background-image":"","background-repeat":"repeat","background-position":"center center","background-size":"auto","background-attachment":"scroll","background-type":"","background-media":"","overlay-type":"","overlay-color":"","overlay-opacity":"","overlay-gradient":""}},"ast-content-background-meta":{"desktop":{"background-color":"var(--ast-global-color-5)","background-image":"","background-repeat":"repeat","background-position":"center center","background-size":"auto","background-attachment":"scroll","background-type":"","background-media":"","overlay-type":"","overlay-color":"","overlay-opacity":"","overlay-gradient":""},"tablet":{"background-color":"var(--ast-global-color-5)","background-image":"","background-repeat":"repeat","background-position":"center center","background-size":"auto","background-attachment":"scroll","background-type":"","background-media":"","overlay-type":"","overlay-color":"","overlay-opacity":"","overlay-gradient":""},"mobile":{"background-color":"var(--ast-global-color-5)","background-image":"","background-repeat":"repeat","background-position":"center center","background-size":"auto","background-attachment":"scroll","background-type":"","background-media":"","overlay-type":"","overlay-color":"","overlay-opacity":"","overlay-gradient":""}},"footnotes":""},"categories":[8],"tags":[],"class_list":["post-4775","post","type-post","status-publish","format-standard","has-post-thumbnail","hentry","category-github-engineering"],"_links":{"self":[{"href":"https:\/\/rssfeedtelegrambot.bnaya.co.il\/index.php\/wp-json\/wp\/v2\/posts\/4775","targetHints":{"allow":["GET"]}}],"collection":[{"href":"https:\/\/rssfeedtelegrambot.bnaya.co.il\/index.php\/wp-json\/wp\/v2\/posts"}],"about":[{"href":"https:\/\/rssfeedtelegrambot.bnaya.co.il\/index.php\/wp-json\/wp\/v2\/types\/post"}],"author":[{"embeddable":true,"href":"https:\/\/rssfeedtelegrambot.bnaya.co.il\/index.php\/wp-json\/wp\/v2\/users\/1"}],"replies":[{"embeddable":true,"href":"https:\/\/rssfeedtelegrambot.bnaya.co.il\/index.php\/wp-json\/wp\/v2\/comments?post=4775"}],"version-history":[{"count":0,"href":"https:\/\/rssfeedtelegrambot.bnaya.co.il\/index.php\/wp-json\/wp\/v2\/posts\/4775\/revisions"}],"wp:featuredmedia":[{"embeddable":true,"href":"https:\/\/rssfeedtelegrambot.bnaya.co.il\/index.php\/wp-json\/wp\/v2\/media\/4776"}],"wp:attachment":[{"href":"https:\/\/rssfeedtelegrambot.bnaya.co.il\/index.php\/wp-json\/wp\/v2\/media?parent=4775"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"https:\/\/rssfeedtelegrambot.bnaya.co.il\/index.php\/wp-json\/wp\/v2\/categories?post=4775"},{"taxonomy":"post_tag","embeddable":true,"href":"https:\/\/rssfeedtelegrambot.bnaya.co.il\/index.php\/wp-json\/wp\/v2\/tags?post=4775"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}