spring-ai icon indicating copy to clipboard operation
spring-ai copied to clipboard

@ToolParam description not applied to nested data class parameters

Open mautini opened this issue 6 months ago • 0 comments
trafficstars

When defining a tool that takes an object (in my case, defined by a data class) as a parameter, the @ToolParam description is not included in the resulting JSON schema.

For example, consider the following tool:

@Tool(description = "Get the weather at a specific address", returnDirect = true)
private fun getWeather(address: Address) {
    ...
}

data class Address(
    @ToolParam(description = "The street (without number) of the address")
    val street: String,
    val postalCode: String,
    val city: String,
)

In the resulting JSON schema, the description for the street attribute is missing.

The documentation states that the @ToolParam annotation supports nested types, but it does not provide an example.

Would it be possible to recursively include the description (and required flag) for tools arguments that are objects?

mautini avatar Apr 23 '25 23:04 mautini