From 991c8a02e76791461f14930c2f8e606d15610033 Mon Sep 17 00:00:00 2001 From: Xin Wang Date: Fri, 29 May 2026 16:44:01 +0800 Subject: [PATCH] Update idle count will reset when user active again --- engine/pipeline.py | 7 +++++++ 1 file changed, 7 insertions(+) diff --git a/engine/pipeline.py b/engine/pipeline.py index cb178a8..f0af44c 100644 --- a/engine/pipeline.py +++ b/engine/pipeline.py @@ -10,6 +10,7 @@ from pipecat.frames.frames import ( LLMRunFrame, OutputTransportMessageUrgentFrame, TTSSpeakFrame, + UserStartedSpeakingFrame, ) from pipecat.pipeline.pipeline import Pipeline from pipecat.pipeline.runner import PipelineRunner @@ -189,6 +190,7 @@ async def run_pipeline_with_serializer( ), idle_timeout_secs=config.session.inactivity_timeout_sec, ) + task.set_reached_upstream_filter((UserStartedSpeakingFrame,)) idle_prompt_count = 0 @transport.event_handler("on_client_connected") @@ -218,6 +220,11 @@ async def run_pipeline_with_serializer( logger.info(f"{client_label} websocket session timed out") await task.cancel() + @task.event_handler("on_frame_reached_upstream") + async def on_frame_reached_upstream(_task, _frame: UserStartedSpeakingFrame): + nonlocal idle_prompt_count + idle_prompt_count = 0 + @user_aggregator.event_handler("on_user_turn_started") async def on_user_turn_started(_aggregator, _strategy): nonlocal idle_prompt_count