From 56f2564ed10da68d96675e7a482a0f8f29e26561 Mon Sep 17 00:00:00 2001 From: Rupesh Date: Fri, 27 Feb 2026 14:45:37 -0800 Subject: [PATCH] Use local variable instead of instance variable for RTVI prepend decision Replace _rtvi_external instance variable with a local prepend_rtvi flag since it is only used during __init__ to decide whether to prepend the RTVIProcessor to the pipeline. --- src/pipecat/pipeline/task.py | 9 +++------ 1 file changed, 3 insertions(+), 6 deletions(-) diff --git a/src/pipecat/pipeline/task.py b/src/pipecat/pipeline/task.py index 1db23e7d4..eeb39c9b6 100644 --- a/src/pipecat/pipeline/task.py +++ b/src/pipecat/pipeline/task.py @@ -330,7 +330,7 @@ class PipelineTask(BasePipelineTask): # RTVI support self._rtvi = None - self._rtvi_external = False + prepend_rtvi = False external_rtvi = self._find_processor(pipeline, RTVIProcessor) external_observer_found = any(isinstance(o, RTVIObserver) for o in observers) @@ -350,10 +350,10 @@ class PipelineTask(BasePipelineTask): "They are both added by default, no need to add them yourself." ) self._rtvi = external_rtvi - self._rtvi_external = True elif enable_rtvi: self._rtvi = rtvi_processor or RTVIProcessor() observers.append(self._rtvi.create_rtvi_observer(params=rtvi_observer_params)) + prepend_rtvi = True if self._rtvi: # Automatically call RTVIProcessor.set_bot_ready() @@ -393,10 +393,7 @@ class PipelineTask(BasePipelineTask): # Only prepend the RTVIProcessor if we created it ourselves. When the # user already placed it inside their pipeline we must not insert it # again or it will appear twice in the frame chain. - if self._rtvi and not self._rtvi_external: - processors = [self._rtvi, pipeline] - else: - processors = [pipeline] + processors = [self._rtvi, pipeline] if prepend_rtvi else [pipeline] self._pipeline = Pipeline(processors, source=source, sink=sink) # The task observer acts as a proxy to the provided observers. This way,