#!/usr/bin/env python3 """ Quick test to verify response cleaning works properly """ 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_response_cleaning(): """Test that responses are properly cleaned of LangChain metadata""" print("๐Ÿงช Testing response cleaning...") agent = Web3ResearchAgent() if not agent.enabled: print("โŒ Agent not enabled") return False try: print("๐Ÿ“Š Testing simple Bitcoin price query...") result = await agent.research_query("What is Bitcoin current price?", use_gemini=True) if result['success']: response_content = result['result'] print(f"โœ… Query successful!") print(f"๐Ÿ“ˆ Response type: {type(response_content)}") print(f"๐Ÿ“„ Response preview: {response_content[:200]}...") # Check if response contains LangChain metadata (bad) if "additional_kwargs" in str(response_content) or "response_metadata" in str(response_content): print("โŒ Response contains LangChain metadata - not properly cleaned") return False else: print("โœ… Response properly cleaned - no LangChain metadata found") 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_response_cleaning() if success: print("\n๐ŸŽ‰ Response cleaning test passed!") return 0 else: print("\nโŒ Response cleaning test failed!") return 1 if __name__ == "__main__": exit_code = asyncio.run(main()) sys.exit(exit_code)