Skip to content

Commit 8654aed

Browse files
committed
Update test_agent.py
1 parent 4d598eb commit 8654aed

File tree

1 file changed

+13
-19
lines changed

1 file changed

+13
-19
lines changed

examples/tutorials/00_sync/010_multiturn/tests/test_agent.py

Lines changed: 13 additions & 19 deletions
Original file line numberDiff line numberDiff line change
@@ -41,12 +41,13 @@ def test_agent(agent_name: str):
4141
class TestNonStreamingMessages:
4242
"""Test non-streaming message sending."""
4343

44-
def test_send_simple_message(self, test_agent):
44+
def test_send_message(self, test_agent):
4545
messages = [
46-
"Hello, can you tell me a litle bit about tennis? I want to you make sure you use the word 'tennis' in each response.",
46+
"Hello, can you tell me a little bit about tennis? I want to you make sure you use the word 'tennis' in each response.",
4747
"Pick one of the things you just mentioned, and dive deeper into it.",
4848
"Can you now output a summary of this conversation",
4949
]
50+
5051
for i, msg in enumerate(messages):
5152
response = test_agent.send_message(msg)
5253

@@ -61,27 +62,20 @@ def test_send_simple_message(self, test_agent):
6162
assert len(message_history) == (i + 1) * 2 # user + agent messages
6263

6364

65+
class TestStreamingMessages:
66+
"""Test streaming message sending."""
6467

65-
def test_multiturn_conversation():
66-
"""Test multi-turn conversation with non-streaming messages."""
67-
with test_sync_agent(agent_name=AGENT_NAME) as test:
68-
69-
70-
71-
72-
73-
def test_multiturn_streaming():
74-
"""Test multi-turn conversation with streaming messages."""
75-
with test_sync_agent(agent_name=AGENT_NAME) as test:
68+
def test_stream_message(self, test_agent):
69+
"""Test streaming messages in a multi-turn conversation."""
7670
messages = [
77-
"Hello, can you tell me a litle bit about tennis? I want to you make sure you use the word 'tennis' in each response.",
71+
"Hello, can you tell me a little bit about tennis? I want you to make sure you use the word 'tennis' in each response.",
7872
"Pick one of the things you just mentioned, and dive deeper into it.",
7973
"Can you now output a summary of this conversation",
8074
]
8175

82-
for msg in messages:
76+
for i, msg in enumerate(messages):
8377
# Get streaming response
84-
response_gen = test.send_message_streaming(msg)
78+
response_gen = test_agent.send_message_streaming(msg)
8579

8680
# Collect streaming deltas
8781
aggregated_content, chunks = collect_streaming_deltas(response_gen)
@@ -93,9 +87,9 @@ def test_multiturn_streaming():
9387
# Validate that "tennis" appears in the response because that is what our model does
9488
assert "tennis" in aggregated_content.lower()
9589

96-
# Verify conversation history (only user messages tracked with streaming)
97-
history = test.get_conversation_history()
98-
assert len(history) >= 3, f"Expected >= 3 user messages, got {len(history)}"
90+
# Verify conversation history (only user messages tracked with streaming)
91+
history = test_agent.get_conversation_history()
92+
assert len(history) == (i + 1), f"Expected {(i + 1)} user messages, got {len(history)}"
9993

10094

10195
if __name__ == "__main__":

0 commit comments

Comments
 (0)