Skip to content

‼️ json.decoder.JSONDecodeError: Extra data: line 3 column 1 (char 639) #1705

Closed

Description

@XinyueZ

SSE for txt2txt streaming
run_async

model: flash 2.5 gemini

ref issue: #759, googleapis/python-genai#1024

agent with :

planner=(
        built_in_planner.BuiltInPlanner(thinking_config=types.ThinkingConfig(
                    include_thoughts=True,
                    thinking_budget=-1,
                ))
        if thinking_config
        else None
    )

deps:

Image
Image

2025-06-27 23:52:22 - Unclosed client session
client_session: <aiohttp.client.ClientSession object at 0x169983860>
2025-06-27 23:52:22 - Unclosed connector
connections: ['deque([(<aiohttp.client_proto.ResponseHandler object at 0x169abea50>, 335951.859904208)])']
connector: <aiohttp.connector.TCPConnector object at 0x169982c90>
2025-06-27 23:52:22 - Extra data: line 3 column 1 (char 639)
Traceback (most recent call last):
  File "/opt/homebrew/anaconda3/envs/hermes-faq/lib/python3.12/site-packages/chainlit/utils.py", line 47, in wrapper
    return await user_function(**params_values)
           ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
  File "/opt/homebrew/anaconda3/envs/hermes-faq/lib/python3.12/site-packages/chainlit/callbacks.py", line 169, in with_parent_id
    await func(message)
  File "/Users/xinyue.zhao/Desktop/dev/AI/AIMO/hermes-faq/chat_ui.py", line 265, in on_message
    async def end_chat():
            ^^^^^^^^^^^^^^
  File "/Users/xinyue.zhao/Desktop/dev/AI/AIMO/hermes-faq/chat_ui.py", line 215, in _on_streaming
    #    logger.error(f"Streaming error: {e}")
        ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
  File "/Users/xinyue.zhao/Desktop/dev/AI/AIMO/hermes-faq/utils/cl_stream_step_helper.py", line 15, in agent_steps
    async for chunk in response:
  File "/Users/xinyue.zhao/Desktop/dev/AI/AIMO/hermes-faq/chat_agent.py", line 105, in _client2agent_streaming2client
    async for event in self.runner.run_async(
  File "/opt/homebrew/anaconda3/envs/hermes-faq/lib/python3.12/site-packages/google/adk/runners.py", line 203, in run_async
    async for event in invocation_context.agent.run_async(invocation_context):
  File "/opt/homebrew/anaconda3/envs/hermes-faq/lib/python3.12/site-packages/google/adk/agents/base_agent.py", line 147, in run_async
    async for event in self._run_async_impl(ctx):
  File "/opt/homebrew/anaconda3/envs/hermes-faq/lib/python3.12/site-packages/google/adk/agents/llm_agent.py", line 275, in _run_async_impl
    async for event in self._llm_flow.run_async(ctx):
  File "/opt/homebrew/anaconda3/envs/hermes-faq/lib/python3.12/site-packages/google/adk/flows/llm_flows/base_llm_flow.py", line 282, in run_async
    async for event in self._run_one_step_async(invocation_context):
  File "/opt/homebrew/anaconda3/envs/hermes-faq/lib/python3.12/site-packages/google/adk/flows/llm_flows/base_llm_flow.py", line 314, in _run_one_step_async
    async for llm_response in self._call_llm_async(
  File "/opt/homebrew/anaconda3/envs/hermes-faq/lib/python3.12/site-packages/google/adk/flows/llm_flows/base_llm_flow.py", line 539, in _call_llm_async
    async for llm_response in llm.generate_content_async(
  File "/opt/homebrew/anaconda3/envs/hermes-faq/lib/python3.12/site-packages/google/adk/models/google_llm.py", line 120, in generate_content_async
    async for response in responses:
  File "/opt/homebrew/anaconda3/envs/hermes-faq/lib/python3.12/site-packages/google/genai/models.py", line 7581, in async_generator
    async for chunk in response:  # type: ignore[attr-defined]
  File "/opt/homebrew/anaconda3/envs/hermes-faq/lib/python3.12/site-packages/google/genai/models.py", line 6475, in async_generator
    async for response in response_stream:
  File "/opt/homebrew/anaconda3/envs/hermes-faq/lib/python3.12/site-packages/google/genai/_api_client.py", line 1040, in async_generator
    async for chunk in response:
  File "/opt/homebrew/anaconda3/envs/hermes-faq/lib/python3.12/site-packages/google/genai/_api_client.py", line 243, in __anext__
    return await self.segment_iterator.__anext__()
           ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
  File "/opt/homebrew/anaconda3/envs/hermes-faq/lib/python3.12/site-packages/google/genai/_api_client.py", line 303, in async_segments
    yield json.loads(chunk)
          ^^^^^^^^^^^^^^^^^
  File "/opt/homebrew/anaconda3/envs/hermes-faq/lib/python3.12/json/__init__.py", line 346, in loads
    return _default_decoder.decode(s)
           ^^^^^^^^^^^^^^^^^^^^^^^^^^
  File "/opt/homebrew/anaconda3/envs/hermes-faq/lib/python3.12/json/decoder.py", line 340, in decode
    raise JSONDecodeError("Extra data", s, end)
json.decoder.JSONDecodeError: Extra data: line 3 column 1 (char 639)

Activity

  1. changed the title [-]json.decoder.JSONDecodeError: Extra data: line 3 column 1 (char 639)[/-] [+]‼️ json.decoder.JSONDecodeError: Extra data: line 3 column 1 (char 639)[/+] on Jun 27, 2025
  2. added
    live
    on Jun 27, 2025
  3. XinyueZ commented on Jun 28, 2025

    @XinyueZ
    Author

    Fixed by googleapis/python-genai#1048

    The latest GenAI lib contains the fixings.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

No one assigned

    Labels

    live

    Type

    No type

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions