Skip to content

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

@zzzhy

Description

@zzzhy

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"}}"

Metadata

Metadata

Assignees

No one assigned

    Labels

    bugSomething isn't workingtriageNeeds triage from engineering team

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions