Skip to content

Add append_text_to_context for TTS actions; preserve initial-node context#281

Merged
kompfner merged 3 commits into
mainfrom
pk/tts-speak-context-related-fix-and-configurability
Jun 5, 2026
Merged

Add append_text_to_context for TTS actions; preserve initial-node context#281
kompfner merged 3 commits into
mainfrom
pk/tts-speak-context-related-fix-and-configurability

Conversation

@kompfner

@kompfner kompfner commented Jun 4, 2026

Copy link
Copy Markdown
Contributor

Summary

A few related changes for how Pipecat Flows writes programmatically-generated TTS output to the LLM context.

  1. The tts_say and end_conversation actions now append their spoken text to the LLM context by default (append_text_to_context defaults to True)
  2. The initial flow node now follows its context strategy (default APPEND) instead of always replacing the context. With the default strategy, context written before the node's first inference — for example by a tts_say pre-action — is now preserved.
  3. Added an append_text_to_context option to the tts_say and end_conversation actions, controlling whether the spoken text is written to the LLM context.

Testing

uv run pytest tests/ — all green against the released pipecat-ai (1.3.0) as well as the unreleased tip of the Pipecat main branch. Also validated live against a local example exercising tts_say as pre- and post-actions and end_conversation, toggling append_text_to_context across True/False/unset and printing the resulting context.

kompfner added 3 commits June 4, 2026 17:56
The initial node always issued a context-replacing
LLMMessagesUpdateFrame regardless of context strategy, discarding
anything a pre-action (or anything else) had already written to the
context (e.g. a tts_say spoken before the node's first inference).
Make the initial node follow its context strategy like every other
node: under the default APPEND strategy it now appends, so pre-action
contributions are preserved. Set context_strategy=RESET on the
initial node for the previous clean-slate behavior.
The tts_say and end_conversation actions accept an optional
append_text_to_context (bool) controlling whether the spoken text is
recorded in the LLM context. It defaults to True; Flows passes the value
explicitly to TTSSpeakFrame so the behavior doesn't depend on the
installed Pipecat version's default (which is undergoing changes).
@kompfner kompfner force-pushed the pk/tts-speak-context-related-fix-and-configurability branch from fd42e58 to e2a9491 Compare June 5, 2026 01:01

@filipi87 filipi87 left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

LGTM!

@markbackman markbackman left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

LGTM!

@kompfner kompfner merged commit 4a12fe0 into main Jun 5, 2026
2 checks passed
@kompfner kompfner deleted the pk/tts-speak-context-related-fix-and-configurability branch June 5, 2026 14:48
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants