microsoft / microsoft/semantic-kernel-java

Bug: SK runs his self-made function by ignoring the auto-invoke function config

Open
#281 8 comments 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 set the toolcallbehavior of allowOnlyKernelFunctions as true, and passed the functions to the kernel
but the kernel make a functiontoolcall by himself and just invoke it.

To Reproduce
Steps to reproduce the behavior:

         List<KernelFunction<?>> functions = kernel.getPlugins().stream()
                .map(KernelPlugin::getFunctions)
                .map(Map::values)
                .flatMap(Collection::stream)
                .toList();
        FunctionResult<String> preResult = kernel
                .invokeAsync(function)
                .withToolCallBehavior(ToolCallBehavior.allowOnlyKernelFunctions(true, functions))
                .withArguments(
                        KernelFunctionArguments.builder()
                                .withInput(userInput)
                                .withVariable("metadata", metadata)
                                .build())
                .withResultType(ContextVariableTypes.getGlobalVariableTypeForClass(String.class))
                .block();    // occur exception here, for invoke a self-make function

Expected behavior
Only invoke the passed functions.

Screenshots
Image

Maven

  • Version: 3.3.9
  • Dependencies: 1.4.3

Platform

  • IDE: IDEA
  • JDK version: 17

Additional context
Excption: com.azure.core.exception.HttpResponseException: Status code 400, "{"error":{"message":"Invalid 'messages[1].tool_calls[1].function.name': string does not match pattern. Expected a string that matches the pattern '^[a-zA-Z0-9_-]+$'.","type":"invalid_request_error","code":"invalid_value","param":"messages[1].tool_calls[1].function.name"}}"

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 Java example around kernel.invokeAsync(function) and ToolCallBehavior.allowOnlyKernelFunctions(true, functions) with the reported versions. Inspect how the passed functions are handled before the tool call is sent; done means only the supplied kernel functions are invoked and the reported invalid function-name request is no longer produced.

Written by the indexing model from the issue text.

Assessment

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

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.