Untitled conversation
- User
[BUG] @Tool methods not inherited from superclas
@Toolmethods not inherited from superclass. I think this is a bug as this is something that should work.I didn't 100% verify this, but my inherited tools weren't being called and the LLM was stating that it didn't know what tool to call. Once I put the tool methods back in the concrete class, things worked, so I'm assuming that this bug report is true.
This should be done in LC4J too if it already doesn't work there.
Interface
No new interfaces are introduced.
- Assistant
I'll investigate how
@Toolmethods are discovered in the codebase and whether superclass methods are included. - Assistant
Both
ToolSpecificationsandToolService.findToolsonly scangetDeclaredMethods(), so superclass@Toolmethods are missed. I'll add hierarchy traversal and tests. - Assistant
Adding tests for inherited
@Tooldiscovery: - Assistant
Filtering synthetic/bridge methods from hierarchy traversal — JaCoCo injects synthetic methods that were breaking the test.
- Assistant
Confirmed — this was a bug.
@Tooldiscovery only usedgetDeclaredMethods(), so methods on superclasses were never registered.Root cause
Three places only inspected the concrete class:
ToolSpecifications.toolSpecificationsFrom()— builds tool specs for the LLMToolService.findTools()— registers tools with AI ServicesDefaultToolExecutor.findMethod()— resolves methods at execution time
Fix
Added
Utils.declaredMethodsInHierarchy()to walk the class hierarchy (subclass → superclass), with subclass methods winning on signature conflicts. Synthetic/bridge methods are filtered out.Updated all three call sites to use it.
Tests added
ToolSpecificationsTest.tool_specifications_from_inherited_methodsUtilsTest.should_return_declared_methods_from_class_hierarchyToolServiceFindToolsTest.should_find_tools_declared_in_superclass(includes execution)
You can now define methods in a base class and use them from subclasses without re-declaring:
Other models, same or similar prompt
Responses were produced in different, uncontrolled contexts (system prompts, settings, prior turns). This is not a benchmark.