microsoft / microsoft/semantic-kernel-java

Bug: Set ToolCallBehavior.allowAllKernelFunctions(false) doesn't work for getStreamingChatMessageContentsAsync

Open
#279 1 comment 0 reactions 0 assignees View on GitHub

Nobody has claimed this yet.

bug triage
Dominant language
Java
Stars
276
Forks
56
Avg merge
17h 45m
Merged PRs (30d)
4

Description

Describe the bug
I try to invoke toolcall myself in a streaming chat.
I have learned that how to invoke a toolcall in an non-streaming chat. like

        Kernel kernel = Kernel.builder().withAIService(ChatCompletionService.class, chatCompletionService)
                .withPlugin(KernelPluginFactory.createFromObject(this, "time"))
                .build();

        chatCompletionService
                .getChatMessageContentsAsync("what time is it now?", kernel, InvocationContext.builder()
                        .withToolCallBehavior(ToolCallBehavior.allowAllKernelFunctions(false))
                        .build())
                .block()
                .stream().filter(it->it instanceof OpenAIChatMessageContent<?>)
                .map(it->((OpenAIChatMessageContent)it))
                .forEach(it->{
                    System.out.println(it.getToolCall().size());
                });

Image

As you can see, I can get the toolCall value;

but when I change to an streaming chat, like

        Kernel kernel = Kernel.builder().withAIService(ChatCompletionService.class, chatCompletionService)
                .withPlugin(KernelPluginFactory.createFromObject(this, "time"))
                .build();

        chatCompletionService
                .getStreamingChatMessageContentsAsync("what time is it now?", kernel, InvocationContext.builder()
                        .withToolCallBehavior(ToolCallBehavior.allowAllKernelFunctions(false))
                        .build())
                .filter(it->it instanceof OpenAIStreamingChatMessageContent<?>)
                .map(it->(OpenAIStreamingChatMessageContent)it)
                .doOnNext(it->{
                    System.out.println(it.getToolCall().size());
                }).subscribe();

Image
the toolCall will always be an empty array.

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 with getStreamingChatMessageContentsAsync and compare its behavior with getChatMessageContentsAsync, using the ToolCallBehavior.allowAllKernelFunctions(false) examples in the issue. Trace how OpenAIStreamingChatMessageContent exposes tool calls; done means streaming results contain the expected tool-call data instead of an empty array, with coverage for this reproduction.

Written by the indexing model from the issue text.

Assessment

Tech stack
java
Domain
api
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.