Agent Raw response thought instead of final result
Describe the bug
message = types.Content(role="user", parts=[types.Part(text=message_text)])
async for event in self.runner.run_async(user_id=self.user_id, session_id=self.session_id, new_message=message):
if event.is_final_response():
# validate to ensure text is not empty
# Get the text content safely using attribute chaining with conditional expressions
# Dont use getattr
parts = event.content.parts if event.content else None
if not parts:
logger.error(f"reasoning_agent error: event content is empty {event}")
# find text in part item from index 0
for part in parts:
if part.text:
return part.text
Root agent has sub agent [jira_pm_agent] When chatting with root agent, it responses a thinking result instead of text The Raw response: bellow
`INFO:google_genai.models:AFC is enabled with max remote calls: 10.24INFO:httpx:HTTP Request: POST https://generativelanguage.googleapis.com/v1beta/models/gemini-2.5-pro-preview-05-06:generateContent "HTTP/1.1 200 OK"
WARNING:google_genai.types:Warning: there are non-text parts in the response: ['thought_signature', 'function_call'], returning concatenated text result from text parts. Check the full candidates.content.parts accessor to get the full model response
INFO:google_adk.google.adk.models.google_llm:LLM
Function calls:15name: transfer_to_agent, args: {'agent_name': 'jira_pm_agent'}
Raw response: {"candidates":[{"content":{"parts":[{"thought":true,"thought_signature":"AVSoXO5-FQYYhIVP-dtGqxAgdu2KFCqFUlaBKotkovKCRWHrqSevXmgwRj-Qwlfb-SrNAWq-4XtYYOw6CyhmrEV3Ssh1sz3kjeodwrWLuhcqlMnzDpvhhaw8-qkPjRDUDiKKjU9K4qjMfoULxnbdEkU2DOr8cVwQIj29ek8zmng-690aFwDo_IVRTNUfiO32MgITS6AcbjyT-oNWkFGoSFDP8AGRjd-9cSyKZ0sHJULE21rRT8Yvn8Q38WDSiSY6Ap3iTYgzNAjocK6sgOV2gNoVenfuKhW50m3r"},{"function_call":{"args":{"agent_name":"jira_pm_agent"},"name":"transfer_to_agent"}}],"role":"model"},"finish_reason":"STOP","index":0}],"model_version":"models/gemini-2.5-pro-preview-05-06","usage_metadata":{"candidates_token_count":23,"prompt_token_count":3533,"prompt_tokens_details":[{"modality":"TEXT","token_count":3533}],"thoughts_token_count":48,"total_token_count":3604},"automatic_function_calling_history":[]}
INFO:google_adk.google.adk.sessions.database_session_service:Append event: content=Content(parts=[Part(video_metadata=None, thought=True, inline_data=None, file_data=None, thought_signature=b'\x01T\xa8\\xee~\x15\x06\x18\x84\x85O\xf9\xdbF\xab\x10 v\xed\x8a\x14*\x85RV\x81*\x8bd\xa2\xf2\x82Ea\xeb\xa9'\xaf^h0F?\x90\xc2W\xdb\xf9*\xcd\x01j\xbe\xe1{X\xec:\x0b(f\xacEwJ\xc8u\xb3=\xe4\x8d\xea\x1d\xc2\xb5\x8b\xba\x17*\x94\xc9\xf3\x0e\x9b\xe1\x85\xac<\xfa\xa9\x0f\x8d\x10\xd4\x0e"\x8a\x8dOJ\xe2\xa8\xcc~\x85\x0b\xc6v\xdd\x12E6\x0c\xea\xfcq\\\x10"=\xbdzO3\x9ax>\xeb\xdd\x1a\x17\x00\xe8\xfc\x85QL\xd5\x1f\x88\xed\xf62\x02\x13K\xa0\x1cn<\x93\xfa\x83V\x90Q\xa8HP\xcf\xf0\x01\x91\x8d\xdf\xbdq,\x8agK\x07%B\xc4\xdbZ\xd1O\xc6/\x9f\xc47\xf1\xd2\x89&:\x02\x9d\xe2M\x8834\x08\xe8p\xae\xac\x80\xe5v\x80\xda\x15zw\xee*\x15\xb9\xd2m\xeb', code_execution_result=None, executable_code=None, function_call=None, function_response=None, text=None), Part(video_metadata=None, thought=None, inline_data=None, file_data=None, thought_signature=None, code_execution_result=None, executable_code=None, function_call=FunctionCall(id='adk-98ee55d2-65b5-4fb9-a94c-ed59cda7397d', args={'agent_name': 'jira_pm_agent'}, name='transfer_to_agent'), function_response=None, text=None)], role='model') grounding_metadata=None partial=None turn_complete=None error_code=None error_message=None interrupted=None custom_metadata=None usage_metadata=GenerateContentResponseUsageMetadata(cache_tokens_details=None, cached_content_token_count=None, candidates_token_count=23, candidates_tokens_details=None, prompt_token_count=3533, prompt_tokens_details=[ModalityTokenCount(modality=<MediaModality.TEXT: 'TEXT'>, token_count=3533)], thoughts_token_count=48, tool_use_prompt_token_count=None, tool_use_prompt_tokens_details=None, total_token_count=3604, traffic_type=None) invocation_id='e-e9df368f-df6f-423e-9876-247d6360f5fe' author='reasoning_agent' actions=EventActions(skip_summarization=None, state_delta={}, artifact_delta={}, transfer_to_agent=None, escalate=None, requested_auth_configs={}) long_running_tool_ids=set() branch=None id='PXYF5U0a' timestamp=1748927375.897826 to session spaces/AAAAYmNaT6E_spaces/AAAAYmNaT6E/threads/I6Og_VKLxeM_SPACE820`
Desktop (please complete the following information):
- OS: [e.g. iOS]
- Python version(python -V): 3.1.12
- ADK version(pip show google-adk): 1.0.0
Ensure you're checking event.is_final_response() before accessing content. For safety:
if event.is_final_response() and hasattr(event, "content") and event.content:
text = event.content.parts[0].text if event.content.parts else None
Avoid getattr; rely on direct attribute checks.
Ensure you're checking event.is_final_response() before accessing content. For safety:
if event.is_final_response() and hasattr(event, "content") and event.content: text = event.content.parts[0].text if event.content.parts else NoneAvoid
getattr;rely on direct attribute checks.
My code work over a month and today is the first time I got that issue. So weird!!!!! I never see thought event response before.
The correct response I got before like this
Raw response:
{"candidates":[{"content":{"parts":[{"thought":true},{"text":"Hi! I'm AI Assistant Agent. How can I help you today??"}],"role":"model"},"finish_reason":"STOP","index":0}],"model_version":"models/gemini-2.5-pro-preview-05-06","usage_metadata":{"candidates_token_count":21,"prompt_token_count":1508,"prompt_tokens_details":[{"modality":"TEXT","token_count":1508}],"thoughts_token_count":549,"total_token_count":2078},"automatic_function_calling_history":[]}
I'm facing the same issue since today.
This event type, with a bytes thought_signature in content part, is generating an exception in database_session_service.py L.548
Error in run_async: (builtins.TypeError) Object of type bytes is not JSON serializable
[SQL: INSERT INTO events (id, app_name, user_id, session_id, invocation_id, author, branch, timestamp, content, actions, long_running_tool_ids_json, grounding_metadata, partial, turn_complete, error_code, error_message, interrupted) VALUES (%(id)s, %(app_name)s, %(user_id)s, %(session_id)s, %(invocation_id)s, %(author)s, %(branch)s, %(timestamp)s, %(content)s::JSONB, %(actions)s, %(long_running_tool_ids_json)s, %(grounding_metadata)s::JSONB, %(partial)s, %(turn_complete)s, %(error_code)s, %(error_message)s, %(interrupted)s)]
[parameters: [{'content': {'parts': [{'thought': True, 'thought_signature': b'\x01\x9b5\x99\x9c\xe1E\x9b!5\xa3\x99\x80\xacAO~\x87H\x80\x90\xae<t\xfd\xe1\x11\xb7\xd1 ... (566 characters truncated) ... r_code': None, 'long_running_tool_ids_json': None, 'partial': None, 'branch': None, 'interrupted': None, 'turn_complete': None, 'error_message': None}]]
I'm facing the same issue since today. This new event type is generating an exception in
database_session_service.pyL.548Error in run_async: (builtins.TypeError) Object of type bytes is not JSON serializable [SQL: INSERT INTO events (id, app_name, user_id, session_id, invocation_id, author, branch, timestamp, content, actions, long_running_tool_ids_json, grounding_metadata, partial, turn_complete, error_code, error_message, interrupted) VALUES (%(id)s, %(app_name)s, %(user_id)s, %(session_id)s, %(invocation_id)s, %(author)s, %(branch)s, %(timestamp)s, %(content)s::JSONB, %(actions)s, %(long_running_tool_ids_json)s, %(grounding_metadata)s::JSONB, %(partial)s, %(turn_complete)s, %(error_code)s, %(error_message)s, %(interrupted)s)] [parameters: [{'content': {'parts': [{'thought': True, 'thought_signature': b'\x01\x9b5\x99\x9c\xe1E\x9b!5\xa3\x99\x80\xacAO~\x87H\x80\x90\xae<t\xfd\xe1\x11\xb7\xd1 ... (566 characters truncated) ... r_code': None, 'long_running_tool_ids_json': None, 'partial': None, 'branch': None, 'interrupted': None, 'turn_complete': None, 'error_message': None}]]
Oh my friend
Now I confirm it work again. I did nothing change. It was down in range 9AM to 17:30PM
I am having the same issue "Object of type bytes is not JSON serializable". Did you have to do anything to fix this issue, or did it randomly started working again? I can not reproduce the problem locally, only once I deploy to Agent Engine on Vertex AI, is when this happens, and only with Gemini 2.5, and not other models!
can not reproduce the problem locally, only once I deploy to Agent Engine on Vertex A
Because, I'm guessing you're using 'adk web' command and there's no managed sessions here. When you deploy it, it uses managed sessions.
But Why managed Sessions Causes issue?
Since you're using 2.5 Models (All of em are reasoning)) , Recently, from gemini side, they did modification (not sure what), this made the model to reply with thinking signature in bytes.
Manages session expects a json
Temporary Fix :
Stop model to think / use different model / model provider
I found this thread because this started happening with my ADK agents today as well. {"content":{"parts":[{"thought_signature":"CpUCAcu98PDiQfIyH8Qj9nB2UX_OMAAoFNMn6C4jFrQH1hkbGeYhaD8W7vIkxIeI9vTeD-wBnJvNpekIX2icWWoBMrYmvojY9ujEdSJUN0QTaXPWzisz_ZP_uEChHwbloQnlLTTsBDmKaKthD9jouRui7E2iaJWVEGR1V9jQETD7jIhu1uF_dn6Cv-FeBypV38_kILv4Ciocl77DR4ZTx instead of: content":{"parts":[{"text":"Ah, hello there, friend! It's good to hear from you. How can I help you on your creative journey today?"}],Anyone have a fix?
Have the same issue time to time
I found this thread because this started happening with my ADK agents today as well. {"content":{"parts":[{"thought_signature":"CpUCAcu98PDiQfIyH8Qj9nB2UX_OMAAoFNMn6C4jFrQH1hkbGeYhaD8W7vIkxIeI9vTeD-wBnJvNpekIX2icWWoBMrYmvojY9ujEdSJUN0QTaXPWzisz_ZP_uEChHwbloQnlLTTsBDmKaKthD9jouRui7E2iaJWVEGR1V9jQETD7jIhu1uF_dn6Cv-FeBypV38_kILv4Ciocl77DR4ZTx instead of: content":{"parts":[{"text":"Ah, hello there, friend! It's good to hear from you. How can I help you on your creative journey today?"}],Anyone have a fix?
I am using gemini 2.5 pro and ADK version 1.21, you can try to ignore the issue
Have the same issue time to time
I am using gemini 2.5 pro and ADK version 1.21, you can try to ignore the issue
Ensure you're checking event.is_final_response() before accessing content. For safety:
if event.is_final_response() and hasattr(event, "content") and event.content: text = event.content.parts[0].text if event.content.parts else NoneAvoid
getattr;rely on direct attribute checks.My code work over a month and today is the first time I got that issue. So weird!!!!! I never see thought event response before.
The correct response I got before like this
Raw response:
{"candidates":[{"content":{"parts":[{"thought":true},{"text":"Hi! I'm AI Assistant Agent. How can I help you today??"}],"role":"model"},"finish_reason":"STOP","index":0}],"model_version":"models/gemini-2.5-pro-preview-05-06","usage_metadata":{"candidates_token_count":21,"prompt_token_count":1508,"prompt_tokens_details":[{"modality":"TEXT","token_count":1508}],"thoughts_token_count":549,"total_token_count":2078},"automatic_function_calling_history":[]}
i am facing this exact issue. if i check for this text existing, the model skips some in between agents and my whole system fails. I think this is a issue with SequentialAgent.
+1
Hi @momo-tuannguyen12 and thanks to everyone who participated in this thread.
We're currently doing some housekeeping on our issue tracker. Given the rapid pace of development and the number of updates since this was last active, there's a good chance this issue has been resolved in a newer version. To help us keep our backlog focused on current issues, we are closing this as stale.
If you're still facing this problem, could you please update to the very latest version of the library and confirm the issue still exists? If it does, please comment here, and we will be happy to reopen this issue and investigate further.
Thanks for your contribution and understanding!
I'm encountering a similar issue when handling agent responses that include non-text parts, specifically:
Code Warning: there are non-text parts in the response: ['thought_signature'], returning concatenated text result from text parts. Check the full candidates.content.parts accessor to get the full model response. This warning leads to the following error:
Code Error: 'NoneType' object has no attribute 'parts' ⚙️ Behavior Observed The agent sometimes returns a reasoning-style response that includes metadata like thought_signature, which isn't part of the standard text payload.
My current logic handle this structure properly, resulting in a blank response when non-text parts are detected. This allows the conversation to continue without breaking.
However, once the user sends another message, the agent resumes responding—often with another reasoning-style reply. This increases the frequency of the issue and makes it harder to manage consistently.
I have this issue with an agent that is used in Gemini Enterprise. "WARNING: Warning: there are non-text parts in the response: ['thought_signature'], returning concatenated text result from text parts. Check the full candidates.content.parts accessor to get the full model response." When inspecting the logs, I notice also asyncio errors are thrown; object not iterable...
When testing the agent in AgentEngine Playground everything seems fine.
Hi, @bluechipamsterdam. Based on my testing, the parts may contain the following:
Part(
text=""".....""",
thought=True
),
Therefore, if you directly extract the attribute containing text from parts, the model's reasoning will also be written into response_text. However, you can still extract the response and bypass that annoying warning using the following code.
response = chat_session.send_message(input_content)
response_text = ""
for part in response.candidates[0].content.parts:
if hasattr(part, 'text') and part.text and part.thought != True:
response_text += part.text