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 and whether superclass methods are included in that scan. - Assistant
Implementing the fix:
getDeclaredMethods()only scans the concrete class, so superclass@Toolmethods are missed. Adding hierarchy-aware method discovery and tests. - Assistant
Adding tests for inherited
@Toolmethods: - Assistant
Confirmed: this was a bug. Tool discovery used
getDeclaredMethods(), which only returns methods declared on the concrete class — not inherited ones from superclasses.Root cause
Three places only scanned the concrete class:
ToolSpecifications.toolSpecificationsFrom()— tool specs sent to the LLMToolService.findTools()— tool registration for AI ServicesDefaultToolExecutor.findMethod()— runtime method lookup
Fix
Added
Utils.getAllDeclaredMethods()that walks the class hierarchy (subclass → superclass →Object), with subclass methods taking precedence when overridden.Updated all three call sites to use it.
Behavior
@Toolmethods in superclasses are now discovered and registered- If a subclass overrides a tool method without
@Tool, the inherited tool is correctly excluded - Subclass
@Toolmethods still work as before
Tests added
ToolSpecificationsTest— inherited tools + override-without-annotation case
Other models, same or similar prompt
Responses were produced in different, uncontrolled contexts (system prompts, settings, prior turns). This is not a benchmark.