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
Now update the three call sites:
- Assistant
Good. Now
ToolService.findTools: - Assistant
Now
DefaultToolExecutor.findMethod: - Assistant
Invocation already calls
setAccessible(true), so protected superclass methods will work. Now add tests: - Assistant
Also add a unit test for the new
Utils.getAllDeclaredMethodshelper: - Assistant
Now compile and run the tests:
- Assistant
The
langchain4jmodule resolves core from the local repo — I need to install the updated core first: - Assistant
All targeted tests pass. Let me run the broader unit test suites of both modules to check for regressions:
- Assistant
Confirmed unrelated —
ConnectException: Connection timed outfetching fromraw.githubusercontent.com(no internet access in this environment). All 1384 other tests pass.Let me verify formatting complies with the project's spotless config:
- Assistant
All tests pass. Final review of the change set:
- Assistant
Fixed.
@Toolmethods are now inherited from superclasses.Root cause
Tool scanning used
Class.getDeclaredMethods(), which only returns methods declared directly on the concrete class — any@Toolmethods inherited from a superclass were silently ignored, so they were never registered as tool specifications and the LLM never saw them.Changes
New helper —
Utils.getAllDeclaredMethods(Class<?>)in :
Other models, same or similar prompt
Responses were produced in different, uncontrolled contexts (system prompts, settings, prior turns). This is not a benchmark.