Skip to content

Commit 8a82cbc

Browse files
authored
Merge pull request #1225 from Steve-Dusty/master
added ire test
2 parents 31e3043 + c2ae1ec commit 8a82cbc

1 file changed

Lines changed: 86 additions & 0 deletions

File tree

tests/structs/test_i_agent.py

Lines changed: 86 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,86 @@
1+
import pytest
2+
3+
from swarms.agents.i_agent import IterativeReflectiveExpansion
4+
5+
6+
def test_ire_agent_initialization():
7+
"""Test IRE agent initialization with default parameters"""
8+
agent = IterativeReflectiveExpansion()
9+
10+
assert agent is not None
11+
assert agent.agent_name == "General-Reasoning-Agent"
12+
assert agent.max_iterations == 5
13+
assert agent.output_type == "dict"
14+
assert agent.agent is not None
15+
16+
17+
def test_ire_agent_custom_initialization():
18+
"""Test IRE agent initialization with custom parameters"""
19+
agent = IterativeReflectiveExpansion(
20+
agent_name="Custom-IRE-Agent",
21+
description="A custom reasoning agent",
22+
max_iterations=3,
23+
model_name="gpt-4o",
24+
output_type="string",
25+
)
26+
27+
assert agent.agent_name == "Custom-IRE-Agent"
28+
assert agent.description == "A custom reasoning agent"
29+
assert agent.max_iterations == 3
30+
assert agent.output_type == "string"
31+
32+
33+
def test_ire_agent_execution():
34+
"""Test IRE agent execution with a simple problem"""
35+
agent = IterativeReflectiveExpansion(
36+
agent_name="Test-IRE-Agent",
37+
model_name="gpt-4o",
38+
max_iterations=2,
39+
output_type="dict",
40+
)
41+
42+
# Test with a simple reasoning task
43+
task = "What are three main benefits of renewable energy?"
44+
result = agent.run(task)
45+
46+
# Result should not be None
47+
assert result is not None
48+
# Result should be dict or string based on output_type
49+
assert isinstance(result, (str, dict))
50+
51+
52+
def test_ire_agent_generate_hypotheses():
53+
"""Test IRE agent hypothesis generation"""
54+
agent = IterativeReflectiveExpansion(
55+
agent_name="Hypothesis-Test-Agent",
56+
max_iterations=1,
57+
)
58+
59+
task = "How can we reduce carbon emissions?"
60+
hypotheses = agent.generate_initial_hypotheses(task)
61+
62+
assert hypotheses is not None
63+
assert isinstance(hypotheses, list)
64+
assert len(hypotheses) > 0
65+
66+
67+
def test_ire_agent_workflow():
68+
"""Test complete IRE agent workflow with iterative refinement"""
69+
agent = IterativeReflectiveExpansion(
70+
agent_name="Workflow-Test-Agent",
71+
description="Agent for testing complete workflow",
72+
model_name="gpt-4o",
73+
max_iterations=2,
74+
output_type="dict",
75+
)
76+
77+
# Test with a problem that requires iterative refinement
78+
task = "Design an efficient public transportation system for a small city"
79+
result = agent.run(task)
80+
81+
# Verify the result is valid
82+
assert result is not None
83+
assert isinstance(result, (str, dict))
84+
85+
# Check that conversation was populated during execution
86+
assert agent.conversation is not None

0 commit comments

Comments
 (0)