-
Notifications
You must be signed in to change notification settings - Fork 1.8k
Open
Description
Summary
When a TextFrame (or LLMTextFrame) with append_to_context=False passes through the TTS service, the flag is silently dropped. The resulting TTSTextFrame always has append_to_context=True, so the text still gets added to the LLM context by the assistant aggregator.
The TTSSpeakFrame path works correctly since it explicitly passes frame.append_to_context through to _push_tts_frames().
Steps to reproduce
- Create a custom
FrameProcessorpositioned between the LLM and TTS - Emit a
TextFrameorLLMTextFramewithappend_to_context = False - Observe the text still appears in the LLM assistant context
Root cause
In tts_service.py, _process_text_frame() (line 803) creates new AggregatedTextFrame objects from the incoming text but does not forward frame.append_to_context to _push_tts_frames():
async def _process_text_frame(self, frame: TextFrame):
async for aggregate in self._text_aggregator.aggregate(frame.text):
# ...
await self._push_tts_frames(
AggregatedTextFrame(aggregate.text, aggregate.type),
includes_inter_frame_spaces,
# append_tts_text_to_context is not passed, defaults to True
)By contrast, the TTSSpeakFrame path correctly propagates the flag:
await self._push_tts_frames(
AggregatedTextFrame(frame.text, AggregationType.SENTENCE),
append_tts_text_to_context=frame.append_to_context, # properly forwarded
push_assistant_aggregation=push_assistant_aggregation,
)Suggested fix
Pass frame.append_to_context through in _process_text_frame():
async def _process_text_frame(self, frame: TextFrame):
async for aggregate in self._text_aggregator.aggregate(frame.text):
includes_inter_frame_spaces = (
frame.includes_inter_frame_spaces
if aggregate.type == AggregationType.TOKEN
else False
)
if aggregate.type != AggregationType.TOKEN:
await self.stop_text_aggregation_metrics()
await self._push_tts_frames(
AggregatedTextFrame(aggregate.text, aggregate.type),
includes_inter_frame_spaces,
append_tts_text_to_context=frame.append_to_context,
)Versions
- pipecat-ai 0.0.104
Reactions are currently unavailable