miniature-barista-33555
12/27/2025, 1:10 AMtall-airline-16756
12/27/2025, 1:10 AMtall-airline-16756
12/27/2025, 1:11 AMinstructions="Say you like cats." can be overridden by the last message in the chat history. This is expected behavior.
• Your workaround (including past conversation text in the instructions) is a valid way to get a controlled reply while preserving history.
What you can do (options)
• Keep using instructions, but include the needed context in that instructions string so the model sees both the past conversation and the one-off directive. Example:
await self.session.generate_reply(instructions=f"""
Past conversation: {serialized_history}
Now, respond with: Say you like cats.
""")
• Use user_input when you want to inject a message that should behave like a user turn (it will be appended to history and processed normally). Use instructions only for high-level control that does not become a chat message.
• If you need the agent to act on a directive that should override the last user turn, explicitly add an assistant/system message into the chat context before calling generate_reply() with an instruction that references that message. For example, add an assistant message like "System directive: Say you like cats." then call generate_reply().
Clarifying question
• Do you want the preloaded history to remain visible to the model but have a single instruction always take precedence (i.e., force the agent to ignore the last user turn)? If so, I can show a concise code pattern to inject a system/assistant directive into the live chat context so it will be followed by subsequent generate_reply() calls.
If you tell me which option you'd prefer (forced override vs. combined-context instruction vs. using user_input), I’ll give the exact code snippet that fits your current setup.
Sources: Agent speech and audio | LiveKit docs | External data and RAG | LiveKit docs | Pipeline nodes and hooks | LiveKit docs | Text and transcriptions | LiveKit docs