Skip to content

[Core] Tools as methods only work if they are public #2041

@ThomasVitale

Description

@ThomasVitale

Bug description
When defining tools from Java methods, the callback logic fails if the method is not public or if it's located in a non-public class.

Environment
Spring AI: 1.0.0-SNAPSHOT
Java: 23

Expected behavior
Even if the class/method is not public, I'd expect the tool callback logic to work. It's good practice not to define tool methods as public, and make sure they are only used as part of an LLM workflow.

I have a solution suggestion. See MethodToolCallback.java. A working example is available here.

Minimal Complete Reproducible example
Example reproducing the issue is available here (check the /chat/method/non-public endpoint).

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions