From 7807e36b404a7ba44ef0b01765f07775f6fae61c Mon Sep 17 00:00:00 2001 From: Ishaan Jaffer Date: Thu, 26 Feb 2026 01:09:53 -0800 Subject: [PATCH] fix(realtime): instruct LLM to say exact guardrail message verbatim The previous prompt gave the LLM creative freedom to paraphrase the guardrail violation message. Now it instructs the LLM to repeat the exact configured message word for word. Made-with: Cursor --- litellm/litellm_core_utils/realtime_streaming.py | 10 ++++------ 1 file changed, 4 insertions(+), 6 deletions(-) diff --git a/litellm/litellm_core_utils/realtime_streaming.py b/litellm/litellm_core_utils/realtime_streaming.py index 588920d6d1e..0b94ed3b2c5 100644 --- a/litellm/litellm_core_utils/realtime_streaming.py +++ b/litellm/litellm_core_utils/realtime_streaming.py @@ -363,13 +363,11 @@ class RealTimeStreaming: }, }) ) - # Ask the LLM to voice the guardrail message so the user - # hears it as audio in voice sessions (not just text). + # Ask the LLM to voice the exact guardrail message so the + # user hears it as audio in voice sessions (not just text). guardrail_prompt = ( - f"The user's last message was blocked by a content guardrail " - f"before it reached you. Briefly inform the user in a helpful " - f"and empathetic tone: {error_msg}. " - f"Do not repeat the blocked content." + f"Say exactly the following message to the user, word for word, " + f"do not add anything else: {error_msg}" ) await self._send_to_backend(json.dumps({ "type": "conversation.item.create",