Skip to content

Replace Spring AI 2.0 deprecated API - #1840

Merged
igordayen merged 2 commits into
embabel:mainfrom
guanxuc:main
Jul 31, 2026
Merged

Replace Spring AI 2.0 deprecated API#1840
igordayen merged 2 commits into
embabel:mainfrom
guanxuc:main

Conversation

@guanxuc

@guanxuc guanxuc commented Jul 30, 2026

Copy link
Copy Markdown
Contributor
  • Rename ChatModel.getDefaultOptions() to getOptions()
  • Rename ChatClientCustomizer to ChatClientBuilderCustomizer
  • Replace ChatClient.toolCallbacks() to tools()
  • Convert OpenAiEmbeddingModel from constructor to builder pattern
  • Update related comments and documentation to reflect new API names

@guanxuc
guanxuc force-pushed the main branch 3 times, most recently from f22027b to dab96ac Compare July 30, 2026 10:03
@igordayen

igordayen commented Jul 30, 2026

Copy link
Copy Markdown
Contributor

@guanxuc - good call.

requires coordination with PR #1837 and PR #1826.

Also requires testing of all IT tests in embabel-agent and embabel-agent-experimental repo.

@arnabnandy7 - FYI

@arnabnandy7

Copy link
Copy Markdown
Contributor

@guanxuc - good call.

requires coordination with PR #1837 and PR #1826.

Also requires testing of all IT tests in embabel-agent and embabel-agent-experimental repo.

@arnabnandy7 - FYI

Let me analyse and share the impact statement for #1826

- Rename ChatModel.getDefaultOptions() to getOptions()
- Rename ChatClientCustomizer to ChatClientBuilderCustomizer
- Replace ChatClient.toolCallbacks() to tools()
- Convert OpenAiEmbeddingModel from constructor to builder pattern
- Update related comments and documentation to reflect new API names

Signed-off-by: guanxu <1510424541@qq.com>
@arnabnandy7

Copy link
Copy Markdown
Contributor

For #1836 the main integration risk is that .tools(...) preserves the previous .toolCallbacks(...) behavior. Once, it's merged only then we can check how to proceed further.

@arnabnandy7

arnabnandy7 commented Jul 30, 2026

Copy link
Copy Markdown
Contributor

This PR overlaps with the streaming changes in #1826, primarily around the Spring AI ChatClient request API. Once it is merged, this branch (#1826) will need to be rebased and the request-spec calls updated from .toolCallbacks(...) to .tools(...).

The provider-neutral streaming tool-loop design is unaffected. During conflict resolution, we will retain the ChatModel-based single-inference streamer and Embabel-managed tool execution. The ToolCallingChatOptions.mutate().toolCallbacks(...) calls also remain valid because #1840 only replaces the deprecated ChatClient request-spec method.

The LangChain4j/Ollama unfolding integration test is unaffected. @igordayen

@igordayen

Copy link
Copy Markdown
Contributor

@guanxuc, @arnabnandy7 - please confirm the preferred order of merges.
Merge only after passing IT tests, though.
Thanks

@arnabnandy7

Copy link
Copy Markdown
Contributor

@guanxuc, @arnabnandy7 - please confirm the preferred order of merges. Merge only after passing IT tests, though. Thanks

Order should be as follows;

#1840
#1819
#1837
#1826

@igordayen

Copy link
Copy Markdown
Contributor

#1840
#1819
#1837
#1826

==> im concern with #1819, as not seeing active development on this track; de-prioritize it?

@arnabnandy7

Copy link
Copy Markdown
Contributor

==> im concern with #1819, as not seeing active development on this track; de-prioritize it?

That's one option but if/when he starts it back he has to carefully rebase and refactor to incorporate the changes we'll be merging into main. Ofcourse it's only if this issue is being actively looked into later on.

@igordayen igordayen 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.

@guanxuc - visual inspection looks good, however lets execute integration tests , especially IT tests for double esurance.
Thanks

@igordayen

Copy link
Copy Markdown
Contributor

My plan to execute tests later in day, thanks

@igordayen

Copy link
Copy Markdown
Contributor

requires attention:


[INFO] Running com.embabel.agent.spi.support.springai.InstrumentedChatModelTest$DefaultOptionsTests
[ERROR] Tests run: 1, Failures: 0, Errors: 1, Skipped: 0, Time elapsed: 0.003 s <<< FAILURE! -- in com.embabel.agent.spi.support.springai.InstrumentedChatModelTest$DefaultOptionsTests
[ERROR] com.embabel.agent.spi.support.springai.InstrumentedChatModelTest$DefaultOptionsTests.does not emit any event -- Time elapsed: 0.002 s <<< ERROR!
io.mockk.MockKException: no answer found for: ChatModel(#7175).getOptions()
	at io.mockk.impl.stub.MockKStub.defaultAnswer(MockKStub.kt:93)
	at io.mockk.impl.stub.MockKStub.answer(MockKStub.kt:42)
	at io.mockk.impl.recording.states.AnsweringState.call(AnsweringState.kt:16)
	at io.mockk.impl.recording.CommonCallRecorder.call(CommonCallRecorder.kt:53)
	at io.mockk.impl.stub.MockKStub.handleInvocation(MockKStub.kt:271)
	at io.mockk.impl.instantiation.JvmMockFactoryHelper$mockHandler$1.invocation(JvmMockFactoryHelper.kt:24)
	at io.mockk.proxy.jvm.advice.Interceptor.call(Interceptor.kt:21)
	at io.mockk.proxy.jvm.advice.BaseAdvice.handle(BaseAdvice.kt:42)
	at io.mockk.proxy.jvm.advice.jvm.JvmMockKProxyInterceptor.intercept(JvmMockKProxyInterceptor.java:31)
	at org.springframework.ai.chat.model.ChatModel$Subclass34.getOptions(Unknown Source)
	at com.embabel.agent.spi.support.springai.InstrumentedChatModel.getOptions(InstrumentedChatModel.kt:95)
	at org.springframework.ai.chat.model.ChatModel.getDefaultOptions(ChatModel.java:61)
	at com.embabel.agent.spi.support.springai.InstrumentedChatModelTest$DefaultOptionsTests.does not emit any event(InstrumentedChatModelTest.kt:184)

[INFO] Tests run: 0, Failures: 0, Errors: 0, Skipped: 0, Time elapsed: 0.004 s -- in com.embabel.agent.spi.support.springai.InstrumentedChatModelTest
[INFO] 
[INFO] Results:
[INFO] 
[ERROR] Errors: 
[ERROR] com.embabel.agent.spi.support.springai.InstrumentedChatModelTest$DefaultOptionsTests.does not emit any event
[ERROR]   Run 1: InstrumentedChatModelTest$DefaultOptionsTests.does not emit any event:184 » MockK no answer found for: ChatModel(#3159).getOptions()
[ERROR]   Run 2: InstrumentedChatModelTest$DefaultOptionsTests.does not emit any event:184 » MockK no answer found for: ChatModel(#7175).getOptions()
[INFO] 
[INFO] 
[ERROR] Tests run: 3950, Failures: 0, Errors: 1, Skipped: 23

Did you run unit tests? @guanxuc - that is even prior to IT tests.

@igordayen

Copy link
Copy Markdown
Contributor

@guanxuc @arnabnandy7 - successfully passed all integration tests.
However, the reported unit test failure needs to be addressed before merging.
thx.

Signed-off-by: guanxu <1510424541@qq.com>
@guanxuc

guanxuc commented Jul 31, 2026

Copy link
Copy Markdown
Contributor Author

requires attention:


[INFO] Running com.embabel.agent.spi.support.springai.InstrumentedChatModelTest$DefaultOptionsTests
[ERROR] Tests run: 1, Failures: 0, Errors: 1, Skipped: 0, Time elapsed: 0.003 s <<< FAILURE! -- in com.embabel.agent.spi.support.springai.InstrumentedChatModelTest$DefaultOptionsTests
[ERROR] com.embabel.agent.spi.support.springai.InstrumentedChatModelTest$DefaultOptionsTests.does not emit any event -- Time elapsed: 0.002 s <<< ERROR!
io.mockk.MockKException: no answer found for: ChatModel(#7175).getOptions()
	at io.mockk.impl.stub.MockKStub.defaultAnswer(MockKStub.kt:93)
	at io.mockk.impl.stub.MockKStub.answer(MockKStub.kt:42)
	at io.mockk.impl.recording.states.AnsweringState.call(AnsweringState.kt:16)
	at io.mockk.impl.recording.CommonCallRecorder.call(CommonCallRecorder.kt:53)
	at io.mockk.impl.stub.MockKStub.handleInvocation(MockKStub.kt:271)
	at io.mockk.impl.instantiation.JvmMockFactoryHelper$mockHandler$1.invocation(JvmMockFactoryHelper.kt:24)
	at io.mockk.proxy.jvm.advice.Interceptor.call(Interceptor.kt:21)
	at io.mockk.proxy.jvm.advice.BaseAdvice.handle(BaseAdvice.kt:42)
	at io.mockk.proxy.jvm.advice.jvm.JvmMockKProxyInterceptor.intercept(JvmMockKProxyInterceptor.java:31)
	at org.springframework.ai.chat.model.ChatModel$Subclass34.getOptions(Unknown Source)
	at com.embabel.agent.spi.support.springai.InstrumentedChatModel.getOptions(InstrumentedChatModel.kt:95)
	at org.springframework.ai.chat.model.ChatModel.getDefaultOptions(ChatModel.java:61)
	at com.embabel.agent.spi.support.springai.InstrumentedChatModelTest$DefaultOptionsTests.does not emit any event(InstrumentedChatModelTest.kt:184)

[INFO] Tests run: 0, Failures: 0, Errors: 0, Skipped: 0, Time elapsed: 0.004 s -- in com.embabel.agent.spi.support.springai.InstrumentedChatModelTest
[INFO] 
[INFO] Results:
[INFO] 
[ERROR] Errors: 
[ERROR] com.embabel.agent.spi.support.springai.InstrumentedChatModelTest$DefaultOptionsTests.does not emit any event
[ERROR]   Run 1: InstrumentedChatModelTest$DefaultOptionsTests.does not emit any event:184 » MockK no answer found for: ChatModel(#3159).getOptions()
[ERROR]   Run 2: InstrumentedChatModelTest$DefaultOptionsTests.does not emit any event:184 » MockK no answer found for: ChatModel(#7175).getOptions()
[INFO] 
[INFO] 
[ERROR] Tests run: 3950, Failures: 0, Errors: 1, Skipped: 23

Did you run unit tests? @guanxuc - that is even prior to IT tests.

Thanks for the feedback! Apologies for overlooking this. I've applied the fix and all tests are now passing.

@igordayen

Copy link
Copy Markdown
Contributor

Test passed!
Thanks

@igordayen

igordayen commented Jul 31, 2026

Copy link
Copy Markdown
Contributor

Builder pattern for OpenAiEmbeddingModel:

  • Replace new OpenAiEmbeddingModel(...) with OpenAiEmbeddingModel.builder()...build()
  • Check if any subclasses or mocks need updating

Easy misses to watch for:

  • XML/properties config files referencing old class names
  • Spring bean definitions (@Bean ChatClientCustomizer ...)
  • Test classes extending or mocking the renamed types
  • Any documentation, READMEs, or example code in the repo

@guanxuc - could you review and see that everything got spotted cleanly? Thank you

Did you capture all deprecated warnings from logs related to the upgrade? thx

@guanxuc

guanxuc commented Jul 31, 2026

Copy link
Copy Markdown
Contributor Author

@igordayen Thanks for the detailed checklist! I've gone through all the mentioned areas (XML configs, Spring beans, tests, and docs) and confirmed that everything has been properly migrated. No stale references found.

@igordayen
igordayen merged commit c1930f0 into embabel:main Jul 31, 2026
1 check passed
@guanxuc

guanxuc commented Jul 31, 2026

Copy link
Copy Markdown
Contributor Author

My plan to execute tests later in day, thanks

Hi @igordayen , I noticed that the GitHub CI workflow is currently located at embabel-agent/embabel-agent-api/.github/workflows/maven.yml rather than in the repository root. Should we move the .github directory to the root so that GitHub Actions can properly detect it?
Additionally, it looks like .embabel and .idea are also nested under the submodule. Should these be moved to the root as well?

@igordayen

Copy link
Copy Markdown
Contributor

Nice work, thank you, @guanxuc

@igordayen

Copy link
Copy Markdown
Contributor

My plan to execute tests later in day, thanks

Hi @igordayen , I noticed that the GitHub CI workflow is currently located at embabel-agent/embabel-agent-api/.github/workflows/maven.yml rather than in the repository root. Should we move the .github directory to the root so that GitHub Actions can properly detect it? Additionally, it looks like .embabel and .idea are also nested under the submodule. Should these be moved to the root as well?

@alexheifetz FYI

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

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants