diff --git a/CHANGELOG.md b/CHANGELOG.md index c131b1c82..9ffb9f36e 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -13,6 +13,13 @@ and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0 the case where the user has hung up before the `TwilioFrameSerializer` hangs up the call. +### Changed + +- The `UserIdleProcessor` now handles the scenario where function calls take + longer than the idle timeout duration. This allows you to use the + `UserIdleProcessor` in conjunction with function calls that take a while to + return a result. + ### Performance - Remove unncessary push task in each `FrameProcessor`. diff --git a/src/pipecat/processors/user_idle_processor.py b/src/pipecat/processors/user_idle_processor.py index e98320b8b..5f6b25b95 100644 --- a/src/pipecat/processors/user_idle_processor.py +++ b/src/pipecat/processors/user_idle_processor.py @@ -15,6 +15,8 @@ from pipecat.frames.frames import ( CancelFrame, EndFrame, Frame, + FunctionCallInProgressFrame, + FunctionCallResultFrame, StartFrame, UserStartedSpeakingFrame, UserStoppedSpeakingFrame, @@ -168,6 +170,13 @@ class UserIdleProcessor(FrameProcessor): self._idle_event.set() elif isinstance(frame, BotSpeakingFrame): self._idle_event.set() + elif isinstance(frame, FunctionCallInProgressFrame): + # Function calls can take longer than the timeout, so we want to prevent idle callbacks + self._interrupted = True + self._idle_event.set() + elif isinstance(frame, FunctionCallResultFrame): + self._interrupted = False + self._idle_event.set() async def cleanup(self) -> None: """Cleans up resources when processor is shutting down."""