Bug Desception

I have the following FunctionToolCallback instance created and registered to ChatClient Builder as below:

FunctionToolCallback toolCallback1 = ...
FunctionToolCallback toolCallback2 = ...
ChatClient.create(chatModel)
    .prompt("What's the weather like in Copenhagen?")
    .tools(toolCallback1, toolCallback2)
    .call()
    .content();

The above tool registration will not take effect because it actually calls the Builder defaultTools(Object... toolObjects); overload method instead of the Builder defaultTools(List<ToolCallback> toolCallbacks);.

Builder defaultTools(Object... toolObjects); method only works for Method tool, because inside ToolCallbacks.from(toolObjects) it only accepts Method tools:

@Override
public ChatClientRequestSpec tools(Object... toolObjects) {
    Assert.notNull(toolObjects, "toolObjects cannot be null");
    Assert.noNullElements(toolObjects, "toolObjects cannot contain null elements");
    this.functionCallbacks.addAll(Arrays.asList(ToolCallbacks.from(toolObjects))); // here only accepts Method tools
    return this;
}

Only the following form is correct:

ToolCallback toolCallback1 = ... // must be ToolCallback type but not FunctionToolCallback type.
ToolCallback toolCallback2 = ... // must be ToolCallback type but not FunctionToolCallback type.
ChatClient.create(chatModel)
    .prompt("What's the weather like in Copenhagen?")
    .tools(toolCallback1, toolCallback2)
    .call()
    .content();

It's very easy to make the above mistake. There's no compilation error because of the overload methods and it's not easy to debug and find the problem.

Environment

1.0.0-M6