Skip to content

Commit 476e5e9

Browse files
authored
Stop yielding the accumulated final response (#986)
The agent samples yield the accumulated final response after sending all streaming chunks, which is duplicate. It now cleanly yields `{"is_task_complete": True, "parts": []}`.
1 parent ff00602 commit 476e5e9

File tree

2 files changed

+7
-15
lines changed

2 files changed

+7
-15
lines changed

samples/agent/adk/contact_lookup/agent.py

Lines changed: 4 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -42,11 +42,10 @@
4242
from tools import get_contact_info
4343
from a2ui.core.schema.constants import VERSION_0_8, VERSION_0_9, A2UI_OPEN_TAG, A2UI_CLOSE_TAG
4444
from a2ui.core.schema.manager import A2uiSchemaManager
45-
from a2ui.core.parser.parser import parse_response, ResponsePart
45+
from a2ui.core.parser.parser import parse_response
4646
from a2ui.basic_catalog.provider import BasicCatalog
4747
from a2ui.a2a import (
4848
get_a2ui_agent_extension,
49-
parse_response_to_parts,
5049
stream_response_to_parts,
5150
)
5251

@@ -358,16 +357,13 @@ async def token_stream():
358357

359358
if is_valid:
360359
logger.info(
361-
"--- ContactAgent.stream: Response is valid. Sending final response"
362-
f" (Attempt {attempt}). ---"
363-
)
364-
final_parts = parse_response_to_parts(
365-
final_response_content, fallback_text="OK."
360+
"--- ContactAgent.stream: Response is valid. Task complete (Attempt"
361+
f" {attempt}). ---"
366362
)
367363

368364
yield {
369365
"is_task_complete": True,
370-
"parts": final_parts,
366+
"parts": [],
371367
}
372368
return # We're done, exit the generator
373369

samples/agent/adk/restaurant_finder/agent.py

Lines changed: 3 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -43,12 +43,11 @@
4343
from tools import get_restaurants
4444
from a2ui.core.schema.constants import VERSION_0_8, VERSION_0_9, A2UI_OPEN_TAG, A2UI_CLOSE_TAG
4545
from a2ui.core.schema.manager import A2uiSchemaManager
46-
from a2ui.core.parser.parser import parse_response, ResponsePart
46+
from a2ui.core.parser.parser import parse_response
4747
from a2ui.basic_catalog.provider import BasicCatalog
4848
from a2ui.core.schema.common_modifiers import remove_strict_validation
4949
from a2ui.a2a import (
5050
get_a2ui_agent_extension,
51-
parse_response_to_parts,
5251
stream_response_to_parts,
5352
)
5453

@@ -327,16 +326,13 @@ async def token_stream():
327326

328327
if is_valid:
329328
logger.info(
330-
"--- RestaurantAgent.stream: Response is valid. Sending final response"
329+
"--- RestaurantAgent.stream: Response is valid. Task complete"
331330
f" (Attempt {attempt}). ---"
332331
)
333-
final_parts = parse_response_to_parts(
334-
final_response_content, fallback_text="OK."
335-
)
336332

337333
yield {
338334
"is_task_complete": True,
339-
"parts": final_parts,
335+
"parts": [],
340336
}
341337
return # We're done, exit the generator
342338

0 commit comments

Comments
 (0)