diff --git a/samples/agent/adk/contact_lookup/agent.py b/samples/agent/adk/contact_lookup/agent.py index aa8f0367d..a68c020b4 100644 --- a/samples/agent/adk/contact_lookup/agent.py +++ b/samples/agent/adk/contact_lookup/agent.py @@ -42,10 +42,11 @@ from tools import get_contact_info from a2ui.core.schema.constants import VERSION_0_8, VERSION_0_9, A2UI_OPEN_TAG, A2UI_CLOSE_TAG from a2ui.core.schema.manager import A2uiSchemaManager -from a2ui.core.parser.parser import parse_response +from a2ui.core.parser.parser import parse_response, ResponsePart from a2ui.basic_catalog.provider import BasicCatalog from a2ui.a2a import ( get_a2ui_agent_extension, + parse_response_to_parts, stream_response_to_parts, ) @@ -357,13 +358,16 @@ async def token_stream(): if is_valid: logger.info( - "--- ContactAgent.stream: Response is valid. Task complete (Attempt" - f" {attempt}). ---" + "--- ContactAgent.stream: Response is valid. Sending final response" + f" (Attempt {attempt}). ---" + ) + final_parts = parse_response_to_parts( + final_response_content, fallback_text="OK." ) yield { "is_task_complete": True, - "parts": [], + "parts": final_parts, } return # We're done, exit the generator diff --git a/samples/agent/adk/restaurant_finder/agent.py b/samples/agent/adk/restaurant_finder/agent.py index 1a9b70e57..7b6b2d45b 100644 --- a/samples/agent/adk/restaurant_finder/agent.py +++ b/samples/agent/adk/restaurant_finder/agent.py @@ -43,11 +43,12 @@ from tools import get_restaurants from a2ui.core.schema.constants import VERSION_0_8, VERSION_0_9, A2UI_OPEN_TAG, A2UI_CLOSE_TAG from a2ui.core.schema.manager import A2uiSchemaManager -from a2ui.core.parser.parser import parse_response +from a2ui.core.parser.parser import parse_response, ResponsePart from a2ui.basic_catalog.provider import BasicCatalog from a2ui.core.schema.common_modifiers import remove_strict_validation from a2ui.a2a import ( get_a2ui_agent_extension, + parse_response_to_parts, stream_response_to_parts, ) @@ -326,13 +327,16 @@ async def token_stream(): if is_valid: logger.info( - "--- RestaurantAgent.stream: Response is valid. Task complete" + "--- RestaurantAgent.stream: Response is valid. Sending final response" f" (Attempt {attempt}). ---" ) + final_parts = parse_response_to_parts( + final_response_content, fallback_text="OK." + ) yield { "is_task_complete": True, - "parts": [], + "parts": final_parts, } return # We're done, exit the generator