File tree Expand file tree Collapse file tree 2 files changed +33
-0
lines changed
main/java/org/springframework/ai/tool/method
test/java/org/springframework/ai/tool/method Expand file tree Collapse file tree 2 files changed +33
-0
lines changed Original file line number Diff line number Diff line change @@ -88,6 +88,7 @@ public ToolCallback[] getToolCallbacks() {
8888 AopUtils .isAopProxy (toolObject ) ? AopUtils .getTargetClass (toolObject ) : toolObject .getClass ()))
8989 .filter (this ::isToolAnnotatedMethod )
9090 .filter (toolMethod -> !isFunctionalType (toolMethod ))
91+ .filter (ReflectionUtils .USER_DECLARED_METHODS ::matches )
9192 .map (toolMethod -> MethodToolCallback .builder ()
9293 .toolDefinition (ToolDefinitions .from (toolMethod ))
9394 .toolMetadata (ToolMetadata .from (toolMethod ))
Original file line number Diff line number Diff line change 1+ package org .springframework .ai .tool .method ;
2+
3+ import org .junit .jupiter .api .Test ;
4+ import org .springframework .ai .tool .ToolCallback ;
5+ import org .springframework .ai .tool .annotation .Tool ;
6+
7+ import static org .junit .jupiter .api .Assertions .*;
8+
9+ class MethodToolCallbackProviderTest {
10+
11+ abstract class TestObjectClass <T > {
12+
13+ public abstract String test (T input );
14+ }
15+
16+ class TestObjectSuperClass extends TestObjectClass <String > {
17+
18+ @ Tool
19+ public String test (String input ) {
20+ return input ;
21+ }
22+ }
23+
24+ @ Test
25+ public void buildToolsWithBridgeMethodReturnOnlyUserDeclaredMethods () {
26+ MethodToolCallbackProvider provider = MethodToolCallbackProvider .builder ().toolObjects (new TestObjectSuperClass ()).build ();
27+ ToolCallback [] toolCallbacks = provider .getToolCallbacks ();
28+ assertEquals (1 , toolCallbacks .length );
29+ assertInstanceOf (MethodToolCallback .class , toolCallbacks [0 ]);
30+ }
31+
32+ }
You can’t perform that action at this time.
0 commit comments