@@ -53,14 +53,12 @@ async def run_compact_memories_with_mocks(
5353 merged_memories: List of merged memory dictionaries to return from merge_memories_with_llm
5454 search_results: List of search results to return from search_index.search
5555 """
56- print ("Setting up mocks for compact_long_term_memories" )
5756 # Setup scan mock
5857 mock_redis .scan = AsyncMock ()
5958 mock_redis .scan .side_effect = lambda cursor , match = None , count = None : (
6059 0 ,
6160 memory_keys ,
6261 )
63- print (f"Mocked scan to return { memory_keys } " )
6462
6563 # Setup execute_command mock for Redis
6664 mock_redis .execute_command = AsyncMock ()
@@ -90,7 +88,6 @@ def execute_command_side_effect(cmd, *args):
9088 return [0 ]
9189
9290 mock_redis .execute_command .side_effect = execute_command_side_effect
93- print ("Mocked execute_command for AGGREGATE and SEARCH" )
9491
9592 # Setup pipeline mock
9693 # Use MagicMock for the pipeline itself, but AsyncMock for execute
@@ -104,7 +101,6 @@ def execute_command_side_effect(cmd, *args):
104101 )
105102 # This ensures pipeline.hgetall(key) won't create an AsyncMock
106103 mock_redis .pipeline = MagicMock (return_value = mock_pipeline )
107- print ("Mocked pipeline setup" )
108104
109105 # Setup delete mock
110106 mock_redis .delete = AsyncMock ()
@@ -113,10 +109,8 @@ def execute_command_side_effect(cmd, *args):
113109 if "123" in key
114110 else memory_contents [1 ]
115111 )
116- print ("Mocked delete and hgetall" )
117112
118113 # Setup hash generation mock
119- print (f"Setting up hash values: { hash_values } for memories" )
120114 hash_side_effect = (
121115 hash_values
122116 if isinstance (hash_values , list )
@@ -135,51 +129,40 @@ def execute_command_side_effect(cmd, *args):
135129 # For a single merge, we need to handle both hash-based and semantic merging
136130 merge_memories_mock .return_value = merged_memories
137131
138- print (f"Set up merge_memories_with_llm mock with { merged_memories } " )
139-
140132 # Setup vectorizer mock
141133 mock_vectorizer = MagicMock ()
142134 mock_vectorizer .aembed = AsyncMock (return_value = [0.1 , 0.2 , 0.3 ])
143135 mock_vectorizer .aembed_many = AsyncMock (return_value = [[0.1 , 0.2 , 0.3 ]])
144- print ("Mocked vectorizer" )
145136
146137 # Setup search index mock - special handling for test_compact_semantic_duplicates_simple
147138 mock_index = MagicMock ()
148139
149140 # Create a search mock that responds appropriately for VectorRangeQuery
150141 # This is needed for the new code that uses VectorRangeQuery
151142 def search_side_effect (query , params = None ):
152- print (f"Search called with query type: { type (query ).__name__ } " )
153143 # If we're doing a semantic search with VectorRangeQuery
154144 if (
155145 hasattr (query , "distance_threshold" )
156146 and query .distance_threshold == 0.12
157147 ):
158- print (
159- f"Returning semantic search results with { len (search_results .docs ) if hasattr (search_results , 'docs' ) else 0 } docs"
160- )
161148 return search_results
162149
163150 # For VectorQuery general queries
164151 if hasattr (query , "vector_field_name" ):
165- print ("Returning empty results for vector query" )
166152 empty_result = MagicMock ()
167153 empty_result .docs = []
168154 empty_result .total = 0
169155 return empty_result
170156
171157 # For standard Query, we should include the memories for hash-based compaction
172- print (f"Standard query: { query } " )
173158 return search_results
174159
175160 mock_index .search = AsyncMock (side_effect = search_side_effect )
176- print ("Mocked search_index.search" )
177161
178162 # Mock get_redis_conn and get_llm_client to return our mocks
179163 mock_get_redis_conn = AsyncMock (return_value = mock_redis )
180164 mock_llm_client = AsyncMock ()
181165 mock_get_llm_client = AsyncMock (return_value = mock_llm_client )
182- print ("Mocked get_redis_conn and get_llm_client" )
183166
184167 # Setup index_long_term_memories mock
185168 index_long_term_memories_mock = AsyncMock ()
@@ -211,7 +194,6 @@ def search_side_effect(query, params=None):
211194 mock_get_llm_client ,
212195 ),
213196 ):
214- print ("Calling compact_long_term_memories" )
215197 # Call the function
216198 # Force compact_hash_duplicates=True to ensure hash-based compaction is tested
217199 await agent_memory_server .long_term_memory .compact_long_term_memories (
@@ -222,18 +204,6 @@ def search_side_effect(query, params=None):
222204 compact_semantic_duplicates = True ,
223205 )
224206
225- print (f"Merge memories called { merge_memories_mock .call_count } times" )
226- if merge_memories_mock .call_count > 0 :
227- print (
228- f"Merge memories called with args: { merge_memories_mock .call_args_list } "
229- )
230-
231- print (f"Search index called { mock_index .search .call_count } times" )
232- if mock_index .search .call_count > 0 :
233- print (
234- f"Search index called with args: { mock_index .search .call_args_list } "
235- )
236-
237207 return {
238208 "merge_memories" : merge_memories_mock ,
239209 "search_index" : mock_index ,
0 commit comments