Agentic AI is remodeling how organizations use generative AI, transferring past prompt-response interactions to autonomous methods that may plan, execute, and full advanced multi-step duties. Whereas early proof of ideas in Agentic AI areas excite enterprise stakeholders, scaling them to manufacturing requires addressing scalability, governance, and safety challenges. Amazon Bedrock AgentCore is an Agentic AI platform to construct, deploy, and function brokers at scale utilizing any framework and any mannequin.
Java builders need to construct AI brokers utilizing identified Spring patterns, however manufacturing deployment requires infrastructure that’s advanced to implement from scratch. Amazon Bedrock AgentCore offers constructing blocks like managed runtime infrastructure (scalability, reliability, safety, observability), short- and long-term reminiscence, browser automation, sandboxed code execution, and evaluations. Integrating these capabilities right into a Spring utility at present requires writing customized controllers to satisfy AgentCore Runtime contract, dealing with Server-Aspect Occasions (SSE) streaming, implementing well being checks, managing charge limiting, and wiring up Spring advisors, reminiscence repositories, and gear definitions. That is weeks of infrastructure work earlier than writing any AI Agent logic.
With the brand new Spring AI AgentCore SDK, you’ll be able to construct production-ready AI brokers and run them on the extremely scalable AgentCore Runtime. The Spring AI AgentCore SDK is an open supply library that brings Amazon Bedrock AgentCore capabilities into Spring AI by way of identified patterns: annotations, auto-configuration, and composable advisors. SpringAI Builders add a dependency, annotate a way, and the SDK handles the remainder.
Understanding the AgentCore Runtime contract
AgentCore Runtime manages agent lifecycle and scaling with pay-per-use pricing, which means you don’t pay for idle compute. The runtime routes incoming requests to your agent and screens its well being, however this requires your agent to observe a contract. The contract requires that the implementation exposes two endpoints. The /invocations endpoint receives requests and returns responses as both JSON or SSE streaming. The /ping well being endpoint reviews a Wholesome or HealthyBusy standing. Lengthy-running duties should sign that they’re busy, or the runtime may scale them down to avoid wasting prices. The SDK implements this contract routinely, together with async process detection that reviews busy standing when your agent is processing.
Past the contract, the SDK offers extra capabilities for manufacturing workloads like dealing with SSE responses with correct framing, backpressure dealing with, and connection lifecycle administration for giant responses. It additionally offers charge limiting, throttling requests to guard your agent from visitors spikes and restrict per-user consumption. You focus is on agent logic whereas the SDK handles the runtime integration.Past the contract, the SDK offers extra capabilities for manufacturing workloads resembling dealing with SSE responses with correct framing, backpressure dealing with, and connection lifecycle administration for giant responses. It additionally offers charge limiting, throttling requests to guard your agent from visitors spikes and restrict per-user consumption. You concentrate on agent logic whereas the SDK handles the runtime integration.
On this put up, we construct a production-ready AI agent beginning with a chat endpoint, then including streaming responses, dialog reminiscence, and instruments for internet searching and code execution. By the top, you should have a totally purposeful agent able to deploy to AgentCore Runtime or run standalone in your present infrastructure.
Stipulations
To observe alongside, you want:
Answer overview
The Spring AI AgentCore SDK is constructed on three design rules:
- Conference over configuration – Wise defaults align with AgentCore expectations (port 8080, endpoint paths, content-type dealing with) with out specific configuration.
- Annotation-driven growth – A single @AgentCoreInvocation annotation transforms any Spring bean technique into an AgentCore-compatible endpoint with computerized serialization, streaming detection, and response formatting.
- Deployment flexibility – The SDK helps AgentCore Runtime for absolutely managed deployment, however you may as well use particular person modules (Reminiscence, Browser, Code Interpreter) in purposes operating on Amazon EKS, Amazon ECS, or another infrastructure.
The next diagram exhibits how the SDK parts work together. The @AgentCoreInvocation annotation handles the runtime contract, whereas the ChatClient composes Reminiscence advisors, Browser instruments, and Code Interpreter. Deployment to AgentCore Runtime is non-obligatory. You should use the SDK modules as standalone options.
Creating your first AI agent
The next part walks you thru the right way to create a totally purposeful agent step-by-step:
Step 1: Add the SDK dependency
Add the Spring AI AgentCore BOM to your Maven challenge, then embody the runtime starter:
org.springaicommunity
spring-ai-agentcore-bom
1.0.0
pom
import
org.springaicommunity
spring-ai-agentcore-runtime-starter
Step 2: Create the agent
The @AgentCoreInvocation annotation tells the SDK that this technique handles incoming agent requests. The SDK auto-configures POST /invocations and GET /ping endpoints, handles JSON serialization, and reviews well being standing routinely.
@Service
public class MyAgent {
personal last ChatClient chatClient;
public MyAgent(ChatClient.Builder builder) {
this.chatClient = builder.construct();
}
@AgentCoreInvocation
public String chat(PromptRequest request) {
return chatClient.immediate()
.person(request.immediate())
.name()
.content material();
}
}
document PromptRequest(String immediate) {}
Step 3: Configure Amazon Bedrock
Set your mannequin and AWS Area in utility.properties:
spring.ai.bedrock.aws.area=us-east-1
spring.ai.bedrock.converse.chat.choices.mannequin=world.anthropic.claude-sonnet-4-5-20250929-v1:0
Step 4: Check regionally
Begin the applying and ship a request:
mvn spring-boot:run
curl -X POST http://localhost:8080/invocations
-H “Content material-Kind: utility/json”
-d ‘{“immediate”: “What’s Spring AI?”}’
That’s a whole, AgentCore-compatible AI agent. No customized controllers, no protocol dealing with, no well being examine implementation.
Step 5: Add streaming
To stream responses as they’re generated, change the return sort to Flux. The SDK routinely switches to SSE output:
@AgentCoreInvocation
public Flux streamingChat(PromptRequest request) {
return chatClient.immediate()
.person(request.immediate())
.stream()
.content material();
}
The SDK handles SSE framing, Content material-Kind headers, newline preservation, and connection lifecycle. Your code stays centered on the AI interplay.
Step 6: Add reminiscence to your agent
Actual-world brokers should bear in mind what customers mentioned earlier in a dialog (short-term reminiscence) and what they’ve realized over time (long-term reminiscence). The SDK integrates with AgentCore Reminiscence by way of Spring AI’s advisor sample, interceptors that enrich prompts with context earlier than they attain the mannequin.
Quick-term reminiscence (STM) retains latest messages utilizing a sliding window. Lengthy-term reminiscence (LTM) persists information throughout periods utilizing 4 methods:
Technique
Goal
Instance
Semantic
Factual details about customers
“Person works in finance”
Person desire
Specific settings and selections
“Metric items most popular”
Abstract
Condensed dialog historical past
Session summaries for continuity
Episodic
Previous interactions and classes
“Person had hassle with X final week”
AgentCore consolidates these methods asynchronously, extracting related info with out specific developer intervention.Add the reminiscence dependency and allow auto-discovery. In auto-discovery mode, the SDK routinely detects accessible long-term reminiscence methods and namespaces with out guide configuration:
agentcore.reminiscence.memory-id=${AGENTCORE_MEMORY_ID}
agentcore.reminiscence.long-term.auto-discovery=true
Then inject AgentCoreMemory and compose it into your chat consumer:
// Add to MyAgent constructor
personal last AgentCoreMemory agentCoreMemory;
public MyAgent(ChatClient.Builder builder, AgentCoreMemory agentCoreMemory) {
this.agentCoreMemory = agentCoreMemory;
this.chatClient = builder.construct();
}
// Replace the chat technique to incorporate reminiscence advisors
@AgentCoreInvocation
public String chat(PromptRequest request, AgentCoreContext context) {
String sessionId = context.getHeader(AgentCoreHeaders.SESSION_ID);
return chatClient.immediate()
.person(request.immediate())
.advisors(agentCoreMemory.advisors)
.advisors(a -> a.param(ChatMemory.CONVERSATION_ID, “person:” + sessionId))
.name()
.content material();
}
The agentCoreMemory.advisors checklist contains each STM and all configured LTM advisors. For detailed configuration choices, see the Reminiscence documentation.
Step 7: Extending brokers with instruments
AgentCore offers specialised instruments that the SDK exposes as Spring AI instrument callbacks by way of the ToolCallbackProvider interface.
Browser automation – Brokers can navigate web sites, extract content material, take screenshots, and work together with web page components utilizing AgentCore Browser:
org.springaicommunity
spring-ai-agentcore-browser
Code interpreter – Brokers can write and run Python, JavaScript, or TypeScript in a safe sandbox utilizing AgentCore Code Interpreter. The sandbox contains numpy, pandas, and matplotlib. Generated recordsdata are captured by way of the artifact retailer.
org.springaicommunity
spring-ai-agentcore-code-interpreter
Each instruments combine by way of Spring AI’s ToolCallbackProvider interface. Right here is the ultimate MyAgent with reminiscence, browser, and code interpreter composed collectively:
@Service
public class MyAgent {
personal last ChatClient chatClient;
personal last AgentCoreMemory agentCoreMemory;
public MyAgent(
ChatClient.Builder builder,
AgentCoreMemory agentCoreMemory,
@Qualifier(“browserToolCallbackProvider”) ToolCallbackProvider browserTools,
@Qualifier(“codeInterpreterToolCallbackProvider”) ToolCallbackProvider codeInterpreterTools) {
this.agentCoreMemory = agentCoreMemory;
this.chatClient = builder
.defaultToolCallbacks(browserTools, codeInterpreterTools)
.construct();
}
@AgentCoreInvocation
public Flux chat(PromptRequest request, AgentCoreContext context) {
String sessionId = context.getHeader(AgentCoreHeaders.SESSION_ID);
return chatClient.immediate()
.person(request.immediate())
.advisors(agentCoreMemory.advisors)
.advisors(a -> a.param(ChatMemory.CONVERSATION_ID, “person:” + sessionId))
.stream()
.content material();
}
}
The mannequin sees all instruments equally and decides which to name primarily based on the person’s request. Whereas this put up focuses on Amazon Bedrock to entry basis fashions (FMs), Spring AI helps a number of giant language mannequin (LLM) suppliers together with OpenAI and Anthropic, so you’ll be able to select the fashions that suit your wants. For instance, a journey and expense administration agent can use the browser instrument to search for flight choices and the code interpreter to research spending patterns and generate charts, all inside a single dialog:
Deploying your agent
The SDK helps two deployment fashions:
AgentCore Runtime – For absolutely managed infrastructure, bundle your utility as an ARM64 container, push it to Amazon Elastic Container Registry (Amazon ECR), and create an AgentCore Runtime that references the picture. The runtime handles scaling and well being monitoring. The examples/terraform listing offers infrastructure as code (IaC) with IAM and OAuth authentication choices.
Standalone – Use AgentCore Reminiscence, Browser, or Code Interpreter in purposes operating on Amazon Elastic Kubernetes Service (Amazon EKS), Amazon Elastic Container Service (Amazon ECS), Amazon Elastic Compute Cloud (Amazon EC2), or on-premises. With this strategy, groups can undertake AgentCore capabilities incrementally. For instance, including reminiscence to an present Spring Boot service earlier than migrating to AgentCore Runtime later.
Authentication and authorization
AgentCore Runtime helps two authentication strategies: IAM-based SigV4 for AWS service-to-service calls and OAuth2 for user-facing purposes. When your Spring AI agent is deployed to AgentCore Runtime, authentication is dealt with on the infrastructure layer. Your utility receives the authenticated person’s identification by way of AgentCoreContext. Fantastic-grained authorization can then be carried out in your Spring utility utilizing normal Spring Safety patterns with these rules. For standalone deployments, your Spring utility is chargeable for offering authentication and authorization utilizing Spring Safety. On this case, calls to AgentCore companies (Reminiscence, Browser, Code Interpreter) are secured utilizing normal AWS SDK credential mechanisms.
Connecting to MCP instruments with AgentCore Gateway
Spring AI brokers can entry organizational instruments by way of AgentCore Gateway, which offers Mannequin Context Protocol (MCP) help with outbound authentication and a semantic instrument registry. To make use of Gateway, configure your Spring AI MCP consumer endpoint to level to AgentCore Gateway and authenticate utilizing both IAM SigV4 or OAuth2:
spring.ai.mcp.consumer.toolcallback.enabled=true
spring.ai.mcp.consumer.initialized=false
spring.ai.mcp.consumer.streamable-http.connections.gateway.url=${GATEWAY_URL}
This permits brokers to find and invoke enterprise instruments whereas Gateway handles credential administration for downstream companies. For a hands-on instance, see the Constructing Java AI brokers with Spring AI and Amazon Bedrock AgentCore workshop, which demonstrates MCP integration with AgentCore Gateway.
What’s subsequent?
The SDK continues to evolve. Upcoming integrations will embody:
- Observability – Combine Spring AI tracing, metrics, and logging with help for Amazon CloudWatch and exterior observability instruments resembling LangFuse, Datadog, and Dynatrace utilizing OpenTelemetry. Fundamental AgentCore observability is out there right this moment.
- Evaluations – Testing and high quality evaluation frameworks for agent responses.
- Superior Id administration – Streamlined safety context retrieval for Spring AI Brokers.
Cleansing up
In the event you created sources whereas following this put up, delete them to keep away from ongoing fees:
- Delete any AgentCore Runtime brokers that you just created.
- Delete container pictures from Amazon ECR.
- Take away IAM roles and insurance policies created for agent deployment.
- In the event you used the Terraform examples, run terraform destroy to take away all sources.
Conclusion
On this put up, we confirmed you the right way to construct production-ready AI brokers in Java utilizing the Spring AI AgentCore SDK. Ranging from an annotated technique, we added streaming responses, persistent reminiscence, browser automation, and code execution—all by way of identified Spring patterns.The SDK is an open supply beneath the Apache 2.0 license. To get began:
- Discover the Spring AI AgentCore SDK on GitHub. The repository contains instance purposes that you should utilize as beginning factors:
- simple-spring-boot-app — Minimal agent with primary request dealing with
- spring-ai-sse-chat-client — Streaming responses with Server-Despatched Occasions
- spring-ai-memory-integration — Quick-term and long-term reminiscence utilization
- spring-ai-extended-chat-client — OAuth authentication with per-user reminiscence isolation
- spring-ai-browser — Net searching and screenshot capabilities
- Learn the Amazon AgentCore documentation for particulars on Runtime, Reminiscence, Browser, and Code Interpreter companies.
- Strive the Amazon Bedrock console to allow mannequin entry and discover accessible basis fashions.
- For a hands-on deep dive, strive the Constructing Java AI brokers with Spring AI and Amazon AgentCore workshop. In about 4 hours, you construct a whole journey and expense administration assistant—progressively including persona, reminiscence, information retrieval, internet searching, code execution, MCP instrument integration and deploy it serverless to AgentCore Runtime with authentication and observability. No synthetic intelligence and machine studying (AI/ML) expertise is required.
We welcome your suggestions and contributions. Go away a remark to share your expertise or open a problem on the GitHub repository.
In regards to the authors
Andrei Shakirin
Andrei Shakirin is a Senior Answer Architect. He helps prospects in growing cloud options, specializing in Agentic AI, Containers, Spring AI and Java. Andrei is contributor of Spring AI, MCP Java SDK and speaker on worldwide developer conferences.
James Ward
James Ward Skilled software program developer since 1997, with a lot of that point spent serving to builders construct software program that doesn’t suck. A Typed Pure Useful Programming zealot who typically compromises on his beliefs to only get stuff executed. At present a Developer Advocate for AWS and AAIF Technical Committee member.
Maximilian Schellhorn
Maximilian Schellhorn works as a Principal Options Architect at Amazon Net Providers. Earlier than that he labored for greater than 10 years as a Software program Engineer & Architect on distributed system design and monolith-to-microservice transformations. His latest work focuses on SaaS, Serverless (Java) and Agentic AI.
Matthew Meckes
Matthew Meckes works as a Principal Containers Specialist at Amazon Net Providers, serving to prospects construct and scale their most advanced workloads on Kubernetes and EKS, with a specific concentrate on Java, AI and Platform Engineering.
Yuriy Bezsonov
Yuriy Bezsonov is a Senior Options Architect. He has progressed from a software program developer to an engineering supervisor and Options Architect. Now, as a Senior Options Architect at AWS, he assists companions and prospects in growing cloud options, specializing in Agentic AI, container applied sciences, Kubernetes, Java. Yuriy holds AWS and Kubernetes certifications, and he’s a recipient of the AWS Golden Jacket.
Muhammad Hamza Usmani
Muhammad Hamza Usmani is a Senior Generative AI GTM Options Architect. He works on GTM subjects for Amazon Bedrock pan EMEA. He’s keen about working with prospects and companions, motivated by the aim of harnessing mannequin in context studying capabilities.

