ADK agent would sometimes return malformed JSON
Problem Description I encountered intermittent JSON parsing errors when integrating a frontend application with an ADK agent backend. The ADK agent would sometimes return malformed JSON that couldn't be parsed by the frontend, specifically when using visualization tools. Error Details:
Expected ',' or '}' after property value in JSON at position ~4069 Unexpected token 'T', ..."useGeodata": True, "val"... is not valid JSON Error occurred in ADK's stateDelta.visual_result field responses
Architecture:
Backend: ADK Agent (Python) running on adk api_server Frontend: React/Vite app consuming ADK /run endpoint Issue: JSON responses from ADK agent contained somettimes Python formatting instead of valid JSON
Symptoms
Intermittent behavior: Same visualization request would work sometimes, fail other times Python vs JSON format: ADK responses contained someties True/False instead of true/false
anyone had similare issue
duplicate. closing.
Hi, is there any specific way that JSON validation can be solved. I am using output_key with a proper Pydantic model and the model fails. This is intermittent, with more occurrences when using flash vs pro models. But happens every now and then. If there are any guidelines, please can you share?
I am using adk with Python.