pipecat icon indicating copy to clipboard operation
pipecat copied to clipboard

fix: preserve skip_tts flag when frames pass through LLM services (simple fix)

Open jamsea opened this issue 1 month ago • 1 comments

Problem

When sending an LLMTextFrame with skip_tts=True through an LLMSwitcher (or any LLM service), the frame exits with skip_tts=False. This happens because the LLMService.push_frame() override unconditionally sets frame.skip_tts = self._skip_tts, overwriting any value already set on the frame.

This bug was introduced in commit 16f57be72cec9f718ab1d42df258baac82b39f96.

Solution

This PR implements a simple, minimal fix: only set skip_tts=True when self._skip_tts is True, rather than unconditionally overwriting the value:

if isinstance(frame, (LLMTextFrame, LLMFullResponseStartFrame, LLMFullResponseEndFrame)):
    if self._skip_tts:
        frame.skip_tts = True

How it works

Frame's skip_tts Service's _skip_tts Result
False (default) False (default) False (unchanged)
False (default) True True (set by service)
True (explicit) False (default) True (preserved) ✅
True (explicit) True True (unchanged)

Trade-offs

This fix still modifies frames after creation, which isn't ideal for Pipecat's architecture. However, it's a minimal change that fixes the bug without requiring updates to all LLM service implementations.

Alternative: Architectural Fix

For a more architecturally pure solution that sets skip_tts at frame creation time (no frame mutation), see #3160. That approach:

  • Makes skip_tts an init parameter on frames
  • Updates all LLM services to pass skip_tts=self._get_skip_tts() when creating frames
  • Removes the push_frame() override entirely

Choose this PR for a quick fix, or #3160 for a cleaner long-term solution.

jamsea avatar Nov 28 '25 12:11 jamsea

Codecov Report

:x: Patch coverage is 0% with 2 lines in your changes missing coverage. Please review.

Files with missing lines Patch % Lines
src/pipecat/services/llm_service.py 0.00% 2 Missing :warning:
Files with missing lines Coverage Δ
src/pipecat/services/llm_service.py 38.88% <0.00%> (-0.20%) :arrow_down:
:rocket: New features to boost your workflow:
  • :snowflake: Test Analytics: Detect flaky tests, report on failures, and find test suite problems.

codecov[bot] avatar Nov 28 '25 12:11 codecov[bot]

Closing. This was merged in #3168

aconchillo avatar Dec 05 '25 17:12 aconchillo