diff --git a/src/pipecat/processors/aggregators/llm_response.py b/src/pipecat/processors/aggregators/llm_response.py index 81a92800a..1b53e9934 100644 --- a/src/pipecat/processors/aggregators/llm_response.py +++ b/src/pipecat/processors/aggregators/llm_response.py @@ -1024,10 +1024,8 @@ class LLMAssistantContextAggregator(LLMContextResponseAggregator): logger.debug( f"{self} FunctionCallCancelFrame: [{frame.function_name}:{frame.tool_call_id}]" ) - if frame.tool_call_id not in self._function_calls_in_progress: - return - - if self._function_calls_in_progress[frame.tool_call_id].cancel_on_interruption: + function_call = self._function_calls_in_progress.get(frame.tool_call_id) + if function_call and function_call.cancel_on_interruption: await self.handle_function_call_cancel(frame) del self._function_calls_in_progress[frame.tool_call_id] diff --git a/src/pipecat/processors/aggregators/llm_response_universal.py b/src/pipecat/processors/aggregators/llm_response_universal.py index 4b0e89008..993774dc3 100644 --- a/src/pipecat/processors/aggregators/llm_response_universal.py +++ b/src/pipecat/processors/aggregators/llm_response_universal.py @@ -890,10 +890,8 @@ class LLMAssistantAggregator(LLMContextAggregator): logger.debug( f"{self} FunctionCallCancelFrame: [{frame.function_name}:{frame.tool_call_id}]" ) - if frame.tool_call_id not in self._function_calls_in_progress: - return - - if self._function_calls_in_progress[frame.tool_call_id].cancel_on_interruption: + function_call = self._function_calls_in_progress.get(frame.tool_call_id) + if function_call and function_call.cancel_on_interruption: # Update context with the function call cancellation self._update_function_call_result(frame.function_name, frame.tool_call_id, "CANCELLED") del self._function_calls_in_progress[frame.tool_call_id]