c
help
t
Thanks for reaching out, Joshua. I'm an AI assistant and I'm here to help. Give me a moment while I research this topic.
I’m here to help — could you tell me which area you need assistance with? • Is this about an account, billing, a specific error, SDK/integration, rooms/participants, or something else? • If it’s an error, please paste the error message and share any relevant IDs (project ID, room ID) and steps to reproduce. • If it’s an integration or SDK issue, tell me the platform (web, iOS, Android, server) and the LiveKit SDK version. Share whichever details you have and I’ll guide you next.
c
can you tell me where you get your info from the websource of information
t
You're asking where I get my information. I use LiveKit's product documentation and knowledge resources provided for support (the official LiveKit docs, help articles, and internal support materials) to answer product- and support-related questions. If you mean web sources outside LiveKit, tell me which topic you want sources for and I’ll specify what references I used or can check.
c
can you help me with this error? client_session: <aiohttp.client.ClientSession object at 0x00000145AFA2E0D0> 2025-12-10 204846,509 - WARNING MedicalRecords.BaseAgent - Room not found for muting (expected in console mode): TwirpError(code=not_found, message=requested room does not exist, status=404) 2025-12-10 204852,743 - WARNING MedicalRecords.BaseAgent - Room not found for muting (expected in console mode): TwirpError(code=not_found, message=requested room does not exist, status=404) 2025-12-10 204853,022 - ERROR livekit.plugins.google - error in receive task: received 1007 (invalid frame payload data) Request contains an invalid argument.; then sent 1007 (invalid frame payload data) Request contains an invalid argument. Traceback (most recent call last): File "C:\Users\rayan\Downloads\Testing-AI\NYGA\nyga-medical-records-v1\.venv\Lib\site-packages\livekit\plugins\google\realtime\realtime_api.py", line 761, in _recv_task async for response in session.receive(): ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ ...<31 lines>... self._num_retries = 0 # reset the retry counter ^^^^^^^^^^^^^^^^^^^^^ File "C:\Users\rayan\Downloads\Testing-AI\NYGA\nyga-medical-records-v1\.venv\Lib\site-packages\google\genai\live.py", line 453, in receive while result := await self._receive(): ^^^^^^^^^^^^^^^^^^^^^ File "C:\Users\rayan\Downloads\Testing-AI\NYGA\nyga-medical-records-v1\.venv\Lib\site-packages\google\genai\live.py", line 534, in _receive raw_response = await self._ws.recv(decode=False) ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ File "C:\Users\rayan\Downloads\Testing-AI\NYGA\nyga-medical-records-v1\.venv\Lib\site-packages\websockets\asyncio\connection.py", line 322, in recv raise self.protocol.close_exc from self.recv_exc websockets.exceptions.ConnectionClosedError: received 1007 (invalid frame payload data) Request contains an invalid argument.; then sent 1007 (invalid frame payload data) Request contains an invalid argument. 2025-12-10 204853,030 - DEBUG livekit.plugins.google - send task finished. 2025-12-10 204853,031 - DEBUG livekit.plugins.google - connecting to Gemini Realtime API... 2025-12-10 205155,183 - DEBUG livekit.agents - executing tool {"function": "transfer_to_dispatch_agent", "arguments": "{\"transfer_reason\": \"Patient wants to send
t
Thanks — I’m looking at the two errors in your logs: the TwirpError 404 "room not found" when muting, and the WebSocket 1007 "invalid frame payload data" from the Gemini Realtime API. I can help troubleshoot both — a few targeted checks will narrow this down quickly. Please confirm/provide: • The exact room name (or room ID) and how you create/join it in your code. Do you create the room explicitly or rely on the first participant to create it? • The sequence/timing: does the mute attempt happen immediately after joining, or later? Any use of timeouts or background tasks that might act after the room is closed? • The code snippet that performs the mute (or the API call) and the code where you connect/send to Gemini (especially how audio or messages are encoded). • The audio format you send to Gemini (sample rate, bit depth, channels, and whether it’s raw PCM or encoded like OPUS/MP3). • Versions of these packages in your venv:
livekit
,
livekit-plugins-google
, and
google-genai
. Quick troubleshooting steps to try now: • Before muting, list or fetch the room to confirm it exists and that your agent has joined it. Retry with short backoff if it's transient. • Ensure you wait for the room-joined/connected event before sending room operations. • Validate audio frames before sending to Gemini: they must be correctly formatted (no None/NaN, correct sample rate/bit depth, and proper binary vs text framing). • Enable DEBUG logging for the plugin to capture the exact outgoing message that triggers the 1007 close. • Update
livekit
and
livekit-plugins-google
to their latest compatible versions if not already current. Send the requested snippets (room create/join, mute call, and Gemini send/receive code) plus package versions and I’ll pinpoint the likely offending message and a code fix. Sources: Managing rooms | LiveKit docs | Agents telephony integration | LiveKit docs | Gemini Live API plugin | LiveKit docs | Realtime model plugins | LiveKit Docs
c
i only want to know about this frames error not being sent properly ignore the room sid thing that was because i was running on console But what is this error mean? here are my packages ivekit.plugins.google - error in receive task: received 1007 (invalid frame payload data) Request contains an invalid argument.; then sent 1007 (invalid frame payload data) Request contains an invalid argument. Traceback (most recent call last): File "C:\Users\rayan\Downloads\Testing-AI\NYGA\nyga-medical-records-v1\.venv\Lib\site-packages\livekit\plugins\google\realtime\realtime_api.py", line 761, in _recv_task async for response in session.receive(): ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ ...<31 lines>... self._num_retries = 0 # reset the retry counter ^^^^^^^^^^^^^^^^^^^^^ File "C:\Users\rayan\Downloads\Testing-AI\NYGA\nyga-medical-records-v1\.venv\Lib\site-packages\google\genai\live.py", line 453, in receive while result := await self._receive(): ^^^^^^^^^^^^^^^^^^^^^ File "C:\Users\rayan\Downloads\Testing-AI\NYGA\nyga-medical-records-v1\.venv\Lib\site-packages\google\genai\live.py", line 534, in _receive raw_response = await self._ws.recv(decode=False) ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ File "C:\Users\rayan\Downloads\Testing-AI\NYGA\nyga-medical-records-v1\.venv\Lib\site-packages\websockets\asyncio\connection.py", line 322, in recv raise self.protocol.close_exc from self.recv_exc livekit-agents[cartesia,deepgram,google,silero,turn-detector, rime]==1.2.15 openai livekit-agents[openai,google]==1.2.15 python-dotenv>=1.1.1 firebase-admin>=6.4.0 google-cloud-storage google-cloud-bigquery livekit-plugins-noise-cancellation~=0.2 pandas pandas-gbq google-generativeai google-genai datetime pytz python-json-logger requests google-cloud-pubsub==2.33.0
t
Thanks — focusing only on the WebSocket 1007 "invalid frame payload data" error. What it means • 1007 indicates the peer (Gemini) rejected a WebSocket frame because the payload was malformed or not the expected encoding/structure (invalid text encoding or invalid binary payload). Most likely causes in your setup • A malformed WebSocket message: sending text frames with invalid UTF-8 or binary frames with corrupt/incorrect bytes. • Invalid audio frames: wrong format (not 16-bit PCM where expected), wrong sample rate/channels, or improperly chunked binary audio. • Invalid control/data message: JSON or Protobuf with non-serializable values, None/NaN, or wrong schema. • Package conflicts that cause wrong behavior: you have both
google-genai
and
google-generativeai
(possible incompatibility), and multiple overlapping
livekit-agents
extras — these can cause mixed imports or incompatible runtime behavior that produces malformed frames. Immediate troubleshooting steps (minimal, actionable) 1. Enable debug logging for the Google plugin to capture the exact outgoing frames. ◦ logging.basicConfig(level=logging.DEBUG) and target
livekit.plugins.google
and
google.genai
logs. 1. Reproduce with a minimal test: connect the RealtimeModel and send a single small, known-good payload (e.g., a simple text event or a short validated PCM audio frame). Confirm whether minimal payloads succeed. 2. Validate audio payloads before send: ◦ Ensure 16-bit signed PCM (
pcm_s16le
), correct sample rate expected by the model, mono, and proper chunk sizes. Reject frames with None/NaN. 1. Inspect outgoing frames right before send: ◦ Log type, length, and a small hex/utf-8 preview. If text frames fail, ensure UTF-8 validity. 1. Simplify dependencies: ◦ Uninstall
google-generativeai
if not required. Keep
google-genai
(the package used by the plugin). ◦ Consolidate
livekit-agents
extras into one install to avoid duplicate extras and reinstall to remove import ambiguities. 1. Update packages to compatible versions (reinstall after cleanup) and retest. If you want, paste: • A small snippet that sends frames to Gemini (text or audio send path). • One logged example of an outgoing frame (or its type/first ~100 bytes). I’ll point to the exact offending encoding/field. Sources: Gemini Live API plugin | LiveKit docs | An open source stack for real-time multimodal AI
c
its audio only
t
Thanks — since it’s audio-only, the 1007 error means Gemini closed the WebSocket because an audio frame payload was malformed or not the expected format. Here’s what to check and how to fix it. What 1007 indicates for audio • The server received a frame it couldn’t parse (invalid binary payload or encoding). For audio this is almost always: wrong sample format, corrupted bytes, wrong framing, or unexpected meta in the message. Concrete checks and fixes • Confirm required format: ◦ Send raw 16‑bit signed PCM (
pcm_s16le
) unless the model/docs specify otherwise. ◦ Use the sample rate the RealtimeModel expects (verify model—common rates are 16kHz or 24/48kHz). ◦ Send mono (1 channel) unless stereo is explicitly supported. • Validate your audio pipeline: ◦ Ensure samples are integers (no NaN/None), correct dtype (int16), and contiguous bytes:
numpy_array.astype(np.int16).tobytes()
. ◦ Do not send encoded formats (MP3/OPUS) as raw PCM frames. • Check framing/packetization: ◦ Send reasonably sized chunks; avoid sending huge blobs or splitting frames incorrectly. ◦ Ensure you send binary WS frames when sending audio (not text frames). • Log outgoing payloads right before send: ◦ Log type, length, and a small hex/UTF-8 preview (first ~64 bytes) to spot corruption or wrong framing. • Reproduce with a minimal valid frame: ◦ Generate a short 1s sine wave converted to int16 PCM and send it; if that works, your capture/encoding is the problem. • Dependency sanity: ◦ Keep the Google GenAI client your plugin expects (
google-genai
), remove conflicting
google-generativeai
if present, and ensure
livekit-plugins-google
is compatible with installed genai version. • Retry behavior: ◦ If you detect an invalid frame, drop it and continue rather than repeatedly sending corrupt data. If you want, paste a small snippet that encodes/sends the audio frame (the code that creates the bytes and calls send). I’ll point out exactly what to change or validate.
c
where are docs for this error where can i find them
t
You're looking for docs about the WebSocket 1007 "invalid frame payload data" error (audio-only). Short answer and links: What 1007 means • 1007 is a standard WebSocket close code meaning the peer received a message whose payload is not consistent with the message type (e.g., non‑UTF‑8 text or an unexpected/corrupt binary payload). For audio, this means the server rejected the audio frame because its bytes/encoding were malformed or not the expected format. Relevant docs to read • WebSocket close codes (explains 1007): https://developer.mozilla.org/en-US/docs/Web/API/CloseEvent#status_codes • RFC 6455 (WebSocket protocol, close codes): https://tools.ietf.org/html/rfc6455#section-7.4.1 • LiveKit — stream audio to WebSocket (how audio/text frames are expected): https://docs.livekit.io/home/egress/track/#stream-audio-to-websocket • LiveKit Agents — byte/stream handling for realtime models: https://docs.livekit.io/agents/build/inputs/byte-streams/ What to check while debugging (quick checklist) • Send binary frames for audio (not text) and ensure no binary is sent in text frames. • Confirm audio format: 16-bit signed PCM (
pcm_s16le
) and the sample rate/channels expected by the RealtimeModel. • Ensure frames contain valid int16 samples (no NaN/None) and are properly chunked. • Log outgoing frames (type, length, first bytes) to find malformed sends. • Remove conflicting Google packages (
google-generativeai
) if it interferes with the plugin's
google-genai
usage. If you want, paste one logged outgoing frame (type + first ~64 bytes or hex preview) and the small send/encode snippet — I’ll point out exactly what looks malformed. Sources: Server-side | livekit/livekit_composite | DeepWiki | Track egress | LiveKit docs | Vision | LiveKit Docs
c
livekit-agents[cartesia,deepgram,google,silero,turn-detector, rime]==1.2.15 openai livekit-agents[openai,google]==1.2.15 python-dotenv>=1.1.1 firebase-admin>=6.4.0 google-cloud-storage google-cloud-bigquery livekit-plugins-noise-cancellation==0.2.5 pandas pandas-gbq google-generativeai google-genai datetime pytz python-json-logger requests google-cloud-pubsub==2.33.0 these are my packages it happens on one agent right after i play the intro speech and then it comes while audio is playing back. Never encountered this in other agents
t
Thanks — with that package list and the detail that it happens right after the intro speech while audio is playing back, this narrows it down. Likely cause • Gemini closed the WebSocket with code 1007 because an audio frame sent during playback was malformed or in the wrong encoding (binary frame with corrupted bytes or wrong PCM format). Targeted checks to run now 1. Confirm intro playback path vs capture path ◦ Verify the intro audio you play back is sent as binary audio frames (not accidentally sent as text frames or JSON). 1. Validate audio format for every outgoing frame ◦ Ensure frames are 16-bit signed PCM (
pcm_s16le
) and the sample rate/channels your RealtimeModel expects. ◦ Convert arrays with:
pcm_bytes = numpy_array.astype(np.int16).tobytes()
. 1. Inspect the exact frame that triggers the close ◦ Add logging immediately before sending: type, len, and first 64 bytes hex preview. ◦ Example log:
logger.debug("send: %s bytes %d preview=%s", type(data), len(data), data[:64].hex())
1. Check for mixed/duplicate packages causing runtime conflict ◦ Having both
google-genai
and
google-generativeai
can cause unexpected behavior. Uninstall
google-generativeai
unless you explicitly need it. ◦ Consolidate
livekit-agents
extras to a single install to avoid overlapping installs. 1. Reproduce with a minimal valid frame ◦ Send a short generated 1s int16 sine wave as a test payload. If that works, the issue is your recorded/intro audio encoding or clips injected mid-stream. 1. Playback timing/race ◦ If you switch from playback to capture or splice streams, ensure you don’t accidentally send a zero-length frame, None, or metadata in place of binary audio during the transition. If you want me to pinpoint it, paste: • The small send/encode snippet used when playing the intro and during playback (how you build/send bytes). • One logged send preview (type, len, first ~64 bytes hex) captured right before the socket close. I’ll examine that and show exactly what is malformed.
c
could this be an issue with google-genai and google noise cancellations
t
Short answer: no known direct conflict between
google-genai
and LiveKit’s noise‑cancellation plugin that would inherently produce WebSocket 1007 — but noise processing can indirectly cause malformed audio frames, so it’s worth testing. What to try (quick): • Disable noise cancellation and retest playback. If the 1007 stops, the processing pipeline is likely corrupting frames or changing format. • Confirm noise-cancellation output is still raw 16-bit PCM
int16
bytes, correct sample rate, and mono before sending to Gemini. • Log a failing frame (type, length, first ~64 bytes hex) right before send with and without noise cancellation to compare. • As a control, send a known-good synthetic 1s int16 sine wave during playback; if that never triggers 1007, your real audio or processing is at fault. If you want, paste the small encode/process/send snippet (where noise cancellation runs) and one logged failing-frame preview and I’ll point out what to change. Sources: Google Gemini LLM plugin guide | LiveKit Docs | Enhanced noise cancellation | LiveKit docs