Explore Spring AI SDK – Amazon Bedrock AgentCore – Part 1

Author: Mahendra Rao B

Original post on Foojay: Read More

Table of Contents

Introduction

Introduction

Artificial intelligence has rapidly expanded across every industry since the inception of ChatGPT. It represents a breakthrough in how we build and use software. Moreover, this breakthrough technology has driven major transformation. At the same time, it has created significant noise and hype.

Today, AI is no longer experimental. Instead, it has become essential, much like electricity and the internet. As a result, it now plays a key role in our daily lives. Overall, this shift reflects strong technological acceleration across industries.

From a development perspective, the software development lifecycle is evolving. In particular, it is steadily moving toward AI engineering. In my view, this shift improves the productivity of developers and architects.

However, we must remain cautious. For example, we should not blindly trust outputs from tools like ChatGPT, GitHub Copilot, or other AI assistants. Instead, we must review and validate all generated text, code, and content. Only then should we deploy it to production for customers.

Role of Agentic AI Frameworks

Meanwhile, as AI continues to evolve and deliver staggering results, many agentic AI frameworks are emerging. Consequently, developers and architects can build and experiment with use cases in a short time. In addition, these frameworks act as breakthrough technology and accelerate innovation.

At the same time, provider SDKs handle key architectural and infrastructure concerns. For instance, they manage scalability, reliability, security, and observability. Therefore, this support reflects strong technological acceleration in the ecosystem.

As a result, developers and architects can focus mainly on building core agent logic.

For Python and TypeScript developers, AWS has open-sourced the Strands Agents SDK. It follows a model-driven approach to building and running AI agents with just a few lines of code.

Meanwhile, the Amazon Bedrock SDK handles the underlying infrastructure capabilities. This includes scalability, reliability, security, and observability. From my experience, I have explored, built, and deployed several agents using this framework. I find it to be a very interesting and powerful framework to work with.

In this article, we focus on Spring AI and its integration with the generally available Amazon Bedrock SDK. Specifically, the Spring AI AgentCore SDK enables developers to build production-ready AI agents. Furthermore, they can run these agents on the highly scalable AgentCore Runtime.

Spring AI SDK

What is Spring AI and Spring AI SDK?

According to Spring AI documentation, it is an application framework for AI engineering. Using this framework, developers can connect Data and APIs with AI models.

The Spring AI AgentCore SDK is an open-source library that brings Amazon Bedrock AgentCore capabilities into Spring AI. It uses familiar patterns such as annotations, auto-configuration, and composable advisors.

With Spring AI Builders, developers can simply add a dependency and annotate a method. The SDK then handles the rest.

What is Amazon Bedrock AgentCore and Why?

According to Amazon documentation, it is an agentic AI platform that enables developers to build, deploy, and operate agents at scale using any framework and any model.

One key reason to use Amazon Bedrock AgentCore is that it simplifies development. It allows developers to focus on building AI agents and implementing business logic. However, configuring capabilities such as scalability, reliability, security, governance, and observability typically requires significant time and effort.

With Amazon Bedrock AgentCore, the platform handles the infrastructure layer. It provides these capabilities out of the box. As a result, developers can concentrate on core agent development rather than managing underlying systems.

Agentcore Capabilities
Source: Amazon

Amazon Bedrock AgentCore Capabilties

Amazon Bedrock AgentCore provides the following capabilities.

1. AgentCore Runtime

  • The execution environment where your AI agents run
  • Handles scaling, session management, and isolation automatically
  • Lets you deploy agents without managing infrastructure

2. AgentCore Memory

  • Helps agents remember context across interactions
  • Supports:
    • Short-term memory (conversation context): It stores recent messages using a sliding window approach.
    • Long-term memory (persistent knowledge): It persists knowledge across sessions using multiple strategies like Semantic, User Preference, Summary, and Episodic memory strategies.
  • Enables more personalized and intelligent responses

3. AgentCore Gateway

  • Connects agents to APIs, tools, and external systems
  • Converts APIs/Lambda functions into agent-compatible tools (MCP)
  • Simplifies tool integration with minimal code

4. AgentCore Identity

  • Manages authentication and access control for agents
  • Integrates with existing identity providers (e.g., Cognito, Okta, OAuth2)
  • Ensures secure interactions with systems and data

5. AgentCore Policy

  • Defines rules and boundaries for agent behavior
  • Controls what actions an agent can perform
  • Ensures compliance and governance without slowing execution

6. Build-inTool: Code Interpreter

  • Provides a secure sandbox for executing code
  • Supports multiple languages (Python, JS, etc.)
  • Helps agents perform complex computations and tasks

7. Build-inTool: Browser

  • Allows agents to interact with websites
  • Can navigate pages, fill forms, and extract data
  • Runs in a secure, managed environment

8. Gen AI Observability

  • Monitors and tracks agent performance in production
  • Provides tracing, debugging, and visualization of workflows
  • Helps identify failures and optimize performance
  • Separate feature is available in CloudWatch as a sidecar as a Gen AI Observability

9. Evaluations

  • Measures agent quality and performance
  • Evaluates correctness, reliability, and task success
  • Helps improve agents using data-driven insights

Step-by-step guide

We can start by creating a sample agent. Then, we can gradually add and integrate AgentCore services such as memory, gateway, identity, and policies. We can also incorporate built-in tools like the browser and code interpreter.

Observability, evaluations, and advanced identity management are still evolving. These capabilities are expected in upcoming SDK releases.

1. Add the below Bill of Materials(BOM) SDK Dependencies to pom.xml

<dependencyManagement>
        <dependencies>
            <dependency>
                <groupId>org.springframework.ai</groupId>
                <artifactId>spring-ai-bom</artifactId>
                <version>${spring-ai.version}</version>
                <type>pom</type>
                <scope>import</scope>
            </dependency>
            <dependency>
                <groupId>org.springaicommunity</groupId>
                <artifactId>spring-ai-agentcore-bom</artifactId>
                <version>${spring-ai-agentcore.version}</version>
                <type>pom</type>
                <scope>import</scope>
            </dependency>
        </dependencies>
    </dependencyManagement>

complete pom.xml

<?xml version="1.0" encoding="UTF-8"?>
<project xmlns="http://maven.apache.org/POM/4.0.0" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
    xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 https://maven.apache.org/xsd/maven-4.0.0.xsd">
    <modelVersion>4.0.0</modelVersion>
    <parent>
        <groupId>org.springframework.boot</groupId>
        <artifactId>spring-boot-starter-parent</artifactId>
        <version>3.5.8</version>
        <relativePath/> <!-- lookup parent from repository -->
    </parent>
    <groupId>com.bsmlabs</groupId>
    <artifactId>simple-spring-boot-agent</artifactId>
    <version>0.0.1-SNAPSHOT</version>
    <name/>
    <description/>
    <url/>
    <licenses>
        <license/>
    </licenses>
    <developers>
        <developer/>
    </developers>
    <scm>
        <connection/>
        <developerConnection/>
        <tag/>
        <url/>
    </scm>
    <properties>
        <java.version>21</java.version>
        <spring-ai.version>1.1.4</spring-ai.version>
        <spring-ai-agentcore.version>1.0.0</spring-ai-agentcore.version>
    </properties>
    <dependencies>
        <dependency>
            <groupId>org.springframework.boot</groupId>
            <artifactId>spring-boot-starter-actuator</artifactId>
        </dependency>
        <dependency>
            <groupId>org.springframework.boot</groupId>
            <artifactId>spring-boot-starter-web</artifactId>
        </dependency>

        <dependency>
            <groupId>org.springframework.ai</groupId>
            <artifactId>spring-ai-starter-model-bedrock-converse</artifactId>
        </dependency>

        <dependency>
            <groupId>org.springaicommunity</groupId>
            <artifactId>spring-ai-agentcore-runtime-starter</artifactId>
            <version>${spring-ai-agentcore.version}</version>
        </dependency>

        <dependency>
            <groupId>org.springframework.boot</groupId>
            <artifactId>spring-boot-starter-test</artifactId>
            <scope>test</scope>
        </dependency>
    </dependencies>

    <dependencyManagement>
        <dependencies>
            <dependency>
                <groupId>org.springframework.ai</groupId>
                <artifactId>spring-ai-bom</artifactId>
                <version>${spring-ai.version}</version>
                <type>pom</type>
                <scope>import</scope>
            </dependency>
            <dependency>
                <groupId>org.springaicommunity</groupId>
                <artifactId>spring-ai-agentcore-bom</artifactId>
                <version>${spring-ai-agentcore.version}</version>
                <type>pom</type>
                <scope>import</scope>
            </dependency>
        </dependencies>
    </dependencyManagement>

    <build>
        <plugins>
            <plugin>
                <groupId>org.springframework.boot</groupId>
                <artifactId>spring-boot-maven-plugin</artifactId>
            </plugin>
        </plugins>
    </build>

</project>

The post Explore Spring AI SDK – Amazon Bedrock AgentCore – Part 1 appeared first on foojay.