Skip to content

Commit 4d598eb

Browse files
committed
.
1 parent 97811c3 commit 4d598eb

File tree

4 files changed

+130
-182
lines changed

4 files changed

+130
-182
lines changed

examples/tutorials/00_sync/000_hello_acp/tests/test_agent.py

Lines changed: 2 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -39,7 +39,7 @@ def test_agent(agent_name: str):
3939

4040

4141
class TestNonStreamingMessages:
42-
"""Tests for non-streaming message sending."""
42+
"""Test non-streaming message sending."""
4343

4444
def test_send_simple_message(self, test_agent):
4545
"""Test sending a simple message and receiving a response."""
@@ -54,8 +54,7 @@ def test_send_simple_message(self, test_agent):
5454
assert response.content == expected, f"Expected: {expected}\nGot: {response.content}"
5555

5656
class TestStreamingMessages:
57-
"""Tests for streaming message sending."""
58-
57+
"""Test streaming message sending."""
5958

6059
def test_stream_simple_message(self, test_agent):
6160
"""Test streaming a simple message and aggregating deltas."""

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

Lines changed: 31 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -16,37 +16,58 @@
1616
pytest tests/test_agent.py -v
1717
"""
1818

19+
import pytest
20+
1921
from agentex.lib.testing import (
2022
test_sync_agent,
2123
collect_streaming_deltas,
2224
assert_valid_agent_response,
23-
assert_conversation_maintains_context
2425
)
2526

2627
AGENT_NAME = "s010-multiturn"
2728

29+
@pytest.fixture
30+
def agent_name():
31+
"""Return the agent name for testing."""
32+
return AGENT_NAME
2833

29-
def test_multiturn_conversation():
30-
"""Test multi-turn conversation with non-streaming messages."""
31-
with test_sync_agent(agent_name=AGENT_NAME) as test:
34+
@pytest.fixture
35+
def test_agent(agent_name: str):
36+
"""Fixture to create a test sync agent."""
37+
with test_sync_agent(agent_name=agent_name) as test:
38+
yield test
39+
40+
41+
class TestNonStreamingMessages:
42+
"""Test non-streaming message sending."""
43+
44+
def test_send_simple_message(self, test_agent):
3245
messages = [
3346
"Hello, can you tell me a litle bit about tennis? I want to you make sure you use the word 'tennis' in each response.",
3447
"Pick one of the things you just mentioned, and dive deeper into it.",
3548
"Can you now output a summary of this conversation",
3649
]
37-
38-
for msg in messages:
39-
response = test.send_message(msg)
50+
for i, msg in enumerate(messages):
51+
response = test_agent.send_message(msg)
4052

4153
# Validate response (agent may require OpenAI key)
4254
assert_valid_agent_response(response)
4355

4456
# Validate that "tennis" appears in the response because that is what our model does
4557
assert "tennis" in response.content.lower()
4658

47-
# Verify conversation history
48-
history = test.get_conversation_history()
49-
assert len(history) >= 6, f"Expected >= 6 messages (3 user + 3 agent), got {len(history)}"
59+
# Verify conversation history
60+
message_history = test_agent.get_conversation_history()
61+
assert len(message_history) == (i + 1) * 2 # user + agent messages
62+
63+
64+
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+
5071

5172

5273
def test_multiturn_streaming():

0 commit comments

Comments
 (0)