Skip to content

Updated tests in Spring AI, Langchain4j, deps for Spring AI and GenAISDK#1046

Merged
copybara-service[bot] merged 1 commit intogoogle:mainfrom
ddobrin:spring-ai-update-20-M3
Mar 19, 2026
Merged

Updated tests in Spring AI, Langchain4j, deps for Spring AI and GenAISDK#1046
copybara-service[bot] merged 1 commit intogoogle:mainfrom
ddobrin:spring-ai-update-20-M3

Conversation

@ddobrin
Copy link
Contributor

@ddobrin ddobrin commented Mar 17, 2026

Updated to Spring AI 2.0.0M3
GenAI SDK 1.43.0
Tests in /contrib

@gemini-code-assist
Copy link
Contributor

Summary of Changes

Hello, 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 focuses on essential dependency upgrades and corresponding test adjustments. It updates the Spring AI and GenAI SDK versions to their latest milestones, ensuring the project benefits from recent library enhancements. Additionally, it refactors existing integration tests for both Langchain4j and Spring AI to accommodate API changes and model updates, improving test reliability and maintainability.

Highlights

  • Dependency Updates: Updated Spring AI to version 2.0.0M3 and GenAI SDK to 1.43.0, ensuring compatibility with the latest features and improvements from these libraries.
  • Langchain4j Test Updates: Refactored Langchain4j integration tests to use the updated Claude model name 'claude-sonnet-4-6' and adjusted an assertion to reflect expected output changes.
  • Spring AI Anthropic Integration Test Refactoring: Modernized the Spring AI Anthropic integration tests by removing direct AnthropicApi usage and adopting the AnthropicChatOptions builder pattern for model configuration, aligning with Spring AI's updated API.

🧠 New Feature in Public Preview: You can now enable Memory to help Gemini Code Assist learn from your team's feedback. This makes future code reviews more consistent and personalized to your project's style. Click here to enable Memory in your admin console.

Changelog
  • contrib/langchain4j/src/test/java/com/google/adk/models/langchain4j/LangChain4jIntegrationTest.java
    • Updated the constant for the Claude model name from 'claude-3-7-sonnet-20250219' to 'claude-sonnet-4-6'.
    • Modified AnthropicChatModel and LangChain4j instantiations to use the new Claude model name.
    • Adjusted an assertion in testSingleAgentWithTools() from checking for 'beautiful' to 'sunny'.
  • contrib/spring-ai/pom.xml
    • Updated the spring-ai.version property from 2.0.0-M2 to 2.0.0-M3.
  • contrib/spring-ai/src/test/java/com/google/adk/models/springai/integrations/AnthropicApiIntegrationTest.java
    • Removed the import for org.springframework.ai.anthropic.api.AnthropicApi.
    • Refactored all AnthropicChatModel instantiations to use AnthropicChatOptions.builder() for configuration, including model, maxTokens, and API key.
  • pom.xml
    • Updated the google.genai.version property from 1.41.0 to 1.43.0.
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.

Copy link
Contributor

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

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 updates several dependencies, including Spring AI to 2.0.0-M3 and GenAI SDK to 1.43.0, and adjusts the test code accordingly. The changes in the Langchain4j integration tests correctly reflect the model updates.

However, the updates in AnthropicApiIntegrationTest.java for Spring AI integration introduce some issues. There are several compilation errors due to incorrect usage of the updated AnthropicChatModel builder API. Additionally, one of the tests, testConfigurationOptions, has lost its original purpose of testing custom configurations. I've provided critical feedback to address these issues. I've also included a suggestion to refactor duplicated code to improve maintainability.

.apiKey(System.getenv("ANTHROPIC_API_KEY"))
.build();

AnthropicChatModel anthropicModel = AnthropicChatModel.builder().options(options).build();
Copy link
Contributor

Choose a reason for hiding this comment

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

critical

The builder method .options() is incorrect for AnthropicChatModel.builder(). According to the Spring AI 2.0.0-M3 API, you should use .withDefaultOptions(). This will cause a compilation error.

Suggested change
AnthropicChatModel anthropicModel = AnthropicChatModel.builder().options(options).build();
AnthropicChatModel anthropicModel = AnthropicChatModel.builder().withDefaultOptions(options).build();

.apiKey(System.getenv("ANTHROPIC_API_KEY"))
.build();

AnthropicChatModel anthropicModel = AnthropicChatModel.builder().options(options).build();
Copy link
Contributor

Choose a reason for hiding this comment

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

critical

The builder method .options() is incorrect. It should be .withDefaultOptions() to comply with the updated Spring AI API and avoid a compilation error.

Suggested change
AnthropicChatModel anthropicModel = AnthropicChatModel.builder().options(options).build();
AnthropicChatModel anthropicModel = AnthropicChatModel.builder().withDefaultOptions(options).build();

.apiKey(System.getenv("ANTHROPIC_API_KEY"))
.build();

AnthropicChatModel anthropicModel = AnthropicChatModel.builder().options(options).build();
Copy link
Contributor

Choose a reason for hiding this comment

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

critical

The builder method .options() is incorrect. It should be .withDefaultOptions() to comply with the updated Spring AI API and avoid a compilation error.

Suggested change
AnthropicChatModel anthropicModel = AnthropicChatModel.builder().options(options).build();
AnthropicChatModel anthropicModel = AnthropicChatModel.builder().withDefaultOptions(options).build();

.maxTokens(1024)
.apiKey(System.getenv("ANTHROPIC_API_KEY"))
.build();
AnthropicChatModel anthropicModel = AnthropicChatModel.builder().options(options).build();
Copy link
Contributor

Choose a reason for hiding this comment

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

critical

The builder method .options() is incorrect. It should be .withDefaultOptions() to comply with the updated Spring AI API and avoid a compilation error.

Suggested change
AnthropicChatModel anthropicModel = AnthropicChatModel.builder().options(options).build();
AnthropicChatModel anthropicModel = AnthropicChatModel.builder().withDefaultOptions(options).build();

Comment on lines +288 to +294
var options =
AnthropicChatOptions.builder()
.model(CLAUDE_MODEL)
.maxTokens(1024)
.apiKey(System.getenv("ANTHROPIC_API_KEY"))
.build();
AnthropicChatModel anthropicModel = AnthropicChatModel.builder().options(options).build();
Copy link
Contributor

Choose a reason for hiding this comment

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

critical

This test testConfigurationOptions seems to have lost its original purpose. It's supposed to test custom configurations like temperature and maxTokens, but the new code uses the same default options as other tests. Additionally, the builder method .options() is incorrect and should be .withDefaultOptions().

To fix this and restore the test's intent, you should reintroduce the custom options.

Suggested change
var options =
AnthropicChatOptions.builder()
.model(CLAUDE_MODEL)
.maxTokens(1024)
.apiKey(System.getenv("ANTHROPIC_API_KEY"))
.build();
AnthropicChatModel anthropicModel = AnthropicChatModel.builder().options(options).build();
var options =
AnthropicChatOptions.builder()
.model(CLAUDE_MODEL)
.temperature(0.7F)
.maxTokens(100)
.apiKey(System.getenv("ANTHROPIC_API_KEY"))
.build();
AnthropicChatModel anthropicModel =
AnthropicChatModel.builder().withDefaultOptions(options).build();

Comment on lines +55 to +62
var options =
AnthropicChatOptions.builder()
.model(CLAUDE_MODEL)
.maxTokens(1024)
.apiKey(System.getenv("ANTHROPIC_API_KEY"))
.build();

AnthropicChatModel anthropicModel = AnthropicChatModel.builder().options(options).build();
Copy link
Contributor

Choose a reason for hiding this comment

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

medium

The logic for creating a default AnthropicChatModel is duplicated across several tests (testSimpleAgentWithRealAnthropicApi, testStreamingWithRealAnthropicApi, etc.). To improve maintainability and reduce redundancy, consider extracting this into a private helper method.

For example, you could add a method like this to the class:

private AnthropicChatModel createDefaultAnthropicChatModel() {
  var options =
      AnthropicChatOptions.builder()
          .model(CLAUDE_MODEL)
          .maxTokens(1024)
          .apiKey(System.getenv("ANTHROPIC_API_KEY"))
          .build();
  // Note: .withDefaultOptions() should be used instead of .options()
  return AnthropicChatModel.builder().withDefaultOptions(options).build();
}

Then you could replace this block in each test with:

AnthropicChatModel anthropicModel = createDefaultAnthropicChatModel();

@ddobrin ddobrin force-pushed the spring-ai-update-20-M3 branch from e6454db to dfbab95 Compare March 19, 2026 16:04
@copybara-service copybara-service bot merged commit 55a4953 into google:main Mar 19, 2026
6 checks passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants