You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
priority: p2Moderately-important priority. Fix may not be included in next release.type: bugError or flaw in code with unintended results or allowing sub-optimal usage patterns.
While streaming responses with GenerativeModel.generate_content_stream() (used via livekit-plugins-google), the client occasionally raises a json.decoder.JSONDecodeError: Extra data which bubbles up as an APIConnectionError:
Full traceback
Traceback (most recent call last):
File "/home/appuser/.local/lib/python3.12/site-packages/livekit/plugins/google/llm.py", line 332, in _run
async for response in stream:
File "/home/appuser/.local/lib/python3.12/site-packages/google/genai/models.py", line 7484, in async_generator
async for chunk in response:
File "/home/appuser/.local/lib/python3.12/site-packages/google/genai/models.py", line 6394, in async_generator
async for response_dict in response_stream:
File "/home/appuser/.local/lib/python3.12/site-packages/google/genai/_api_client.py", line 1040, in async_generator
async for chunk in response:
File "/home/appuser/.local/lib/python3.12/site-packages/google/genai/_api_client.py", line 243, in __anext__
return await self.segment_iterator.__anext__()
File "/home/appuser/.local/lib/python3.12/site-packages/google/genai/_api_client.py", line 303, in async_segments
yield json.loads(chunk)
File "/usr/local/lib/python3.12/json/__init__.py", line 346, in loads
return _default_decoder.decode(s)
File "/usr/local/lib/python3.12/json/decoder.py", line 341, in decode
raise JSONDecodeError("Extra data", s, end)
json.decoder.JSONDecodeError: Extra data: line 3 column 1 (char 407)
During handling of the above, another exception occurred:
livekit.agents._exceptions.APIConnectionError: gemini llm: error generating content Extra data: line 3 column 1 (char 407) (body=None, retryable=False)
Also seeing this issue. Using the latest livekit-agents and livekit-plugins-google but reverting the google-genai dependency to 1.17.0 resolves this issue for now for me. (Haven't tested versions after this yet so not sure when the regression occured)
Yes, thank you @jimmy0251 for opening the issue, this seems to be another issue in the ongoing Gemini reliability saga. Personally I'm using Agno with streaming, but it comes down to the python-genai library (agno code: await self.get_client().aio.models.generate_content_stream(..)) where get_client returns a google.genai.Client.
priority: p2Moderately-important priority. Fix may not be included in next release.type: bugError or flaw in code with unintended results or allowing sub-optimal usage patterns.
Activity
simplegr33n commentedon Jun 26, 2025
Also seeing this issue. Using the latest
livekit-agentsandlivekit-plugins-googlebut reverting thegoogle-genaidependency to1.17.0resolves this issue for now for me. (Haven't tested versions after this yet so not sure when the regression occured)nilnor commentedon Jun 26, 2025
Yes, thank you @jimmy0251 for opening the issue, this seems to be another issue in the ongoing Gemini reliability saga. Personally I'm using Agno with streaming, but it comes down to the python-genai library (agno code:
await self.get_client().aio.models.generate_content_stream(..)) where get_client returns a google.genai.Client.sasha-gitg commentedon Jun 26, 2025
Please provide the Gemini model IDs that you are using when encountering this issue.
nilnor commentedon Jun 26, 2025
gemini-2.5-pro, and also encountered this with gemini-2.5-flash-preview-05-20 unless my mind plays tricks on me.
simplegr33n commentedon Jun 26, 2025
gemini-2.5-flash-preview-05-20for me. No issues onv1.20.0mbrian23 commentedon Jun 27, 2025
Same issue here—using the ADK (1.5.0) with google-genai (1.22.0) as a dependency
sasha-gitg commentedon Jun 27, 2025
If using aiohttp, this PR may fix this issue - working on getting it in: https://github.com/googleapis/python-genai/pull/1048/files
XinyueZ commentedon Jun 27, 2025
An official release is needed as this is a critical issue causing significant disruptions.
XinyueZ commentedon Jun 27, 2025
@sasha-gitg fixing worked on my side
janasangeetha commentedon Jun 30, 2025
Hey users,
We have similar issue #1010. Please follow up on the same!
Thank you!