#!/usr/bin/env python3 """ ๐Ÿ” GAIA Agent Diagnostic Test Quick test to diagnose why the agent isn't answering questions """ import os import sys from gaia_system import BasicAgent, EnhancedMultiModelGAIASystem def test_basic_agent(): """Test the BasicAgent with simple questions""" print("๐Ÿงช Testing BasicAgent...") try: # Initialize agent agent = BasicAgent() print("โœ… Agent initialized successfully") # Test simple questions test_questions = [ "What is 2 + 2?", "What is the capital of France?", "How many days are in a week?", "What color is the sky?" ] for i, question in enumerate(test_questions, 1): print(f"\n๐Ÿ“ Test {i}: {question}") try: response = agent(question) print(f"๐Ÿค– Response: '{response}'") print(f"๐Ÿ“ Length: {len(response)} characters") if not response or response.strip() == "": print("โŒ Empty response!") elif "Unable to" in response or "Error" in response: print("โš ๏ธ Error response detected") else: print("โœ… Got non-empty response") except Exception as e: print(f"โŒ Error: {e}") except Exception as e: print(f"โŒ Failed to initialize agent: {e}") return False return True def test_enhanced_system(): """Test the EnhancedMultiModelGAIASystem directly""" print("\n๐Ÿงช Testing EnhancedMultiModelGAIASystem...") try: # Test with HF token if available hf_token = os.getenv('HF_TOKEN') if hf_token: print(f"โœ… Found HF_TOKEN: {hf_token[:10]}...") else: print("โš ๏ธ No HF_TOKEN found - using fallback mode") system = EnhancedMultiModelGAIASystem(hf_token=hf_token) print("โœ… Enhanced system initialized") # Test simple query question = "What is 5 + 3?" print(f"\n๐Ÿ“ Testing: {question}") response = system.query_with_tools(question) print(f"๐Ÿค– Raw response: '{response}'") # Test fallback fallback = system._fallback_response(question) print(f"๐Ÿ›ก๏ธ Fallback response: '{fallback}'") # Test answer extraction if response: extracted = system._extract_final_answer(response) print(f"โœจ Extracted answer: '{extracted}'") return True except Exception as e: print(f"โŒ Enhanced system error: {e}") import traceback traceback.print_exc() return False def test_model_availability(): """Test which AI models are available""" print("\n๐Ÿ” Testing model availability...") try: system = EnhancedMultiModelGAIASystem() print(f"๐Ÿ“Š Available models: {len(system.clients)}") for name, client_info in system.clients.items(): provider = client_info.get('provider', 'Unknown') priority = client_info.get('priority', 999) print(f" - {name} (Priority: {priority}, Provider: {provider})") if system.model_priority: print(f"๐ŸŽฏ Top priority model: {system.model_priority[0]}") else: print("โŒ No models in priority list!") return True except Exception as e: print(f"โŒ Model availability error: {e}") return False def main(): """Run all diagnostic tests""" print("๐Ÿš€ GAIA Agent Diagnostic Tests\n") # Test basic functionality test1 = test_basic_agent() test2 = test_enhanced_system() test3 = test_model_availability() print("\n๐Ÿ“Š Test Summary:") print(f" BasicAgent: {'โœ… PASS' if test1 else 'โŒ FAIL'}") print(f" Enhanced System: {'โœ… PASS' if test2 else 'โŒ FAIL'}") print(f" Model Availability: {'โœ… PASS' if test3 else 'โŒ FAIL'}") if not any([test1, test2, test3]): print("\nโŒ All tests failed! Check dependencies and configuration.") return False elif not test1: print("\nโš ๏ธ BasicAgent failed - this is the issue for GAIA submissions!") return False else: print("\nโœ… Core functionality working - issue might be elsewhere") return True if __name__ == "__main__": success = main() sys.exit(0 if success else 1)