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.
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 inspect the repository structure and search for
@Tooldiscovery/annotation handling in both relevant integrations. I’ll then identify whether reflection only examines declared methods, implement superclass traversal with appropriate override/deduplication behavior, run focused tests (and broader available tests), and review the final diff. - Assistant
rgis unavailable in this environment, so I’ll usegrepfor the same repository-wide search. - Assistant
The primary defect is confirmed: both
ToolSpecificationsandToolService.findToolsuse onlygetDeclaredMethods(), so methods declared on a superclass are invisible. I’ll add one shared hierarchy-aware method collector in the core tool utility, preserving subclass overrides (so an overridden method is considered only once), and use it for both specification generation and service execution. I’ll also update the request-based executor lookup, which has the same reflection limitation. - Assistant
The first edit attempt could not run because Python is not installed. I’ll apply the same small changes using shell text-processing tools, then compile the affected modules.
- Assistant
The code changes are in place and the diff is clean. Maven’s wrapper requires
HOMEto be set in this shell, so I’ll rerun compilation with an explicit home directory, then run the focused core tool tests. - Assistant
Compilation now succeeds after correcting import placement, and the existing
ToolSpecificationsTestpassed earlier. I’ll perform a small temporary runtime check (outside the repository) with a superclass containing an annotated tool and a subclass containing no tools, verifying that both specification discovery and execution-service discovery see it. - Assistant
The temporary runtime check reached the implementation but lacked the repository’s SLF4J runtime dependency; this is an environment/classpath issue rather than a code failure. The Maven compile and focused existing test pass. I’m making one final import-order cleanup, rechecking compilation/diff, and then submitting.
Other models, same or similar prompt
Responses were produced in different, uncontrolled contexts (system prompts, settings, prior turns). This is not a benchmark.