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
Confirmed: both
ToolSpecificationsandToolService.findToolsusegetDeclaredMethods(), which skips inherited methods. Implementing hierarchy-aware discovery and adding tests. - Assistant
Now adding tests for inherited
@Toolmethods. - Assistant
You were right — this was a bug.
@Toolmethods declared in superclasses were not being discovered.Root cause
Both
ToolSpecifications.toolSpecificationsFrom()andToolService.findTools()only scannedgetDeclaredMethods()on the concrete class, which excludes inherited methods from superclasses.Fix
-
ToolSpecifications.toolMethodsFrom()— walks the class hierarchy and collects@Toolmethods, using the most specific declaration when a method is overridden. -
ToolService.findTools()— uses the new hierarchy-aware discovery. -
DefaultToolExecutor.findMethod()— also walks superclasses so tool execution works for inherited methods. -
Javadoc in
AiServicesupdated to reflect that inherited tools are supported.
Behavior
-
Other models, same or similar prompt
Responses were produced in different, uncontrolled contexts (system prompts, settings, prior turns). This is not a benchmark.