ISSUE DESCRIPTION [BUG] @Tool methods not inherited from superclas @Tool methods not…
- User
ISSUE DESCRIPTION
[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.
ADDITIONAL ADVICE
Since you are given a git repository, you can use git commands to simplify your work. For example, if you made a mistake and want to revert your changes, you can use
git checkout <file>to restore the file to its original state. You can also reset all changes in the repository usinggit reset --hardcommand. Additionally, you can usegit stashandgit stash popto temporarily save your changes and restore them later. Finally, you can see the changes that you've made (which will be submitted when you callsubmit) usinggit statusorgit diffcommands. However you don't need to usegit addorgit commitbefore submitting your changes. In fact,submitonly submits currently unstaged changes because it usesgit diffto get the changes that need to be submitted.CHECKLIST
Before submitting your solution, please go over the following checklist and make sure you've done everything:
- If an error was reported in the issue description, I have successfully reproduced it.
- If an error was reported in the issue description, I have confirmed that my fix resolves the error.
- I have thought about edge cases and made sure my fix handles them as well.
- I have run existing tests in the repository that might have been affected by the change I made and confirmed that they pass. I want you to list every bullet from this checklist and write your reasoning for why you think you did it or didn't need to.
Repository has been uploaded and your shell is currently at the repository root. Time to solve the issue!
(Current directory: /langchain4j, current file: none) bash-$
- Assistant
I'll start by exploring the repository structure and locating how
@Toolmethods are discovered so we can fix inheritance. - Assistant
I'll search more specifically for where
@Toolmethods are scanned and converted into tool specifications. - Assistant
Found the core tool files. Next I'll inspect how methods are scanned and how tools are registered.
- Assistant
The bug is that both places use
getDeclaredMethods(), which skips inherited methods. I'll read those files and their tests next. - Assistant
I'll inspect related utilities and existing tests for tool discovery next.
- Assistant
Let me look at getAnnotatedMethod and also DeadlineToolExecutor's method lookup. Also check if there's existing PR or git history about this. And look at how annotations work with inheritance - @Tool ...
- Assistant
I'll check other call sites and whether interface default methods need similar handling.
- Assistant
I'll inspect class-metadata handling and any existing helpers for walking the method hierarchy.
- Assistant
I'll look for a good place for a shared helper, then implement hierarchy-aware method discovery.
- Assistant
I'll add a hierarchy-aware helper in
Utilsand updateToolSpecificationsandToolServiceto use it. - Assistant
I'll insert the helper after
getAnnotatedMethodand update the call sites. - Assistant
I'll remove the duplicate return and clean up the imports.
- Assistant
There's still a stray brace — I'll remove it.
- Assistant
I'll clean up formatting and add the
LinkedHashMapimport. - Assistant
I'll verify imports, then update
ToolSpecificationsresidual andToolService. - Assistant
LinkedHashMap import is missing. Let me add it.
- Assistant
Updating
ToolSpecificationsandToolServicenext. - Assistant
Update toolSpecificationsFrom method and clean unused imports stream if no longer needed.
- Assistant
Updating the object-version javadoc and ToolService next.
- Assistant
Fixing the broken javadoc and updating ToolService.
- Assistant
I'll open each file and apply the edits carefully.
- Assistant
Fix the broken javadoc with edit
- Assistant
I lost the "within the class..." line. Let me fix the full javadoc properly.
- Assistant
Good. Now ToolService.
- Assistant
Need to check if getAnnotatedMethod and Optional are used elsewhere in ToolService.
- Assistant
Optional is still used for type checks. Replace import and findTools.
- Assistant
I'll also make
DefaultToolExecutor.findMethodhierarchy-aware, then compile and verify with a reproduction script. - Assistant
I'll update findMethod to walk hierarchy - simple fix.
- Assistant
Compiling the affected modules and running a quick reproduction next.
- Assistant
HOME not set - need to set it.
- Assistant
Need failIfNoSpecifiedTests
- Assistant
Hmm - ToolSpecificationsTest and UtilsTest didn't run in the output for core. Let me check if core tests ran.
- Assistant
Existing tests pass. I'll add a temporary reproduction script to confirm inheritance works end-to-end.
- Assistant
Reproduction passed. Verifying the final diff and cleaning up.
Other models, same or similar prompt
Responses were produced in different, uncontrolled contexts (system prompts, settings, prior turns). This is not a benchmark.