| |
| """ |
| 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...") |
| |
| |
| 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}") |
| |
| |
| 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()) |