microsoft / microsoft/semantic-kernel-java
Bug: Set ToolCallBehavior.allowAllKernelFunctions(false) doesn't work for getStreamingChatMessageContentsAsync
Nobody has claimed this yet.
- 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());
});
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();
the toolCall will always be an empty array.
Contributor guide
First steps
- Read the whole issue, then the project's contributing guide.
- Comment on the issue to say you are picking it up — it saves two people doing the same work.
- Fork the repository and make your change on a branch.
- 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