Add append_text_to_context for TTS actions; preserve initial-node context#281
Merged
kompfner merged 3 commits intoJun 5, 2026
Merged
Conversation
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).
fd42e58 to
e2a9491
Compare
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Summary
A few related changes for how Pipecat Flows writes programmatically-generated TTS output to the LLM context.
tts_sayandend_conversationactions now append their spoken text to the LLM context by default (append_text_to_contextdefaults toTrue)APPEND) instead of always replacing the context. With the default strategy, context written before the node's first inference — for example by atts_saypre-action — is now preserved.append_text_to_contextoption to thetts_sayandend_conversationactions, controlling whether the spoken text is written to the LLM context.Testing
uv run pytest tests/— all green against the releasedpipecat-ai(1.3.0) as well as the unreleased tip of the Pipecatmainbranch. Also validated live against a local example exercisingtts_sayas pre- and post-actions andend_conversation, togglingappend_text_to_contextacrossTrue/False/unset and printing the resulting context.