@@ -120,6 +120,17 @@ def _get_and_refresh_token(self) -> str:
120120 return token_val
121121
122122
123+ def _is_iterable (obj : Any ) -> bool :
124+ """Safely checks if an object is iterable, excluding strings and bytes."""
125+ if isinstance (obj , (str , bytes )):
126+ return False
127+ try :
128+ iter (obj )
129+ return True
130+ except TypeError :
131+ return False
132+
133+
123134def _extract_message_text (msg : Any ) -> str :
124135 """Extracts agent message text from a single Message object."""
125136 if getattr (msg , "role" , None ) != pb .ROLE_AGENT :
@@ -141,51 +152,49 @@ def _extract_message_text(msg: Any) -> str:
141152
142153
143154def _find_agent_text_recursive (obj : Any ) -> str :
144- """Recursively searches obj to find the first valid agent text."""
145- text = _extract_message_text (obj )
146- if text :
147- return text
155+ """Recursively searches obj to find and accumulate agent texts."""
156+ texts = []
157+
158+ self_text = _extract_message_text (obj )
159+ if self_text :
160+ texts .append (self_text )
148161
149162 # 1. Handle dict-like mappings by traversing their values
150163 if isinstance (obj , collections .abc .Mapping ):
151164 for val in obj .values ():
152165 text = _find_agent_text_recursive (val )
153166 if text :
154- return text
167+ texts .append (text )
168+ return "\n \n " .join (texts )
155169
156170 # 2. Handle iterables (exclude string/bytes)
157- is_iterable = False
158- if not isinstance (obj , (str , bytes )):
159- try :
160- iter (obj )
161- is_iterable = True
162- except TypeError as e :
163- logger .info ("Object is not iterable: %s" , e )
164-
165- if is_iterable :
171+ if _is_iterable (obj ):
166172 for item in obj :
167173 text = _find_agent_text_recursive (item )
168174 if text :
169- return text
175+ texts .append (text )
176+ return "\n \n " .join (texts )
170177
171178 # 3. Handle standard Protobuf Messages via ListFields
172179 elif hasattr (obj , "ListFields" ):
173180 try :
174181 for field_desc , field_value in obj .ListFields ():
175182 text = _find_agent_text_recursive (field_value )
176183 if text :
177- return text
184+ texts . append ( text )
178185 except Exception :
179186 pass
187+ return "\n \n " .join (texts )
180188
181189 # 4. Fallback for other standard objects
182190 elif hasattr (obj , "__dict__" ):
183191 for val in obj .__dict__ .values ():
184192 text = _find_agent_text_recursive (val )
185193 if text :
186- return text
194+ texts .append (text )
195+ return "\n \n " .join (texts )
187196
188- return ""
197+ return "\n \n " . join ( texts )
189198
190199
191200class DataEngineeringAgentGenerator (QueryGenerator ):
@@ -336,7 +345,7 @@ async def _run_client(
336345 message_req .metadata [CONVERSATION_TOKEN_URI ] = token
337346
338347 context = ClientCallContext (
339- timeout = 180 .0 ,
348+ timeout = 300 .0 ,
340349 service_parameters = {
341350 "A2A-Extensions" : ALL_EXTENSIONS
342351 }
0 commit comments