Hi again @Joe_Hu !
We were hitting the same 1008 errors. After investigation, we found the root cause was
a race condition in how we handled realtime input during tool calls.
Here’s what solved it for us:
Root Cause
When Gemini sends a tool_call, the session enters a state where it rejects all sendRealtimeInput calls — including audio, activityStart, activityEnd, and audioStreamEnd. If your client continues streaming microphone audio or sending activity signals while the tool call is pending, the server responds with error 1008 (policy violation) and closes the WebSocket.
This happens because there’s a race condition between:
Your audio input task (continuously streaming mic data)
Your res…
Zero errors in testing so far with this approach.
I hope this helps!