Skip to content

Error "toolInput cannot be null or empty" when calling in stream mode #3280

@MikDanila

Description

@MikDanila

Bug description
Getting error "toolInput cannot be null or empty" while calling .stream() in chatClient

java.lang.IllegalArgumentException: toolInput cannot be null or empty
	at org.springframework.util.Assert.hasText(Assert.java:253) ~[spring-core-6.2.6.jar:6.2.6]
	at org.springframework.ai.tool.method.MethodToolCallback.call(MethodToolCallback.java:99) ~[spring-ai-model-1.0.0.jar:1.0.0]
	at org.springframework.ai.model.tool.DefaultToolCallingManager.lambda$executeToolCall$5(DefaultToolCallingManager.java:224) ~[spring-ai-model-1.0.0.jar:1.0.0]
	at io.micrometer.observation.Observation.observe(Observation.java:564) ~[micrometer-observation-1.14.6.jar:1.14.6]
	at org.springframework.ai.model.tool.DefaultToolCallingManager.executeToolCall(DefaultToolCallingManager.java:221) ~[spring-ai-model-1.0.0.jar:1.0.0]
	at org.springframework.ai.model.tool.DefaultToolCallingManager.executeToolCalls(DefaultToolCallingManager.java:137) ~[spring-ai-model-1.0.0.jar:1.0.0]
	at org.springframework.ai.openai.OpenAiChatModel.lambda$internalStream$10(OpenAiChatModel.java:369) ~[spring-ai-openai-1.0.0.jar:1.0.0]
	at reactor.core.publisher.FluxDefer.subscribe(FluxDefer.java:46) ~[reactor-core-3.7.5.jar:3.7.5]
	at reactor.core.publisher.FluxSubscribeOn$SubscribeOnSubscriber.run(FluxSubscribeOn.java:194) ~[reactor-core-3.7.5.jar:3.7.5]
	at reactor.core.scheduler.WorkerTask.call(WorkerTask.java:84) ~[reactor-core-3.7.5.jar:3.7.5]
	at reactor.core.scheduler.WorkerTask.call(WorkerTask.java:37) ~[reactor-core-3.7.5.jar:3.7.5]
	at java.base/java.util.concurrent.FutureTask.run(FutureTask.java:317) ~[na:na]
	at java.base/java.util.concurrent.ScheduledThreadPoolExecutor$ScheduledFutureTask.run(ScheduledThreadPoolExecutor.java:304) ~[na:na]
	at java.base/java.util.concurrent.ThreadPoolExecutor.runWorker(ThreadPoolExecutor.java:1144) ~[na:na]
	at java.base/java.util.concurrent.ThreadPoolExecutor$Worker.run(ThreadPoolExecutor.java:642) ~[na:na]
	at java.base/java.lang.Thread.run(Thread.java:1583) ~[na:na]

Environment
Spring AI 1.0.0, Java version temurin-21.0.1, Vllm

Expected behavior
There are no error when invoke .call() method, but have error when invoke .stream()

Minimal Complete Reproducible example
Run Vllm:

docker run --runtime nvidia --gpus all --name Qwen3-8B-AWQ -p 8000:8000 --ipc=host vllm/vllm-openai:latest --model Qwen/Qwen3-8B-AWQ --gpu-memory-utilization 0.75 --max-model-len 8192 --enforce-eager --enable-auto-tool-choice --tool-call-parser hermes

application.properties

spring.ai.openai.base-url=http://localhost:8000
spring.ai.openai.chat.options.model=Qwen/Qwen3-8B-AWQ
spring.ai.openai.api-key=KEY

Create Simple Date Time calling tool

@Component
public class DateTimeTools {
  private static final Logger log = LoggerFactory.getLogger(DateTimeTools.class);

  @Tool(description = "Get date and time user")
  public String getCurrentDateTime() {
    log.info("Called tool getCurrentDateTime()");
    return LocalDateTime.now().toString();
  }
}

Create Simple controller:

@RestController
public class ChatApiController {
  private final ChatClient chatClient;

  public ChatApiController(ChatClient.Builder chatClientBuilder, DateTimeTools dateTimeTools) {
    this.chatClient = chatClientBuilder
        .defaultTools(dateTimeTools)
        .build();
  }

  @PostMapping("/api/stream/v1")
  public Flux<String> sendStreamMessage(@RequestBody MessageRequest message) {
    String userInput = message.message();

    return this.chatClient.prompt()
        .user(userInput)
        .stream()
        .content();
  }
}

Steps to reproduce
Call method:
POST http://localhost:8080/api/stream/v1
Content-Type: application/json

{
"message": "Give me current date"
}

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