Tools never been invoked #992
Replies: 4 comments
-
|
I also currently check tool invocation, and managed to run this test Tool method: package com.embabel.template.chris;
import org.springframework.ai.tool.annotation.Tool;
import lombok.experimental.Accessors;
import lombok.extern.slf4j.Slf4j;
@Slf4j
public class TestToolObj
{
@Tool(description = "Use this tool to answer who is Mayor of Kaiserslautern.")
public String getMayorOfKaiserslautern()
{
log.info("Get Mayor of Kaiserslautern called.");
return "The Mayor of Kaiserslautern is Hitzli Putzli.";
}
}package com.embabel.template.chris;
import com.embabel.agent.api.annotation.AchievesGoal;
import com.embabel.agent.api.annotation.Action;
import com.embabel.agent.api.annotation.Agent;
import com.embabel.agent.api.common.OperationContext;
import com.embabel.agent.api.common.PromptRunner;
import com.embabel.agent.domain.io.UserInput;
@Agent(description = "Answers questions about Kaiserslautern and meeting minutes based on OpenSearch data")
public class RatsInfoAgentWithToolObj
{
@AchievesGoal(description = "Questions about Kaiserslautern and meeting minutes including details of a complete result list have been answered")
@Action
String searchMeetingMinutes(UserInput userInput, OperationContext context)
{
TestToolObj testToolObj = new TestToolObj();
PromptRunner promptRunner = context.ai().withDefaultLlm();
promptRunner = promptRunner.withToolObject(testToolObj);
// Prompt inside the embabel shell: x "Who is Mayor of Kaiserslautern."
return promptRunner.createObject(userInput.getContent().trim(), String.class);
}
}package com.embabel.template;
import com.embabel.agent.config.annotation.EnableAgents;
import com.embabel.agent.config.annotation.LoggingThemes;
import org.springframework.boot.SpringApplication;
import org.springframework.boot.autoconfigure.SpringBootApplication;
@SpringBootApplication
@EnableAgents(loggingTheme = "")
class ProjectNameApplication {
public static void main(String[] args) {
SpringApplication.run(ProjectNameApplication.class, args);
}
}I run it with a olllama server and a gpt-oss120b model. The tool method log message "The Mayor of Kaiserslautern is Hitzli Putzli." Is shown on every call of Maybe you have a similar situation? Have you tried to insert a log message inside your tool method? |
Beta Was this translation helpful? Give feedback.
-
|
Thanks. Good to hear it can be working without having to create ToolGroups etc. I presume you don’t run an MCP server either? Like you, I’ve added logging in the tools but I can see unambiguously that they are never being called. Perhaps I’m overwhelming the LLM, I’ve got a fairly long prompt. Will try to break it down a little. Thanks again. |
Beta Was this translation helpful? Give feedback.
-
|
I made some progress and now have gpt-oss calling tools. Steps taken:
Works quite well now! |
Beta Was this translation helpful? Give feedback.
-
|
While local models are really important, it can be useful to try a larger (commercial) model at least once when debugging to see whether or not it's the model fault. Eg if you try with GPT 4.1 and it's not calling your tool there's definitely a problem. |
Beta Was this translation helpful? Give feedback.
Uh oh!
There was an error while loading. Please reload this page.
Uh oh!
There was an error while loading. Please reload this page.
-
Hi, thanks for this amazing initiative!
I've had fun creating an Agent to make recommendations from certain well-know merchants' new releases. It works relatively well but I can't for the life of me figure out how to wire Tools into the agent in order to improve the accuracy and timeliness of the data from which it makes its recommendation decisions.
The LLMs run in Ollama via a remote URL connection. I've created Tools locally as part of the project - firecrawl, wikipedia and brave. They work fine stand-alone and I've wired them up with Tool annotations, e.g.
The agent is given the tools in its Action method:
and this can be seen in logs at runtime:
Finally, I am being explicit in the prompt to the LLM that it needs to use the Tools:
BUT despite all this, I've never seen a Tool actually being called, ever. I've tested with Qwen3, gpt-oss and Gemma3.
Any ideas what might be missing?
Beta Was this translation helpful? Give feedback.
All reactions