AutoFunctionInvocationFilter - terminating function execution #9629
-
Is it possible to terminate function calling once an error is encountered with executing one of the actions specified in a user request? Example:
Here we can call context.Terminate( ) to stop further function execution but this seems to cause issues with chat-history because Assistant message had three tool calls but only one tool message. Terminating function calling is important because the three actions might have to be executed in that sequence and if Action 2 could not be completed then Action 3 should not be executed. Additionally we want to keep the same chat history. Here's the error on issuing a new request after calling context.Terminate( ): An assistant message with 'tool_calls' must be followed by tool messages responding to each 'tool_call_id'. The following tool_call_ids did not have response messages: call_3Zh 26yyqUsynQlYFBziYOYLH, call_Gm 4W 0oRWSiPo 9qdutYzt 6F 65 |
Beta Was this translation helpful? Give feedback.
Replies: 1 comment 1 reply
-
Hi @deepinderdeol , thanks for your question!
Yes, if you terminate function execution, but you still want to use the same chat history for further requests, you have to manually update chat history with some response for specific semantic-kernel/dotnet/samples/Concepts/FunctionCalling/FunctionCalling.cs Lines 262 to 266 in 7d9f834 The other option would be to use semantic-kernel/dotnet/samples/Concepts/FunctionCalling/FunctionCalling.cs Lines 100 to 112 in 7d9f834 I hope this helps. Thank you! |
Beta Was this translation helpful? Give feedback.
Hi @deepinderdeol , thanks for your question!
Yes, if you terminate function execution, but you still want to use the same chat history for further requests, you have to manually update chat history with some response for specific
tool_call_id
, like in this example:semantic-kernel/dotnet/samples/Concepts/FunctionCalling/FunctionCalling.cs
Lines 262 to 266 in 7d9f834