spring-projects / spring-projects/spring-ai

If the parameter of the tool is empty, after the framework calls the tool, the Flux stream returns empty content

Open
#4,699 0 comments 0 reactions 0 assignees View on GitHub

Nobody has claimed this yet.

status: waiting-for-triage
Dominant language
Java
Stars
9.5k
Forks
2.9k
Avg merge
1d 7h
Merged PRs (30d)
6

Description

tools code:

public class FunctionCallTools {

    @Tool(name = "getCurrentDateTime", description = "获取当前时间")
    public static String getCurrentDateTime() {

        return String.valueOf(LocalDateTime.now().atZone(LocaleContextHolder.getTimeZone().toZoneId()));
    }
}

Controller interface code:

@RequestMapping("/tools")
public Flux<String> functionCall(@RequestParam(value = "message", defaultValue = "hello, tell me a joke") String message,
                                      HttpServletResponse response) {
        response.setCharacterEncoding("UTF-8");
        return chatClient.prompt(message)
                .tools(new FunctionCallTools())
                .stream()
                .content();
    }

After open browser,I input "http://localhost:9090/chat/tools?message=what the date is today? ",after running,the browser returned empty,why? but if I called a tool with at least one argument,the browser can return and display the result correctly.

the version of spring-ai I used is 1.0.3,only spring-ai-starter-model-openai and spring-ai-autoconfigure-mode-openai have been introduced

Contributor guide

Open the contributing guide

First steps

  1. Read the whole issue, then the project's contributing guide.
  2. Comment on the issue to say you are picking it up — it saves two people doing the same work.
  3. Fork the repository and make your change on a branch.
  4. Open a pull request that references the issue number.

Research direction

Start by reproducing the /chat/tools endpoint with the zero-argument getCurrentDateTime tool, then compare it with a tool that has an argument. Inspect the chatClient.prompt(...).tools(...).stream().content() path and the Flux handling for tool results. Done means the endpoint emits the tool result for empty-parameter tools as well as parameterized tools.

Written by the indexing model from the issue text.

Assessment

Tech stack
java
Domain
backend-api-design
Issue type
Bug
Difficulty
3/5
Estimated time
1-2 days
Activity status
Stale
Clarity
Mostly clear
Newbie friendliness
45/100

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.