fix(llm): add generic opt-in tool-call text policy for all text LLM providers - #5369
Draft
martinstiago wants to merge 2 commits into
Draft
fix(llm): add generic opt-in tool-call text policy for all text LLM providers#5369martinstiago wants to merge 2 commits into
martinstiago wants to merge 2 commits into
Conversation
martinstiago
force-pushed
the
fix/openai-post-tool-call-text-policy
branch
from
August 21, 2026 21:49
4acb9a6 to
0337769
Compare
Codecov Report✅ All modified and coverable lines are covered by tests.
... and 2 files with indirect coverage changes 🚀 New features to boost your workflow:
|
…_CALL_DETECTED Renames the enum member and value per review feedback for clarity.
Contributor
Author
|
Renamed the enum member and value to |
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
ToolCallTextPolicysetting (PRESERVE/SUPPRESS_AFTER_TOOL_CALL_DETECTED) that suppresses streamed text after a tool call is detected in the same response.LLMSettings, so every LLM service accepts it uniformly and it's runtime-updatable viaLLMUpdateSettingsFrame.LLMService._push_llm_text: the base class owns a_tool_call_detectedflag (reset per response viaLLMFullResponseStartFrameinpush_frame) and drops text when the policy isSUPPRESS_AFTER_TOOL_CALL_DETECTED. Providers call_note_tool_call_detected()at their tool-call detection site — one line per streaming loop.BaseOpenAILLMService), OpenAI Responses (WebSocket + HTTP), Anthropic, Google (Gemini + Vertex), and AWS Bedrock Converse. Realtime speech-to-speech services settool_call_text_policy=None(unsupported — they don't stream TTS-bound text).PRESERVEeverywhere — non-breaking; no behavior changes unless users explicitly opt in.Testing
uv run pytest tests/test_llm_service_tool_call_text.py tests/test_openai_tool_call_text.py tests/test_bedrock_tool_call_text.py tests/test_anthropic_tool_call_text.py tests/test_google_tool_call_text.py tests/test_openai_responses_tool_call_text.pyuv run ruff check src/pipecat/services/ tests/test_*tool_call_text.pySUPPRESS_AFTER_TOOL_CALL_DETECTED; suppression state resets between responses.Documentation