little-kite-91953
12/05/2025, 10:24 PMtall-airline-16756
12/05/2025, 10:25 PMtall-airline-16756
12/05/2025, 10:25 PMinstructions parameter) or updated via explicit API calls such as update_instructions(). Sending a message labeled “system” in the chat stream does not automatically change the agent’s internal system prompt or behavior.
If your goal is to change the agent’s role/behavior at runtime, you can:
• Initialize the agent with the desired system instructions (so they are applied from the start), or
• Use the API method to update instructions during the session (update_instructions() or equivalent in your SDK) so the agent recognizes the new system-level instruction.
If you’d like, tell me how you’re sending the message (which SDK or topic you’re using and a short example of the payload), and I’ll suggest the precise call or pattern to make it act as a true system instruction.
Sources: Prompting guide | LiveKit docs | Events and error handling | LiveKit docs | Agents v0.x migration guide - Python | LiveKit docs | Agents v0.x migration guide - Node.js | LiveKit Docs | Agents (Python) | livekit/livekit_composite | DeepWikilittle-kite-91953
12/05/2025, 10:30 PMtall-airline-16756
12/05/2025, 10:31 PMself._chat_ctx copy does not deliver the message to the model.
• Calling update_chat_ctx() sends the context to the model — but calling it alone doesn't have to force an immediate reply. Generating a reply is a separate action.
Fix: always sync context, but only trigger a response when you want one
1. Add the system message to a copy of your chat context.
2. Call await self.update_chat_ctx(chat_ctx) so the model receives the instruction.
3. Only call the reply generation API (generate_reply(), say(), or similar) if sync=True.
Suggested implementation:
async def send_system_message(self, message: str, sync: bool = False) -> None:
chat_ctx = self.chat_ctx.copy()
chat_ctx.add_message(role="system", content=message)
# Ensure Realtime model receives the instruction
await self.update_chat_ctx(chat_ctx)
logger.info(f"[SYSTEM] System message sent: {message}")
# Only generate a response if explicitly requested
if sync:
await self.session.generate_reply(instructions=message)
Optional: if your Realtime plugin supports disabling auto-response (e.g., create_response=False or server-side VAD settings), use that so the model never auto-generates replies and you control every response via generate_reply().
If you want, tell me which SDK/plugin and the session methods you have available (e.g., generate_reply, say, turn-detection options) and I’ll tailor the exact call names.
Sources: Azure OpenAI Realtime API and LiveKit | LiveKit docs | Testing and evaluation | LiveKit Docs | Agent speech and audio | LiveKit docs | Agents v0.x migration guide - Python | LiveKit docs | Realtime model plugins | LiveKit Docslittle-kite-91953
12/05/2025, 10:34 PMtall-airline-16756
12/05/2025, 10:34 PMupdate_chat_ctx() trigger a reply because the Realtime session is configured to auto-generate responses when context changes or when it detects turns. Here’s how to prevent that while still making the model "know" the system message.
Why it replies
• Some Realtime setups auto-create responses when new context is pushed or when turn-detection/auto-response is enabled. So calling update_chat_ctx() can indirectly cause the model to respond even if you don't call generate_reply().
What you can do
• Always call update_chat_ctx() so the model receives the system message.
• Disable the model's auto-response behavior (turn-detection / create_response) so updates don't generate replies automatically.
• If you can't disable auto-response globally, push the context and immediately suppress/ignore any auto-generated reply, or use a server-side flag to mark the update as "silent."
Practical options
• Disable auto-response (recommended):
◦ Set the Realtime turn-detection or server VAD option to not create responses (e.g., create_response=False or equivalent) so context syncs silently. Then call generate_reply() only when you want a response.
• If disabling isn't available:
◦ Call update_chat_ctx() as usual, then ignore or discard the immediate auto-generated response and only use replies you trigger explicitly.
• Use an explicit "silent" update API or metadata if your SDK supports it (some implementations allow sending context updates with a flag that prevents auto-generation).
Concise code pattern
1. Ensure auto-response is off.
2. Sync context:
await self.update_chat_ctx(chat_ctx) # model sees system message
# do NOT call generate_reply() unless you want a response
If you tell me which SDK/version or the exact Realtime options you have available (e.g., turn-detection settings or whether create_response is exposed), I’ll give the exact flag or code snippet to turn off auto-responses.little-kite-91953
12/05/2025, 10:35 PMtall-airline-16756
12/05/2025, 10:36 PMrole="user", which will continue to auto-generate replies.
• Do not rely on local-only updates; push the system message into the Realtime session with the session/context API so the model actually sees it but is still treated as a system message.
Practical patterns 1) Silent system update (recommended)
chat_ctx = self.chat_ctx.copy()
chat_ctx.add_message(role="system", content=message)
# Push the context so the model knows it, but don't call generate_reply()
await self.update_chat_ctx(chat_ctx)
# Do not call session.generate_reply() here — VAD (user speech) will still create replies
2) If update_chat_ctx() currently auto-generates responses in your setup
• Turn off automatic response for context pushes (set the turn-detection/create_response flag so updates don't auto-generate), while keeping VAD-based create_response=True.
◦ Example conceptual flags:
▪︎ For VAD turns: create_response=True
▪︎ For context updates: create_response=False
• If your SDK doesn't expose per-update flags, push the system message as role="system" via the agent/chat API (not as a user/turn) — the platform treats system messages as non-user turns and won’t trigger VAD behavior.
3) Fallback if you cannot change auto-response behavior
• Push the system message and immediately discard/ignore any auto-generated reply produced by that push, relying instead on VAD-triggered replies for user speech.
• Or add a metadata flag with the message (e.g., silent: true) and have your app ignore model outputs produced in response to messages tagged silent.
If you tell me which SDK/version and which flags/methods you currently have available (for example, whether turn_detection or a create_response option is exposed, or whether update_chat_ctx() accepts metadata), I’ll give the exact flag names and a tailored snippet.
Sources: Pipeline nodes and hooks | LiveKit docs | Improving voice AI's turn detection with transformers | Agent speech and audio | LiveKit docs | Turn detection and interruptions | LiveKit Docslittle-kite-91953
12/05/2025, 10:38 PMtall-airline-16756
12/05/2025, 10:38 PMrole="system" and sync them with update_chat_ctx() so the model sees them.
• Ensure you only call session.generate_reply() (or equivalent) from the user-turn handler (e.g., on_user_turn_completed) when VAD/STT injects a role="user" message.
• If your Realtime setup auto-generates on any context push, disable auto-response for context pushes and keep it enabled for VAD turns (see flags below).
Concrete patterns
1) Normal / recommended (system messages silent, VAD triggers replies)
# add system message and sync so model knows it (no immediate reply)
chat_ctx = self.chat_ctx.copy()
chat_ctx.add_message(role="system", content=message)
await self.update_chat_ctx(chat_ctx)
# DO NOT call generate_reply() here
Then in your VAD/user-turn handler:
async def on_user_turn_completed(self, turn_ctx, new_message):
# new_message will be role="user"
await self.session.generate_reply() # VAD triggers this — agent speaks
2) If update_chat_ctx() currently causes an automatic reply
• Prefer per-turn flags if your SDK exposes them:
◦ For VAD turns: set create_response=True
◦ For context updates: set create_response=False
• Example conceptual usage (SDK method names may vary):
# push system context silently
await self.update_chat_ctx(chat_ctx, create_response=False)
# VAD configured to create responses
# (turn detection / VAD remains create_response=True by default)
3) Fallback if no per-update flag exists
• Push the system message, then immediately discard any auto-generated reply produced by that push; only honor replies generated from on_user_turn_completed.
• Or attach metadata silent: true when adding the system message and have your app ignore outputs associated with silent updates.
What I need to give exact code
• Which Python SDK version you’re using and whether you’re using a Realtime LLM (e.g., OpenAI Realtime) or non-realtime model. Also tell me whether update_chat_ctx() in your SDK accepts a create_response or similar flag. With that I’ll provide the exact call signatures and a copy-paste snippet. Sources: Pipeline nodes and hooks | LiveKit docs