Skip to content

Tool call fix for Spring AI - Let ADK call tools#733

Open
alexcheng1982 wants to merge 1 commit intogoogle:mainfrom
alexcheng1982:spring-ai-tool-call-fix
Open

Tool call fix for Spring AI - Let ADK call tools#733
alexcheng1982 wants to merge 1 commit intogoogle:mainfrom
alexcheng1982:spring-ai-tool-call-fix

Conversation

@alexcheng1982
Copy link

In the current implementation of Spring AI integration, tool calls are handled by Spring AI, this means the code needs to handle the conversion between Spring AI tools and ADK tools. This is unnecessary and introduces serval issues, like ToolContext is null (see #699 ), before and after tool callbacks are not invoked.

In this PR, tool calls are handled by ADK, just like other BaseLlm implementations.

  • Spring AI tool calls execution is disabled by setting internalToolExecutionEnabled to false in ToolCallingChatOptions.
  • FunctionToolCallback in Spring AI simply returns empty strings. FunctionToolCallback is only used to pass tool definitions. The actual tool calls are handled by ADK.
  • Handles ToolResponseMessage in MessageConverter.
  • Removed unused code and test.

Let ADK call tools
@glaforge
Copy link
Contributor

cc @ddobrin for your info

@ddobrin
Copy link
Contributor

ddobrin commented Feb 9, 2026

Hi @alexcheng1982
There is the argument that tool calling could be handled, depending on the use-case, in either the LLMAgent or by SpringAI.

It might be better that there is a (flexible) config which should allow for the selection of who should do function calling

@ddobrin
Copy link
Contributor

ddobrin commented Mar 18, 2026

A couple of notes here:

  1. Data loss in handleUserContent() when Content has both text and function response parts.

The old code added both UserMessage and toolResponseMessages to the result list.
The new code uses an if/else that returns only tool response messages when present, discarding any
accumulated text and media content.
This will cause data loss when a Content object contains both text parts and functionResponse parts.

[link ](https://github.com/google/adk-java/blob/fba5f4fe41ac12f30ff68f9992051abbee17c2eb/contrib/spring-ai/src/main/java/com/google/adk/models/springai/MessageC
onverter.java#L263-L269)

  1. Test coverage reduced with no replacement.

ToolConverterArgumentProcessingTest.java (128 lines, 4 test scenarios) was deleted along with the processArguments() method.
No new tests were added for the new behaviour: ToolResponseMessage creation from function responses (lines 209-228), the no-op tool function in ToolConverter, or the internalToolExecutionEnabled(false) configuration.

[link]( https://github.com/google/adk-java/blob/fba5f4fe41ac12f30ff68f9992051abbee17c2eb/contrib/spring-ai/src/main/java/com/google/adk/models/springai/MessageC
onverter.java#L208-L229)

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