Skip to content

Feat spring boot starter#653

Open
mekkiamiri wants to merge 11 commits into
google:mainfrom
mekkiamiri:feat-spring-boot-starter
Open

Feat spring boot starter#653
mekkiamiri wants to merge 11 commits into
google:mainfrom
mekkiamiri:feat-spring-boot-starter

Conversation

@mekkiamiri

@mekkiamiri mekkiamiri commented Dec 6, 2025

Copy link
Copy Markdown

This pull requests, adds support to spring boot starter.
In addition, i added an example to show how to use the starter.
This starter integrates the Google Agent Development Kit (ADK) into Spring Boot applications.
It provides auto-configuration for :

  • BaseArtifactService and Storage
  • BaseMemoryService
  • RunConfig
  • BaseSessionService

@gemini-code-assist

Copy link
Copy Markdown
Contributor

Summary of Changes

Hello @mekkiamiri, I'm Gemini Code Assist1! I'm currently reviewing this pull request and will post my feedback shortly. In the meantime, here's a summary to help you and other reviewers quickly get up to speed!

This pull request delivers a new Spring Boot Starter for the Google Agent Development Kit (ADK), streamlining the process of building agent-powered applications within the Spring ecosystem. It encapsulates the setup of essential ADK components, offering flexible configuration options for various service implementations. The inclusion of a dedicated sample application provides a practical guide for developers to quickly adopt and utilize the starter.

Highlights

  • New Spring Boot Starter: Introduced adk-spring-boot-starter to simplify integration of the Google Agent Development Kit (ADK) with Spring Boot applications.
  • Auto-Configuration: The starter provides auto-configuration for core ADK services including Artifacts, Session, Memory, and RunConfig, making them easily injectable as Spring beans.
  • Configurable Services: ADK services can be configured via application.yaml to use different implementations, such as GcsArtifactService for artifacts and VertexAiSessionService for sessions, or default in-memory versions.
  • New Sample Application: A new sample Spring Boot application (spring-boot-adk-template) has been added to demonstrate the usage and verification of the ADK Spring Boot Starter.
Using Gemini Code Assist

The full guide for Gemini Code Assist can be found on our documentation page, here are some quick tips.

Invoking Gemini

You can request assistance from Gemini at any point by creating a comment using either /gemini <command> or @gemini-code-assist <command>. Below is a summary of the supported commands on the current page.

Feature Command Description
Code Review /gemini review Performs a code review for the current pull request in its current state.
Pull Request Summary /gemini summary Provides a summary of the current pull request in its current state.
Comment @gemini-code-assist Responds in comments when explicitly tagged, both in pull request comments and review comments.
Help /gemini help Displays a list of available commands.

Customization

To customize Gemini Code Assist for GitHub experience, repository maintainers can create a configuration file and/or provide a custom code review style guide (such as PEP-8 for Python) by creating and adding files to a .gemini/ folder in the base of the repository. Detailed instructions can be found here.

Limitations & Feedback

Gemini Code Assist may make mistakes. Please leave feedback on any instances where its feedback is incorrect or counter productive. You can react with 👍 and 👎 on @gemini-code-assist comments. If you're interested in giving your feedback about your experience with Gemini Code Assist for Github and other Google products, sign up here.

You can also get AI-powered code generation, chat, as well as code reviews directly in the IDE at no cost with the Gemini Code Assist IDE Extension.

Footnotes

  1. Review the Privacy Notices, Generative AI Prohibited Use Policy, Terms of Service, and learn how to configure Gemini Code Assist in GitHub here. Gemini can make mistakes, so double check it and use code with caution.

@gemini-code-assist gemini-code-assist Bot left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Code Review

This pull request introduces a new Spring Boot starter for the Google Agent Development Kit (ADK), which is a valuable addition for easier integration. The auto-configuration logic is generally well-structured. My review focuses on several critical dependency versioning issues in the pom.xml files that could lead to build failures. I've also provided suggestions to improve the auto-configuration classes by adhering more closely to Spring best practices, such as proper dependency injection and failing fast on unsupported configurations. The sample application is a helpful example, and I've included some refactoring suggestions to enhance it as a template.

Comment thread contrib/adk-spring-boot-starter/pom.xml Outdated

<properties>
<java.version>21</java.version>
<spring-boot.version>4.0.0</spring-boot.version>

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

critical

The spring-boot.version is set to 4.0.0, which is not a stable Spring Boot release. Further down, spring-boot-dependencies is imported with version 3.3.0. This inconsistency can cause dependency conflicts and build issues. Please align the versions to a stable release, like 3.3.0.

Suggested change
<spring-boot.version>4.0.0</spring-boot.version>
<spring-boot.version>3.3.0</spring-boot.version>

<dependency>
<groupId>com.google.adk</groupId>
<artifactId>adk-spring-boot-starter</artifactId>
<version>0.3.0</version>

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

critical

The version for the adk-spring-boot-starter dependency is hardcoded to 0.3.0. The starter module in this same project has version 0.4.1-SNAPSHOT. This mismatch will likely cause build failures when building from the project root.

To ensure the sample app uses the starter built in the same project, you should align the versions. The correct version should be 0.4.1-SNAPSHOT.

Suggested change
<version>0.3.0</version>
<version>0.4.1-SNAPSHOT</version>

Comment thread contrib/adk-spring-boot-starter/pom.xml Outdated
Comment on lines +39 to +45
<dependency>
<groupId>org.springframework.boot</groupId>
<artifactId>spring-boot-dependencies</artifactId>
<version>3.3.0</version>
<type>pom</type>
<scope>import</scope>
</dependency>

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

high

A BOM (Bill of Materials) like spring-boot-dependencies should be imported in a <dependencyManagement> section, not directly in <dependencies>. This allows it to manage dependency versions without adding the BOM as a direct dependency.

Once moved, you can remove the explicit <version> tags from the other Spring Boot dependencies as they will be managed by the BOM.

Comment on lines +28 to +34
public BaseArtifactService artifactService(AdkArtifactProperties properties) {
if (properties.isGcsEnabled()) {
Storage storage = StorageOptions.getDefaultInstance().getService();
return new GcsArtifactService(properties.getBucketName(), storage);
}
return new InMemoryArtifactService();
}

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

high

The artifactService bean creates its own Storage instance via StorageOptions.getDefaultInstance().getService(), which ignores the googleCloudStorage bean defined above. This prevents users from customizing or mocking the Storage bean.

The artifactService bean should instead receive the Storage bean via dependency injection. Since the Storage bean is conditional, you can use an ObjectProvider to safely inject it.

    public BaseArtifactService artifactService(AdkArtifactProperties properties, org.springframework.beans.factory.ObjectProvider<Storage> storageProvider) {
        if (properties.isGcsEnabled()) {
            return new GcsArtifactService(properties.getBucketName(), storageProvider.getObject());
        }
        return new InMemoryArtifactService();
    }

Comment on lines +17 to +20
public BaseMemoryService memoryService(AdkMemoryProperties properties) {
// VertexAiMemoryService does not exist yet, defaulting to InMemory
return new InMemoryMemoryService();
}

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

high

If a user configures adk.memory.type=VERTEX_AI, it is silently ignored, and the InMemoryMemoryService is created. This can be misleading.

It's better to fail fast in case of an unsupported configuration. I suggest checking the property and throwing a BeanCreationException if VERTEX_AI is selected, making the failure explicit.

    public BaseMemoryService memoryService(AdkMemoryProperties properties) {
        if (properties.getType() == com.google.adk.autoconfigure.properties.AdkMemoryProperties.Type.VERTEX_AI) {
            throw new org.springframework.beans.factory.BeanCreationException("Vertex AI memory service is not yet supported. Please use IN_MEMORY type.");
        }
        // Only InMemoryMemoryService is supported for now.
        return new InMemoryMemoryService();
    }

<parent>
<groupId>org.springframework.boot</groupId>
<artifactId>spring-boot-starter-parent</artifactId>
<version>4.0.0</version>

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

high

The spring-boot-starter-parent version is set to 4.0.0, which is not a stable release. It's recommended to use the latest stable version, for example 3.3.0, to ensure stability and avoid issues with pre-release software.

Suggested change
<version>4.0.0</version>
<version>3.3.0</version>

Comment on lines +24 to +32
public Runner runner(BaseArtifactService artifactService, BaseSessionService sessionService,
BaseMemoryService memoryService) {
return new Runner(
llmAgent(),
"appName",
artifactService,
sessionService,
memoryService);
}

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

medium

There are a couple of improvements that can be made to this bean definition to follow best practices:

  1. Dependency Injection: Instead of calling the llmAgent() method directly, it's more idiomatic in Spring to declare LlmAgent as a method parameter. This makes the dependency explicit.

  2. Externalize Configuration: The appName is hardcoded to "appName". This should be externalized to a configuration file. You can inject the application name from application.yaml using @Value("${spring.application.name}").

    public Runner runner(LlmAgent llmAgent, BaseArtifactService artifactService, BaseSessionService sessionService,
                         BaseMemoryService memoryService, org.springframework.beans.factory.annotation.Value("${spring.application.name}") String appName) {
        return new Runner(
                llmAgent,
                appName,
                artifactService,
                sessionService,
                memoryService);
    }

@glaforge

Copy link
Copy Markdown
Contributor

FYI @ddobrin

@mekkiamiri

Copy link
Copy Markdown
Author

hello @ddobrin

following up on this PR. Please let me know if you’ve had a chance to review it or if you need any additional context from my side.

@ddobrin

ddobrin commented Mar 18, 2026

Copy link
Copy Markdown
Contributor

Hi @mekkiamiri
I'd like to make a few notes, if you'd like to consider them:

  1. Spring Boot BOM version conflict
  • Starter pom.xml sets spring-boot.version=4.0.0 but imports spring-boot-dependencies:3.3.0 as a BOM
  • Mixing Spring Boot 4.x artifacts with 3.x BOM will cause class incompatibilities
  • Root project uses spring-boot.version=4.0.2
  • File: contrib/adk-spring-boot-starter/pom.xml lines 12-13 and 37-42
  1. Duplicate Storage instantiation
  • AdkArtifactsAutoConfiguration.artifactService() creates StorageOptions.getDefaultInstance().getService() directly instead of injecting the googleCloudStorage() bean
  • Two separate Storage clients are created when GCS is enabled
  • File: contrib/adk-spring-boot-starter/src/main/java/com/google/adk/autoconfigure/AdkArtifactsAutoConfiguration.java lines 18-24
  1. ADK version mismatches
  • Starter version: 0.4.1-SNAPSHOT, project version: 0.9.1-SNAPSHOT
  • Sample references starter version 0.3.0
  • File: contrib/adk-spring-boot-starter/pom.xml line 5 and contrib/samples/spring-boot-adk-template/pom.xml line 18
  1. Incomplete RunConfig auto-configuration
  • Only streamingMode is exposed as a property
  • RunConfig also has: maxLlmCalls, toolExecutionMode, saveInputBlobsAsArtifacts, autoCreateSession
  • These are all important operational settings for a Spring Boot deployment
  • File: contrib/adk-spring-boot/starter/src/main/java/com/google/adk/autoconfigure/properties/AdkRunConfigProperties.java
  • Reference: core/src/main/java/com/google/adk/agents/RunConfig.java

- Re-parent contrib/adk-spring-boot-starter under google-adk-parent
  (1.4.1-SNAPSHOT); drop local <version>, <java.version>, <spring-boot.version>,
  inline BOM import, and hardcoded dependency versions
- Rename artifactId: adk-spring-boot-starter -> google-adk-spring-boot-starter
  (matches the google-adk-* convention of every other contrib module)
- Declare google-adk-firestore-session-service as <optional>true</optional>
  dependency for Firestore-backed sessions/memory (gated via @ConditionalOnClass)
- Declare google-cloud-storage (managed by libraries-bom in parent)
- Re-parent contrib/samples/spring-boot-adk-template under google-adk-samples
  with artifactId google-adk-sample-spring-boot-template
- Reference the starter via \${project.version} (no hardcoded 0.3.0)
- Align Java version to 17 (parent) instead of 21
- Lowercase the sample package: com.example.SpringBootAdkTemplate ->
  com.example.springbootadktemplate (Java package convention)
- Refactor AgentConfig: drop the user-written Runner bean (now starter-provided)
  inject LlmAgent via DI, expose @bean App with @value(spring.application.name)
- Strip the inline verification block from SpringBootAdkTemplateApplication.main
  (moved to assertions in the @SpringBootTest)
- Rename test class: SpringBootAdkTemplateApplicationTests ->
  SpringBootAdkTemplateApplicationTest (parent surefire only includes *Test.java)
- Remove embedded mvnw/.mvn/.gitignore/.gitattributes from both modules
- Update application.yaml with the documented adk.* property surface

Addresses review feedback R1, R2, R3, R6, R7 + ddobrin notes google#1 and google#3.
…ctService

Addresses gemini-code-assist review google#4 and ddobrin maintainer note google#2.

- artifactService(...) now receives ObjectProvider<Storage> instead of
  building its own Storage via StorageOptions.getDefaultInstance(). This
  ensures the googleCloudStorage() bean is the single Storage source — no
  duplicate client when GCS is enabled, user-overridable for testing.
- Throw BeanCreationException at startup when adk.artifacts.gcs-enabled=true
  but adk.artifacts.bucket-name is missing/blank (fail fast).
Addresses gemini-code-assist review google#5 and ddobrin maintainer note google#4, plus
a fix-by-side compile bug for VertexAiSessionService.

Session (AdkSessionAutoConfiguration):
- Replace Optional.empty(), Optional.empty() with null, null — the current
  VertexAiSessionService(String, String, @nullable GoogleCredentials,
  @nullable HttpOptions) constructor does not accept Optional<...> so the
  PR did not compile against ADK 1.4.1-SNAPSHOT.
- Throw BeanCreationException at startup when adk.session.type=VERTEX_AI
  is selected without project-id or location.
- Add FIRESTORE enum value with a fail-fast message that directs users to
  the contrib/firestore-session-service module (the Firestore branch
  itself lives in AdkFirestoreSessionAutoConfiguration, gated by
  @ConditionalOnClass).

Memory (AdkMemoryAutoConfiguration):
- Throw BeanCreationException for adk.memory.type=VERTEX_AI (no Vertex AI
  memory service exists in ADK today; silent downgrade to InMemory was
  misleading).
- Add FIRESTORE enum value with the same classpath-missing guidance.

Style across artifacts/session/memory:
- Replace nested if-then-throw patterns with guard clauses + early return.
- Replace static isBlank(String) helper with Optional.ofNullable(...).filter(s -> !s.isBlank())
  Optional pipelines.
- Switch expressions (case X -> ...) for the enum branches.
Addresses ddobrin maintainer note google#4.

AdkRunConfigProperties now binds the operational subset called out by the
reviewer:
- streamingMode (was already there)
- maxLlmCalls (default 500, matching RunConfig.builder())
- toolExecutionMode (default NONE, matching RunConfig.builder())
- saveInputBlobsAsArtifacts (default false)
- autoCreateSession (default false, matching the new RunConfig field
  added since the PR was opened)

AdkRunConfigAutoConfiguration applies all five to RunConfig.builder().

Out of scope for this property surface (left to user-defined RunConfig
beans via @ConditionalOnMissingBean): speechConfig, responseModalities,
inputAudioTranscription, outputAudioTranscription, avatarConfig.
Activates adk.session.type=FIRESTORE and adk.memory.type=FIRESTORE by
consuming the FirestoreSessionService / FirestoreMemoryService impls that
already exist in contrib/firestore-session-service.

New classes:
- AdkFirestoreProperties: adk.firestore.{project-id,database-id} — both
  optional (fall back to ADC project and "(default)" database).
- AdkFirestoreAutoConfiguration: produces a com.google.cloud.firestore.Firestore
  client bean. Gated by @ConditionalOnClass(Firestore.class) +
  @ConditionalOnMissingBean so Spring Cloud GCP users and tests with their
  own Firestore beans take precedence.
- AdkFirestoreSessionAutoConfiguration: produces FirestoreSessionService
  when both adk.session.type=FIRESTORE AND FirestoreSessionService is on
  the classpath. Runs @AutoConfigureBefore the regular session config so
  @ConditionalOnMissingBean drops the in-memory path.
- AdkFirestoreMemoryAutoConfiguration: same pattern for memory.

No code in this commit is required for users who stay on IN_MEMORY or
VERTEX_AI — Firestore branches activate only when the corresponding
property is set AND the contrib jar is on the classpath.
This eliminates the Runner boilerplate the sample (and any user) had to
write — declared in the rebase prompt as the POC's primary finding.

New AdkRunnerAutoConfiguration:
- Activates when exactly one @bean App is present (@ConditionalOnBean +
  @ConditionalOnSingleCandidate). Multi-BU apps with multiple App beans
  fall through cleanly: the user wires explicit @bean Runner per App.
- @ConditionalOnMissingBean(Runner.class) so user-declared Runners always
  win.
- Injects BaseMemoryService via ObjectProvider since Runner.Builder
  accepts null memory (the starter does not always produce one).
- @AutoConfigureAfter the five service-producing autoconfigs to guarantee
  the dependencies are resolved before this factory fires.

META-INF/spring/...AutoConfiguration.imports now registers all eight
auto-config classes (3 originals + 4 Firestore-related + Runner).
Starter README now documents:
- The new artifactId (google-adk-spring-boot-starter)
- The recommended pairing with google-adk-spring-ai for LLMs
- The new @bean Runner autoconfig (users no longer hand-write a Runner)
- The full adk.* property surface including Firestore + extended RunConfig
- The persistence-backend matrix (IN_MEMORY / VERTEX_AI / FIRESTORE / GCS)
- A dedicated 'Multiple business-unit agents in one Spring Boot app'
  section showing the @ConditionalOnSingleCandidate(App.class) escape hatch
- All eight auto-config classes by name + activation rules
- Fail-fast conditions with remediation messages
- The follow-up Spring AI bridges as a documented roadmap item

Sample README:
- Java 17 (not 21)
- mvn -pl ... -am verify from repo root (no separate starter install)
- Optional Spring AI substrate via google-adk-spring-ai
- New lowercase package paths
…ention

contrib/adk-spring-boot-starter/ -> contrib/spring-boot-starter/

The previous directory name carried an extra 'adk-' prefix that none of
the other contrib modules use. Every other contrib follows
'contrib/<short-name>/' with the Maven artifactId 'google-adk-<short-name>':

  contrib/spring-ai/                    -> google-adk-spring-ai
  contrib/langchain4j/                  -> google-adk-langchain4j
  contrib/firestore-session-service/    -> google-adk-firestore-session-service
  contrib/planners/                     -> google-adk-planners

Aligning the starter to the same shape:

  contrib/spring-boot-starter/          -> google-adk-spring-boot-starter

Updated:
- Root pom.xml <modules> entry to point at the new path.
- Sample README link to the starter README.
- Linter-driven reformatting on the two sample source files
  (AgentConfig, AgentService) carried in from the build.
@mekkiamiri mekkiamiri force-pushed the feat-spring-boot-starter branch from 4f3123c to 66ab62c Compare June 14, 2026 23:47
@mekkiamiri

Copy link
Copy Markdown
Author

Hi @ddobrin
i update the pr could you please check ?
Thanks

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants