diff --git a/examples/tutorials/10_async/10_temporal/070_open_ai_agents_sdk_tools/tests/test_agent.py b/examples/tutorials/10_async/10_temporal/070_open_ai_agents_sdk_tools/tests/test_agent.py index 8bf59cafc..091434cbe 100644 --- a/examples/tutorials/10_async/10_temporal/070_open_ai_agents_sdk_tools/tests/test_agent.py +++ b/examples/tutorials/10_async/10_temporal/070_open_ai_agents_sdk_tools/tests/test_agent.py @@ -118,9 +118,12 @@ async def test_send_event_and_poll(self, client: AsyncAgentex, agent_id: str): content_length = len(str(agent_text)) final_message = message - # Stop when we get DONE status + # Stop when we get DONE with content. If the agent invoked a tool, keep polling + # until tool_response is visible: the final text can be marked DONE before the + # lifecycle activity persists tool_response to the message list. if message.streaming_status == "DONE" and content_length > 0: - break + if not seen_tool_request or seen_tool_response: + break # Verify we got all the expected pieces assert seen_tool_request, "Expected to see tool_request message (agent calling get_weather)" diff --git a/examples/tutorials/10_async/10_temporal/080_open_ai_agents_sdk_human_in_the_loop/tests/test_agent.py b/examples/tutorials/10_async/10_temporal/080_open_ai_agents_sdk_human_in_the_loop/tests/test_agent.py index 3377c1ea8..ca0b129bc 100644 --- a/examples/tutorials/10_async/10_temporal/080_open_ai_agents_sdk_human_in_the_loop/tests/test_agent.py +++ b/examples/tutorials/10_async/10_temporal/080_open_ai_agents_sdk_human_in_the_loop/tests/test_agent.py @@ -148,10 +148,13 @@ async def test_send_event_and_poll_with_human_approval(self, client: AsyncAgente if message.content and message.content.type == "text" and message.content.author == "agent": content_length = len(message.content.content) if message.content.content else 0 - # Stop when we get DONE status with actual content + # Stop when we get DONE with content. If the agent invoked a tool, keep polling + # until tool_response is visible: final text can be marked DONE before the + # lifecycle activity persists tool_response to the message list. if message.streaming_status == "DONE" and content_length > 0: found_final_response = True - break + if not seen_tool_request or seen_tool_response: + break # Verify that we saw the complete flow: tool_request -> human approval -> tool_response -> final answer assert seen_tool_request, "Expected to see tool_request message (agent calling wait_for_confirmation)"