Please do a quick search on GitHub issues first, there might be already a duplicate issue for the one you are about to create. If the bug is trivial, just go ahead and create the issue. Otherwise, please take a few moments and fill in the following sections:

Bug description A clear and concise description of what the bug is about.

A type conversion error occurs when the Tool parameter is an empty string, throwing java.lang.NumberFormatException.

  • The parameter type of the tool is Long.
  • The Tool parameter responded by the LLM is an empty string.
java.lang.NumberFormatException
    at java.base/java.math.BigDecimal.<init>([BigDecimal.java:692](http://bigdecimal.java:692/))
    at java.base/java.math.BigDecimal.<init>([BigDecimal.java:471](http://bigdecimal.java:471/))
    at java.base/java.math.BigDecimal.<init>([BigDecimal.java:900](http://bigdecimal.java:900/))
    at [org.springframework.ai](http://org.springframework.ai/).util.json.JsonParser.toTypedObject([JsonParser.java:139](http://jsonparser.java:139/))
    at [org.springframework.ai](http://org.springframework.ai/).tool.method.MethodToolCallback.buildTypedArgument([MethodToolCallback.java:150](http://methodtoolcallback.java:150/))
    at [org.springframework.ai](http://org.springframework.ai/).tool.method.MethodToolCallback.lambda$buildMethodArguments$1([MethodToolCallback.java:139](http://methodtoolcallback.java:139/))
    at java.base/[java.util.stream](http://java.util.stream/).ReferencePipeline$3$1.accept([ReferencePipeline.java:197](http://referencepipeline.java:197/))
    at java.base/java.util.Spliterators$ArraySpliterator.forEachRemaining([Spliterators.java:992](http://spliterators.java:992/))
    at java.base/[java.util.stream](http://java.util.stream/).AbstractPipeline.copyInto([AbstractPipeline.java:509](http://abstractpipeline.java:509/))
    at java.base/[java.util.stream](http://java.util.stream/).AbstractPipeline.wrapAndCopyInto([AbstractPipeline.java:499](http://abstractpipeline.java:499/))
    at java.base/[java.util.stream](http://java.util.stream/).AbstractPipeline.evaluate([AbstractPipeline.java:575](http://abstractpipeline.java:575/))
    at java.base/[java.util.stream](http://java.util.stream/).AbstractPipeline.evaluateToArrayNode([AbstractPipeline.java:260](http://abstractpipeline.java:260/))
    at java.base/[java.util.stream](http://java.util.stream/).ReferencePipeline.toArray([ReferencePipeline.java:616](http://referencepipeline.java:616/))
    at java.base/[java.util.stream](http://java.util.stream/).ReferencePipeline.toArray([ReferencePipeline.java:622](http://referencepipeline.java:622/))
    at [org.springframework.ai](http://org.springframework.ai/).tool.method.MethodToolCallback.buildMethodArguments([MethodToolCallback.java:140](http://methodtoolcallback.java:140/))
    at [org.springframework.ai.tool.method.MethodToolCallback.call](http://org.springframework.ai.tool.method.methodtoolcallback.call/)([MethodToolCallback.java:107](http://methodtoolcallback.java:107/))

Environment Please provide as many details as possible: Spring AI version, Java version, which vector store you use if any, etc

  • Spring AI 1.0.0

Steps to reproduce Steps to reproduce the issue.

Expected behavior A clear and concise description of what you expected to happen.

Should an empty string be converted to null? Of course, that's a matter for discussion.

Minimal Complete Reproducible example Please provide a failing test or a minimal complete verifiable example that reproduces the issue. Bug reports that are reproducible will take priority in resolution over reports that are not reproducible.

Comment From: sunyuhan1998

I believe the current issue is essentially caused by a type mismatch between the parameters provided by the model when calling the tool and the actual parameter types expected by the tool. Therefore, I suggest we directly throw a clear exception here, including in the exception message the parameter types expected by the tool, as well as the parameter types (and values) actually provided by the model.

This would also help users improve their prompts and tool descriptions.