Skip to content
TheChatArchiveThe Chat Archive
fable-5· unknownHugging Face ibragim-bad/swe_rebench_07_2026_trajectories

Untitled conversation

  1. User

    [BUG] @Tool methods not inherited from superclas @Tool methods 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.

  2. Assistant

    Now let me check for any other places scanning @Tool methods:

  3. Assistant

    Now update the three scanning sites. First ToolSpecifications:

  4. Assistant

    Now ToolService.findTools:

  5. Assistant

    Now let's check that invoking inherited (possibly non-public) methods works — check how DefaultToolExecutor invokes:

  6. Assistant

    Invocation already handles accessibility. Now add tests. Let me look at existing tests:

  7. Assistant

    Now add tests. First to ToolSpecificationsTest:

  8. Assistant

    Now add a test for getAllDeclaredMethods in UtilsTest:

  9. Assistant

    Now add a findTools inheritance test to ToolServiceTest:

  10. Assistant

    Now build and run the tests. First core module:

  11. Assistant

    Core tests pass. Now install core locally and run the langchain4j module tests:

  12. Assistant

    Now run the broader set of tool-related tests to check for regressions:

  13. Assistant

    All Tool-related tests pass (my awk summary was just malformed — every report shows Failures: 0, Errors: 0). Let me run the full test suites of both affected modules to be thorough:

  14. Assistant

    The single failure is UrlDocumentLoaderTest.should_load_text_document — a network timeout fetching an external URL, unrelated to this change (this sandbox has restricted internet access). All other 1384 tests in the langchain4j module and all 1090 in langchain4j-core pass.

    Summary

    @Tool methods declared in a superclass were invisible because tool scanning used Class.getDeclaredMethods(), which only returns methods declared directly on the concrete class.

    Fix — added Utils.getAllDeclaredMethods(Class<?>) in langchain4j-core (Utils.java:555), which walks the class hierarchy up to (excluding) Object, collects declared methods including non-public ones, dedupes overridden methods by signature keeping the most specific declaration, and skips synthetic/bridge methods. Then switched all three tool-scanning sites to it:

    1. ToolSpecifications.toolSpecificationsFrom(Class) — langchain4j-core/.../agent/tool/ToolSpecifications.java:64
    2. ToolService.findTools(Object) — langchain4j/.../service/tool/ToolService.java:230 (the path used by AI Services' .tools(...))
    3. DefaultToolExecutor.findMethod(...) — langchain4j/.../service/tool/DefaultToolExecutor.java:72 (so execution also resolves inherited methods)

    Invocation of inherited non-public methods already works via the existing setAccessible(true) fallback in DefaultToolExecutor.

    Tests added:

    • UtilsTest — getAllDeclaredMethods includes inherited/protected methods, returns overridden methods once using the subclass declaration
    • ToolSpecificationsTest — specs include inherited, overridden, and declared @Tool methods
    • ToolServiceTest — findTools discovers inherited tools and executes them correctly (overridden tool dispatches to the subclass implementation)

Responses were produced in different, uncontrolled contexts (system prompts, settings, prior turns). This is not a benchmark.