private boolean isFunctionalType(Method toolMethod) {
var isFunction = ClassUtils.isAssignable(toolMethod.getReturnType(), Function.class)
|| ClassUtils.isAssignable(toolMethod.getReturnType(), Supplier.class)
|| ClassUtils.isAssignable(toolMethod.getReturnType(), Consumer.class);
if (isFunction) {
logger.warn("Method {} is annotated with @Tool but returns a functional type. "
+ "This is not supported and the method will be ignored.", toolMethod.getName());
}
return isFunction;
}
The isFunctionalType method of class MethodToolCallbackProvider has a bug ( Unable to correctly determine function type ),fixed:
private boolean isFunctionalType(Method toolMethod) {
var isFunction = ClassUtils.isAssignable(Function.class, toolMethod.getReturnType())
|| ClassUtils.isAssignable(Supplier.class, toolMethod.getReturnType())
|| ClassUtils.isAssignable(Consumer.class, toolMethod.getReturnType());
if (isFunction) {
log.warn("Method {} is annotated with @Tool but returns a functional type. "
+ "This is not supported and the method will be ignored.", toolMethod.getName());
}
return isFunction;
}
Comment From: jcgouveia
This is a very serious bug. I have tools that return just the "Object" type and I cannot use them, because isFunctionalType returns true, which is obviously wrong.
Comment From: sunyuhan1998
Hi @TheEterna @jcgouveia , I pushed a PR to fix the issue, can you guys help review the PR https://github.com/spring-projects/spring-ai/pull/3479 ? Thank you.