Skip to content

Commit 93b17bd

Browse files
committed
[BUG-FIX] Test Update for build_agent -> build_llm_agent
1 parent e5c2960 commit 93b17bd

1 file changed

Lines changed: 24 additions & 11 deletions

File tree

tests/structs/test_auto_swarms_builder.py

Lines changed: 24 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -41,21 +41,27 @@ def test_initialization():
4141

4242

4343
def test_agent_building():
44-
"""Test building individual agents"""
44+
"""Test building individual agents from specs"""
4545
print_separator()
4646
print("Testing Agent Building")
4747
try:
4848
swarm = AutoSwarmBuilder()
49-
agent = swarm.build_agent(
50-
agent_name="TestAgent",
51-
agent_description="A test agent",
52-
agent_system_prompt="You are a test agent",
53-
max_loops=1,
54-
)
49+
specs = {
50+
"agents": [
51+
{
52+
"agent_name": "TestAgent",
53+
"description": "A test agent",
54+
"system_prompt": "You are a test agent",
55+
"max_loops": 1,
56+
}
57+
]
58+
}
59+
agents = swarm.create_agents_from_specs(specs)
60+
agent = agents[0]
5561

5662
print("✓ Built agent with configuration:")
5763
print(f" - Name: {agent.agent_name}")
58-
print(f" - Description: {agent.description}")
64+
print(f" - Description: {agent.agent_description}")
5965
print(f" - Max loops: {agent.max_loops}")
6066
print("✓ Agent building test passed")
6167
return agent
@@ -69,18 +75,25 @@ def test_agent_creation():
6975
print_separator()
7076
print("Testing Agent Creation from Task")
7177
try:
78+
import json
79+
7280
swarm = AutoSwarmBuilder(
7381
name="ResearchSwarm",
7482
description="A swarm for research tasks",
7583
)
7684
task = "Research the latest developments in quantum computing"
77-
agents = swarm._create_agents(task)
85+
# create_agents returns a JSON string
86+
agent_specs_json = swarm.create_agents(task)
87+
# Parse JSON string to dict
88+
agent_specs = json.loads(agent_specs_json)
89+
# Convert specs to actual Agent objects
90+
agents = swarm.create_agents_from_specs(agent_specs)
7891

7992
print("✓ Created agents for research task:")
8093
for i, agent in enumerate(agents, 1):
8194
print(f" Agent {i}:")
8295
print(f" - Name: {agent.agent_name}")
83-
print(f" - Description: {agent.description}")
96+
print(f" - Description: {agent.agent_description}")
8497
print(f"✓ Created {len(agents)} agents successfully")
8598
return agents
8699
except Exception as e:
@@ -155,7 +168,7 @@ def test_error_handling():
155168
# Test with invalid agent configuration
156169
print("Testing invalid agent configuration...")
157170
try:
158-
swarm.build_agent("", "", "")
171+
swarm.create_agents_from_specs({"agents": [{"agent_name": ""}]})
159172
print(
160173
"✗ Should have raised an error for empty agent configuration"
161174
)

0 commit comments

Comments
 (0)