GithubEdward BurnsTutorial
Using the GitHub Copilot SDK for Java
Summary
The GitHub Copilot SDK for Java offers a framework-agnostic client library to orchestrate AI agent sessions and tool execution directly from server-side Java code. Unlike framework-dependent alternatives, the SDK supports direct model providers such as OpenAI, Azure, and Anthropic through custom endpoint configurations without requiring a Copilot subscription. Developers can register tools declaratively using the experimental @CopilotTool annotation processor or dynamically through inline lambda definitions with ToolDefinition.from. When integrated into a Jakarta EE 11 application on Open Liberty, agent workflows run on container-managed virtual threads that propagate CDI and transaction contexts during blocking calls like sendAndWait. Real-time event subscriptions capture model execution steps and tool invocations to stream updates over WebSockets without exhausting platform threads.
Context
Java developers previously relied on framework-specific tools such as Spring AI or framework-dependent libraries like Langchain4j to drive AI interactions within enterprise applications.
Approach / What changed
Integrating the GitHub Copilot SDK for Java into enterprise applications using Jakarta EE 11, Open Liberty, @CopilotTool annotation processing, and container-managed virtual thread executors.
Takeaways
The GitHub Copilot SDK for Java supports direct model endpoints from providers like OpenAI, Azure, and Anthropic via custom base URLs and API keys without requiring a Copilot subscription.
Using @CopilotTool annotations requires configuring -Acopilot.experimental.allowed=true and adding the SDK to annotationProcessorPaths in Maven to generate tool metadata at compile time.
Supplying an executor backed by Jakarta Concurrency's ManagedThreadFactory enables virtual-thread-based agent loops that automatically propagate container context and lifecycle tracking.
Source and freshness
- Source
- github.blog
- Published
- Added to Yomu
- Last updated
Summaries are generated from the original by a language model. Check the original before relying on it.
Keep reading
Related reading
The Good Stuff
Paid picks we use ourselves. Links carry a referral code — a subscription through one earns us a commission at no extra cost to you.
The best engineering reads, once a week
One useful email. Unsubscribe anytime.