@@ -1077,7 +1077,10 @@ async def _run_adk_in_background(
10771077 self ._session_manager .mark_messages_processed (app_name , input .thread_id , message_ids )
10781078
10791079 # Convert user messages first (if any)
1080- user_message = await self ._convert_latest_message (input , unseen_messages ) if message_batch else None
1080+ # Note: We pass unseen_messages which is already set from message_batch or _get_unseen_messages
1081+ # The original code had a bug: `if message_batch else None` would skip conversion when
1082+ # message_batch was None but unseen_messages contained valid user messages
1083+ user_message = await self ._convert_latest_message (input , unseen_messages )
10811084
10821085 # if there is a tool response submission by the user, add FunctionResponse to session first
10831086 if active_tool_results and user_message :
@@ -1185,6 +1188,10 @@ async def _run_adk_in_background(
11851188 new_message = types .Content (parts = function_response_parts , role = 'user' )
11861189 else :
11871190 # No tool results, just use the user message
1191+ # If user_message is None (e.g., unseen_messages was empty because all were
1192+ # already processed), fall back to extracting the latest user message from input.messages
1193+ if user_message is None and input .messages :
1194+ user_message = await self ._convert_latest_message (input , input .messages )
11881195 new_message = user_message
11891196
11901197 # Create event translator
0 commit comments