Skip to content

@McpToolbox defined tool not available when AiService is constructed manually #2011

@bitsofinfo

Description

@bitsofinfo

Hi,
I am manually constructing an AiService like this:

Class<? extends InferenceService> inferenceServiceClass = MyTools.class;

InferenceService service = AiServices.builder(inferenceServiceClass)
      .systemMessageProvider(memoryId -> systemPromptDef.renderPrompt())
      .chatModel(aiModel.getChatModel())
      .chatMemoryProvider(config.getChatMemoryProvider())
      .hallucinatedToolNameStrategy((req ->
              new ToolExecutionResultMessage(req.id(),req.name(),
                      "[Tool output omitted due to hallucination]")))
      .build();

the inferenceServiceClass is = MyService.class:

public interface InferenceService {
    String invoke(String message, String memoryId);
}

@CreatedAware
public interface MyService extends InferenceService {

    @ToolBox({
            WebSearchTool.class,
            MessageRecordTool.class
    })
    @McpToolBox("mytools") 
    @Override
    String invoke(@UserMessage String message, @MemoryId String memoryId); 

}

The mcp tool defined as mytools is properly setup in application.yaml. However this tool is never available. I don't see it being sent in the list of tools to the llm. (the others (websearch/message record) are being sent OK.

I also had to put this @CreatedAware on the interface and I'm not sure why.

thanks!

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions