@@ -20,37 +20,50 @@ def test_toolset_basic():
2020 )
2121 print ("✓ Successfully imported toolset functions" )
2222
23- # Test registering a custom toolset
24- register_toolset (
25- "test_toolset" ,
26- tools = ["tool1" , "tool2" ],
27- description = "Test toolset"
28- )
29- print ("✓ Successfully registered custom toolset" )
30-
31- # Test resolving the toolset
32- tools = resolve_toolset ("test_toolset" )
33- assert tools == ["tool1" , "tool2" ]
34- print ("✓ Successfully resolved toolset" )
35-
36- # Test listing toolsets (should include prebuilt ones)
37- toolset_list = list_toolsets ()
38- assert "test_toolset" in toolset_list
39- assert "web" in toolset_list
40- assert "research" in toolset_list
41- print (f"✓ Found { len (toolset_list )} toolsets: { toolset_list } " )
42-
43- # Test composition via includes
44- register_toolset (
45- "composed_test" ,
46- tools = ["tool3" ],
47- includes = ["test_toolset" ]
48- )
49- composed_tools = resolve_toolset ("composed_test" )
50- assert "tool1" in composed_tools
51- assert "tool2" in composed_tools
52- assert "tool3" in composed_tools
53- print ("✓ Successfully tested toolset composition" )
23+ # Test registering a custom toolset with unique names to avoid pollution
24+ import uuid
25+ test_toolset_name = f"test_toolset_{ uuid .uuid4 ().hex [:8 ]} "
26+ composed_toolset_name = f"composed_test_{ uuid .uuid4 ().hex [:8 ]} "
27+
28+ try :
29+ register_toolset (
30+ test_toolset_name ,
31+ tools = ["tool1" , "tool2" ],
32+ description = "Test toolset"
33+ )
34+ print ("✓ Successfully registered custom toolset" )
35+
36+ # Test resolving the toolset
37+ tools = resolve_toolset (test_toolset_name )
38+ assert tools == ["tool1" , "tool2" ]
39+ print ("✓ Successfully resolved toolset" )
40+
41+ # Test listing toolsets (should include prebuilt ones)
42+ toolset_list = list_toolsets ()
43+ assert test_toolset_name in toolset_list
44+ assert "web" in toolset_list
45+ assert "research" in toolset_list
46+ print (f"✓ Found { len (toolset_list )} toolsets: { toolset_list } " )
47+
48+ # Test composition via includes
49+ register_toolset (
50+ composed_toolset_name ,
51+ tools = ["tool3" ],
52+ includes = [test_toolset_name ]
53+ )
54+ composed_tools = resolve_toolset (composed_toolset_name )
55+ assert "tool1" in composed_tools
56+ assert "tool2" in composed_tools
57+ assert "tool3" in composed_tools
58+ print ("✓ Successfully tested toolset composition" )
59+ finally :
60+ # Cleanup to avoid registry pollution
61+ from praisonaiagents .toolsets import unregister_toolset
62+ try :
63+ unregister_toolset (composed_toolset_name )
64+ unregister_toolset (test_toolset_name )
65+ except Exception :
66+ pass
5467
5568 print ("All basic toolset tests passed!\n " )
5669 return True
@@ -95,6 +108,11 @@ def test_agent_integration():
95108
96109 print (f"✓ Agent has { len (agent .tools )} tools: { tool_names } " )
97110
111+ # Verify expected tools are present
112+ assert "internet_search" in tool_names , f"internet_search was not resolved from toolset. Available: { tool_names } "
113+ assert "read_file" in tool_names , f"read_file was not resolved from toolset. Available: { tool_names } "
114+ print ("✓ Verified expected tools are present" )
115+
98116 # Test mixing tools and toolsets
99117 agent2 = Agent (
100118 name = "test_agent2" ,
@@ -104,6 +122,18 @@ def test_agent_integration():
104122 )
105123 print ("✓ Successfully created Agent with both tools and toolsets" )
106124
125+ # Check tools in agent2
126+ tool_names2 = []
127+ for tool in agent2 .tools :
128+ if hasattr (tool , '__name__' ):
129+ tool_names2 .append (tool .__name__ )
130+ elif hasattr (tool , 'name' ):
131+ tool_names2 .append (tool .name )
132+
133+ assert "write_file" in tool_names2 , f"explicit tool write_file missing. Available: { tool_names2 } "
134+ assert "internet_search" in tool_names2 , f"toolset tool internet_search missing. Available: { tool_names2 } "
135+ print ("✓ Verified mixed tools and toolsets work correctly" )
136+
107137 print ("All agent integration tests passed!\n " )
108138 return True
109139
0 commit comments