SpringAI verison 1.0.0

I encountered an issue while using Spring AI’s OpenAI chat framework to integrate with vLLM. When I use Spring AI to call vLLM, vLLM successfully returns the tool call request the first time. However, when I send a second message to vLLM, it throws an error. Here is the error message:

org.springframework.ai.retry.NonTransientAiException: 400 - {"object":"error","message":"can only concatenate str (not "dict") to str can only concatenate str (not "dict") to str","type":"BadRequestError","param":null,"code":400}

Then I captured the following packet information on the server:

Image

Comment From: ilayaperumalg

@Dudu0831 Could you provide more information on how to replicate the issue and set of configurations including where you run this (host/endpoint) and the model etc., ?

Comment From: Dudu0831

@ilayaperumalg Here is the command I use to run the server.

1927 llm serve /data/LLM/DeepSeek-R1-0528-Qwen3-8B --reasoning-parser qwen3 --max-num-seqs 4 --tool-call-parser hermes --enable-auto-tool-choice --served-model-name model --max-model-len 10000 --guided-decoding-backend xgrammar --port 6666

And below is a minimal implementation of Spring AI.

` public class ChatV2Service {

// private final ChatClient chatClient;

public Flux<String> chatStreamV2() {
    HttpClient httpClient = HttpClient.newBuilder()
            .version(HttpClient.Version.HTTP_1_1)
            .build();
    ChatClient client = ChatClient.builder(OpenAiChatModel.builder()
                    .openAiApi(OpenAiApi.builder()
                            .baseUrl("http://192.168.0.202:6666")
                            .apiKey("EMPTY")
                            .restClientBuilder(
                                    RestClient.builder()
                                            .requestFactory(new JdkClientHttpRequestFactory(httpClient))
                            )
                            .build()
                    )
                    .build())
            .build();
    Prompt build = Prompt.builder()
            .chatOptions(OpenAiChatOptions
                    .builder()
                    .model("model")
                    .toolChoice("required")
                    .build())
            .content("北京现在几点了")
            .build();


    String content = client.prompt(build)
            .tools(new DateTimeTools())
            // .stream()
            .call()
            .content();
    System.out.println(content);

    return Flux.empty();
}

} `

` public class DateTimeTools {

@Tool(description = "获取当前时间")
public String getCurrentDateTime(@ToolParam(description = "时区") String zone) {
    return LocalDateTime.now().atZone(LocaleContextHolder.getTimeZone().toZoneId()).toString();
}

@Tool(description = "为指定的时间设置用户闹钟,时间格式为 ISO-8601。")
void setAlarm(String time) {
    LocalDateTime alarmTime = LocalDateTime.parse(time, DateTimeFormatter.ISO_DATE_TIME);
    System.out.println("Alarm set for " + alarmTime);
}

} ` When the model calls a tool, a problem occurs.

Comment From: xyzwps

I got the same issue. I add a breakpoint at DefaultRestClient#576, copy the request json payload and test it in postman, it works. I think that it may be a spring ai bug.

Comment From: xyzwps

I got the same issue. I add a breakpoint at DefaultRestClient#576, copy the request json payload and test it in postman, it works. I think that it may be a spring ai bug.

It not a spring ai bug. In my case, the 400 is caused by an unexpected http upgrade. The vllm server cannot handle it correctly.

Image