From a0e0b9ba8614d09411c8f4790d09034ccc8e034f Mon Sep 17 00:00:00 2001 From: Andrew Brookins Date: Fri, 3 Oct 2025 10:11:35 -0700 Subject: [PATCH] Change optimize_query default to False in client Reduces unnecessary LLM calls for query optimization by defaulting to False. Users can still explicitly enable optimization when needed. --- .../agent_memory_client/__init__.py | 2 +- .../agent_memory_client/client.py | 2 +- tests/test_client_api.py | 22 +++++++++---------- 3 files changed, 13 insertions(+), 13 deletions(-) diff --git a/agent-memory-client/agent_memory_client/__init__.py b/agent-memory-client/agent_memory_client/__init__.py index b8c274c..5b0274d 100644 --- a/agent-memory-client/agent_memory_client/__init__.py +++ b/agent-memory-client/agent_memory_client/__init__.py @@ -5,7 +5,7 @@ memory management capabilities for AI agents and applications. """ -__version__ = "0.12.5" +__version__ = "0.12.6" from .client import MemoryAPIClient, MemoryClientConfig, create_memory_client from .exceptions import ( diff --git a/agent-memory-client/agent_memory_client/client.py b/agent-memory-client/agent_memory_client/client.py index c10f316..c560f99 100644 --- a/agent-memory-client/agent_memory_client/client.py +++ b/agent-memory-client/agent_memory_client/client.py @@ -764,7 +764,7 @@ async def search_long_term_memory( recency: RecencyConfig | None = None, limit: int = 10, offset: int = 0, - optimize_query: bool = True, + optimize_query: bool = False, ) -> MemoryRecordResults: """ Search long-term memories using semantic search and filters. diff --git a/tests/test_client_api.py b/tests/test_client_api.py index e6621f0..b5a337d 100644 --- a/tests/test_client_api.py +++ b/tests/test_client_api.py @@ -499,10 +499,10 @@ async def test_memory_prompt_integration(memory_test_client: MemoryAPIClient): @pytest.mark.asyncio -async def test_search_long_term_memory_with_optimize_query_default_true( +async def test_search_long_term_memory_with_optimize_query_default_false( memory_test_client: MemoryAPIClient, ): - """Test that client search_long_term_memory uses optimize_query=True by default.""" + """Test that client search_long_term_memory uses optimize_query=False by default.""" with patch( "agent_memory_server.long_term_memory.search_long_term_memories" ) as mock_search: @@ -519,15 +519,15 @@ async def test_search_long_term_memory_with_optimize_query_default_true( next_offset=None, ) - # Call search without optimize_query parameter (should default to True) + # Call search without optimize_query parameter (should default to False) results = await memory_test_client.search_long_term_memory( text="tell me about my preferences" ) - # Verify search was called with optimize_query=True (default) + # Verify search was called with optimize_query=False (default) mock_search.assert_called_once() call_kwargs = mock_search.call_args.kwargs - assert call_kwargs.get("optimize_query") is True + assert call_kwargs.get("optimize_query") is False # Verify results assert results.total == 1 @@ -535,10 +535,10 @@ async def test_search_long_term_memory_with_optimize_query_default_true( @pytest.mark.asyncio -async def test_search_long_term_memory_with_optimize_query_false_explicit( +async def test_search_long_term_memory_with_optimize_query_true_explicit( memory_test_client: MemoryAPIClient, ): - """Test that client search_long_term_memory can use optimize_query=False when explicitly set.""" + """Test that client search_long_term_memory can use optimize_query=True when explicitly set.""" with patch( "agent_memory_server.long_term_memory.search_long_term_memories" ) as mock_search: @@ -555,15 +555,15 @@ async def test_search_long_term_memory_with_optimize_query_false_explicit( next_offset=None, ) - # Call search with explicit optimize_query=False + # Call search with explicit optimize_query=True await memory_test_client.search_long_term_memory( - text="tell me about my preferences", optimize_query=False + text="tell me about my preferences", optimize_query=True ) - # Verify search was called with optimize_query=False + # Verify search was called with optimize_query=True mock_search.assert_called_once() call_kwargs = mock_search.call_args.kwargs - assert call_kwargs.get("optimize_query") is False + assert call_kwargs.get("optimize_query") is True @pytest.mark.asyncio