adk-java icon indicating copy to clipboard operation
adk-java copied to clipboard

Agent tools are not propagated to Llm query

Open Vatavuk opened this issue 1 year ago • 2 comments

Agent tools are not passed to LLM as function calls when using Gemini as BaseLlm. Tools field in LlmRequest is empty in Gemini class.

To Reproduce Steps to reproduce the behavior:

LlmAgent.builder()
        .name("My agent")
        .description("Some desc")
        .model("gemini-2.0-flash")
        .instruction("You are ahelpful agent for solving crimes")
        .tools(CustomTool("solve_crimes", "Will solve a crime"))
        .build()

class CustomTool(val name: String, val description: String) : BaseTool(name, description)

The tool is never triggered. (The behavior is the same with pre-build tools)

Expected behavior Should include the tool in function call towards llm.

Desktop:

  • OS: [macOS]
  • Java version: openjdk-24
  • ADK version: 0.1.0

Vatavuk avatar Jun 15 '25 14:06 Vatavuk

The system prompt tries to guide the LllmAgent for when to do the tool call. Could you include an example where you explicitly say when the agent should call the tool and then send a request which would exactly meet that criteria? It's possible that your prompt may just not have triggered a tool call. We have some tool call examples in https://google.github.io/adk-docs/tools/function-tools/#java so please let us know if these still yield issues!

Poggecci avatar Jun 23 '25 21:06 Poggecci

@Poggecci Found the problem, I didn't override declaration() method in my custom tool class. Now it's working with this part: override fun declaration(): Optional<FunctionDeclaration> { val builder = FunctionDeclaration.builder().description(this.description()).name(this.name()) return Optional.of(builder.build()) }

Thx for the help!

Vatavuk avatar Jul 07 '25 12:07 Vatavuk