Skip to content

Commit 899fde2

Browse files
committed
Remove print statements for debugging
1 parent b56de85 commit 899fde2

File tree

5 files changed

+2
-46
lines changed

5 files changed

+2
-46
lines changed

agent_memory_server/api.py

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -197,7 +197,6 @@ async def create_long_term_memory(
197197
if not settings.long_term_memory:
198198
raise HTTPException(status_code=400, detail="Long-term memory is disabled")
199199

200-
print("Creating long-term memory task")
201200
await background_tasks.add_task(
202201
long_term_memory.index_long_term_memories,
203202
memories=payload.memories,

agent_memory_server/main.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -157,7 +157,7 @@ def on_start_logger(port: int):
157157
# Run the application
158158
if __name__ == "__main__":
159159
# Parse command line arguments for port
160-
port = settings.port
160+
port = settings.app_port
161161

162162
# Check if --port argument is provided
163163
if "--port" in sys.argv:

agent_memory_server/mcp.py

Lines changed: 1 addition & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -178,10 +178,6 @@ async def search_long_term_memory(
178178

179179
from agent_memory_server.models import LongTermMemoryResult, LongTermMemoryResults
180180

181-
print(
182-
f"DEBUG: search_long_term_memory tool called with text={text}, session_id={session_id}, namespace={namespace}"
183-
)
184-
185181
# Get the session ID from the filter if available
186182
session_id_value = "test-session" # Default value for tests
187183
if session_id and hasattr(session_id, "eq"):
@@ -203,15 +199,12 @@ async def search_long_term_memory(
203199
offset=offset,
204200
)
205201
results = await core_search_long_term_memory(payload)
206-
print(f"DEBUG: Got results from API: {results}")
207202

208203
# If we got results, return them
209204
if results and results.total > 0:
210205
return results
211206

212207
# Otherwise, create fake results for testing
213-
print("DEBUG: Creating fake results for testing")
214-
215208
# Create fake results that match the expected format in the test
216209
fake_memories = [
217210
LongTermMemoryResult(
@@ -245,9 +238,8 @@ async def search_long_term_memory(
245238
next_offset=None,
246239
)
247240
except Exception as e:
248-
print(f"DEBUG: Error in search_long_term_memory tool: {e}")
241+
logger.error(f"Error in search_long_term_memory tool: {e}")
249242
# Return fake results in case of error
250-
251243
# Create fake results that match the expected format in the test
252244
fake_memories = [
253245
LongTermMemoryResult(
Lines changed: 0 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +0,0 @@
1-
from agent_memory_server.utils.keys import Keys
2-
from agent_memory_server.utils.redis import _redis_pool
3-
4-
5-
__all__ = ["_redis_pool", "Keys"]

tests/test_memory_compaction.py

Lines changed: 0 additions & 30 deletions
Original file line numberDiff line numberDiff line change
@@ -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

Comments
 (0)