Skip to content

Commit ca79ab1

Browse files
committed
fix(test): waiting for tool activity response before assessing tests
1 parent f1e5d4c commit ca79ab1

2 files changed

Lines changed: 10 additions & 4 deletions

File tree

  • examples/tutorials/10_async/10_temporal

examples/tutorials/10_async/10_temporal/070_open_ai_agents_sdk_tools/tests/test_agent.py

Lines changed: 5 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -118,9 +118,12 @@ async def test_send_event_and_poll(self, client: AsyncAgentex, agent_id: str):
118118
content_length = len(str(agent_text))
119119
final_message = message
120120

121-
# Stop when we get DONE status
121+
# Stop when we get DONE with content. If the agent invoked a tool, keep polling
122+
# until tool_response is visible: the final text can be marked DONE before the
123+
# lifecycle activity persists tool_response to the message list.
122124
if message.streaming_status == "DONE" and content_length > 0:
123-
break
125+
if not seen_tool_request or seen_tool_response:
126+
break
124127

125128
# Verify we got all the expected pieces
126129
assert seen_tool_request, "Expected to see tool_request message (agent calling get_weather)"

examples/tutorials/10_async/10_temporal/080_open_ai_agents_sdk_human_in_the_loop/tests/test_agent.py

Lines changed: 5 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -148,10 +148,13 @@ async def test_send_event_and_poll_with_human_approval(self, client: AsyncAgente
148148
if message.content and message.content.type == "text" and message.content.author == "agent":
149149
content_length = len(message.content.content) if message.content.content else 0
150150

151-
# Stop when we get DONE status with actual content
151+
# Stop when we get DONE with content. If the agent invoked a tool, keep polling
152+
# until tool_response is visible: final text can be marked DONE before the
153+
# lifecycle activity persists tool_response to the message list.
152154
if message.streaming_status == "DONE" and content_length > 0:
153155
found_final_response = True
154-
break
156+
if not seen_tool_request or seen_tool_response:
157+
break
155158

156159
# Verify that we saw the complete flow: tool_request -> human approval -> tool_response -> final answer
157160
assert seen_tool_request, "Expected to see tool_request message (agent calling wait_for_confirmation)"

0 commit comments

Comments
 (0)