File size: 1,527 Bytes
9126c2d |
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 |
#!/usr/bin/env python3
"""
Test script to verify that the deduplication mechanism works correctly.
"""
import asyncio
import sys
import os
sys.path.append(os.path.dirname(__file__))
from tools.tavily_search_tool import search_web, _should_execute_call
async def test_deduplication():
"""Test that duplicate tool calls are properly detected and prevented."""
print("Testing deduplication mechanism...")
# Test 1: Same query should be deduplicated
print("\n1. Testing search_web deduplication:")
query = "test query for deduplication"
print(f"First call with query: '{query}'")
result1 = await search_web(query)
print(f"Result: {result1[:100]}...")
print(f"Second call with same query: '{query}'")
result2 = await search_web(query)
print(f"Result: {result2}")
# Test 2: Direct deduplication function
print("\n2. Testing _should_execute_call function:")
should_execute_1 = _should_execute_call("test_tool", arg1="value1", arg2="value2")
print(f"First call should execute: {should_execute_1}")
should_execute_2 = _should_execute_call("test_tool", arg1="value1", arg2="value2")
print(f"Second call should execute: {should_execute_2}")
should_execute_3 = _should_execute_call("test_tool", arg1="value1", arg2="different_value")
print(f"Third call with different args should execute: {should_execute_3}")
print("\n✅ Deduplication test completed!")
if __name__ == "__main__":
asyncio.run(test_deduplication()) |