How to avoid multiple consecutive calls to the same function in ToolCallBehavior.AutoInvokeKernelFunctions? #10124
-
I'm using Semantic Kernel's ToolCallBehavior.AutoInvokeKernelFunctions to orchestrate a set of functions in my application. One of these functions is designed to perform operations on documents, such as changing their formats or processing their content. Occasionally, the orchestrator plans multiple consecutive calls to this function, each targeting a single document, instead of consolidating them into a single call for all documents. For example, if the user requests an operation on two documents, the orchestrator sometimes schedules two separate calls to the function, even though it is capable of handling both in one. I've experimented with modifying the prompts for both the orchestrator and the function's descriptions (including parameter definitions), but I haven't been able to consistently achieve the desired behavior where the requests are combined into a single invocation. Question: Any advice or recommendations would be greatly appreciated! |
Beta Was this translation helpful? Give feedback.
Replies: 4 comments 7 replies
-
tagging @SergeyMenshykh for visibility |
Beta Was this translation helpful? Give feedback.
-
Hi @LuisM000, which model do you use? |
Beta Was this translation helpful? Give feedback.
-
@LuisM000, please consider the following:
|
Beta Was this translation helpful? Give feedback.
@LuisM000, got you. You can access function calls if you enable manual function invocation. Then you will need to consolidate the functions arguments and invoke the function yourself. Additionally, you will need to remove the original function calls and add a simulated function call and return your function invocation result as part of that simulated call.
That will only work if the function calls came as part of one request/response from LLM.