-
Notifications
You must be signed in to change notification settings - Fork 473
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
System prompt is ignored after fatal errors with realtime api #1183
Comments
I have created a PR #1200 to emit the error from the realtime API, so that agent can decide to reset or close the session in the callback. Does that make sense? |
Hi @longcw - many thanks for this! We're now able to read the event emitted (RealtimeError) so that's good. My only followup question - is it well understood why we can keep talking to OpenAI with the system prompt being ignored? I'm wondering if a new session is being created with default opts but I haven't been able to dig around enough yet so it's only an idea. This is still a concern for us because there may be other back doors whereby the system prompt is ignored so would be good to understand the fundamental issue. |
The session to the OAI Realtime API is created when The session is created and active even the To better track if the session update is successful, perhaps we can emit the |
Thanks for the quick response! Hm so something behind the scenes is updating the session? To be clear, we do not want to update the session to change the instructions (system prompt) ever. Is there a way of prohibiting such changes? Emitting a session updated event would be useful so we could check if the instructions had changed, though! |
To be clear, it's OpenAI will always set a default configuration for the session, This is also why you can still talk to the agent when the error happens. |
Session update may be a red herring. In our case, we're creating the azure model with this:
Looking at I then have the following code:
So when a RealtimeError is emitted, the session instructions are still valid BUT the voice assistant is clearly not using our system prompt / instructions (it's speaking in the wrong voice, it's speaking other languages, doing math, talking about politics etc). I've also confirmed that we're not creating an additional session which might have fresh instructions. So I'm quite stumped as to why we're seeing this behaviour if the session instructions are still our original prompt (i.e. it looks like the session hasn't been updated). But yea if you start emitting |
I think there is some misunderstanding of how "RealtimeModel" works. The actual process is
Steps 2-4 all occur in the The point is that all the actual configuration and conversations are managed by the OAI, and |
Ah I see. So in our case, what's (probably) happening is:
What doesn't make sense for our case still is that the OAI docs say But in any case, your suggestions of
|
How to replicate
trigger an OpenAI error (e.g. send a tool call description that's too long which triggers the error below)
Expected behaviour
Actual behaviour
Versions
livekit = "0.18.1"
livekit-agents = "0.11.3"
livekit-plugins-openai = "0.10.7"
livekit-protocol = "0.7.0"
We’re using a realtime-api model hosted on Azure.
I suspect this is the line causing the error -
agents/livekit-plugins/livekit-plugins-openai/livekit/plugins/openai/realtime/realtime_model.py
Line 997 in d671302
While we can of course fix this specific error, we’re concerned that errors are being swallowed by the system and the user is allowed to continue without safeguards. I was also able to raise uncaught exceptions elsewhere in the code to recreate the error.
The text was updated successfully, but these errors were encountered: