@@ -41,12 +41,13 @@ def test_agent(agent_name: str):
4141class 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
10195if __name__ == "__main__" :
0 commit comments