File size: 2,299 Bytes
b091b2c
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
#!/usr/bin/env python3
"""
Test the updated tool selection to ensure we use CryptoCompare/Etherscan instead of CoinGecko
"""

import asyncio
import sys
import os

# Add src to path
sys.path.insert(0, os.path.join(os.path.dirname(__file__), 'src'))

from src.agent.research_agent import Web3ResearchAgent

async def test_tool_selection():
    """Test that the system prioritizes CryptoCompare and Etherscan over CoinGecko"""
    print("πŸ§ͺ Testing tool selection...")
    
    agent = Web3ResearchAgent()
    
    if not agent.enabled:
        print("❌ Agent not enabled")
        return False
    
    # Check which tools are initialized
    tool_names = [tool.name for tool in agent.tools]
    print(f"πŸ› οΈ Available tools: {tool_names}")
    
    # Verify CoinGecko is not in tools (since no API key)
    if 'coingecko_data' in tool_names:
        print("⚠️ CoinGecko tool is still initialized - this may cause API failures")
    else:
        print("βœ… CoinGecko tool properly skipped (no API key)")
    
    # Verify we have the working tools
    expected_tools = ['cryptocompare_data', 'etherscan_data', 'defillama_data', 'chart_data_provider']
    working_tools = [tool for tool in expected_tools if tool in tool_names]
    print(f"βœ… Working tools available: {working_tools}")
    
    # Test a simple query
    try:
        print("\nπŸ“Š Testing Bitcoin price query...")
        result = await agent.research_query("Analyze Bitcoin price trends", use_gemini=True)
        
        if result['success']:
            print("βœ… Query successful!")
            print(f"πŸ“ˆ Result preview: {result['result'][:200]}...")
            print(f"πŸ”§ Tools used: {result.get('metadata', {}).get('tools_used', 'N/A')}")
            return True
        else:
            print(f"❌ Query failed: {result.get('error', 'Unknown error')}")
            return False
            
    except Exception as e:
        print(f"❌ Test failed with exception: {e}")
        return False

async def main():
    success = await test_tool_selection()
    if success:
        print("\nπŸŽ‰ Tool selection test passed!")
        return 0
    else:
        print("\n❌ Tool selection test failed!")
        return 1

if __name__ == "__main__":
    exit_code = asyncio.run(main())
    sys.exit(exit_code)