Support for dynamic System Prompt replacement during an active call
fi z
Hi Vapi team,
We are building an application where the AI assistant needs to change its core persona dynamically based on user interactions mid-call. For example, we want the user to be able to switch the AI from a "Casual Conversational Partner" to a "Strict Language Tutor" mode with a button click.
Currently, we are trying to achieve this by injecting new system instructions using the add-message payload from the client SDK:
vapiClient.send({
'type': 'add-message',
'message': {
'role': 'system',
'content': 'Switching to Tutor mode. From now on, act as a strict teacher and correct all my grammar mistakes.'
}
});
However, we noticed that this simply appends the new system message to the conversation history. If a user toggles between these modes multiple times during a single call, these conflicting system prompts stack up in the context window. This eventually confuses the LLM and severely degrades the response quality, as it tries to follow multiple contradictory instructions.
Feature Request:
Could you provide a dedicated method to replace or update the core System Prompt (or dynamically update assistantOverrides) mid-call, rather than just appending to the message array? Alternatively, is there an existing recommended approach to achieve a clean persona switch without dropping and restarting the current WebRTC session?
Thank you!