A 5.4 kB AWS Bedrock AgentCore Agent in Vanilla Java 📎
An agent running on the AWS Bedrock AgentCore Runtime has to implement a minimal HTTP contract:
POST /invocations answers requests, GET /ping reports health, both on port 8080.
The JDK's built-in jdk.httpserver is sufficient.
The AWS Java Agent Core Runtime CDK quickstarter project implements the contract in vanilla Java 25 with zero external dependencies. The complete contract is implemented in a single interface:
public interface AgentRuntime {
int AGENT_CORE_PORT = 8080;
static String invokeAgent(String payload) {
IO.println("invocation: " + payload);
return """
{"time":"%s"}""".formatted(Instant.now());
}
static String checkHealth() {
return """
{"status":"Healthy"}""";
}
static void serve() {
HttpEndpoint.start(AGENT_CORE_PORT, AgentRuntime::invokeAgent, AgentRuntime::checkHealth);
}
}
A second interface, HttpEndpoint, wires both routes on the JDK's HttpServer. Every import comes from the JDK.
The sample agent answers each invocation with the current UTC time as JSON. Packaged with zb, the complete agent.jar is 5,440 bytes, and the endpoints are serving about 60 ms after JVM start (OpenJDK 25, Apple Silicon).
Deployment is also Java. The project ships with an AWS CDK app (the cdk module) that builds the agent's four-line Dockerfile (Amazon Corretto 25, the jar, an ENTRYPOINT) into an ARM64 container image asset and provisions the AgentCore runtime from it. The image is built and pushed during cdk deploy. The system tests invoke the deployed agent with the AWS SDK's BedrockAgentCoreClient.
The project was developed with /sbce, the spec-driven BCE workflow: the AgentCore contract is declared as EARS requirements (Easy Approach to Requirements Syntax) in the business component's package-info.java, and @Requirement annotations (trimmed from the listing above) trace the boundary methods back to the spec.
The project is part of constructions.cloud, a collection of Java CDK templates and quickstarters.