Skip to content

Commit 6b8275c

Browse files
docs: fix linting issues in memory-lifecycle.md
- Remove trailing whitespace from multiple lines - Apply code formatting with ruff - Ensure all pre-commit hooks pass Co-authored-by: Andrew Brookins <[email protected]>
1 parent ead73d4 commit 6b8275c

File tree

1 file changed

+16
-16
lines changed

1 file changed

+16
-16
lines changed

docs/memory-lifecycle.md

Lines changed: 16 additions & 16 deletions
Original file line numberDiff line numberDiff line change
@@ -9,7 +9,7 @@ Memory lifecycle in the system follows these stages:
99
1. **Creation** - Memories are created in working memory or directly as long-term memories
1010
2. **Promotion** - Working memories are automatically promoted to long-term storage
1111
3. **Access** - Memories are tracked for access patterns and recency
12-
4. **Aging** - Memories accumulate age and inactivity metrics
12+
4. **Aging** - Memories accumulate age and inactivity metrics
1313
5. **Forgetting** - Memories are deleted by background server processes based on configuration
1414
6. **Compaction** - Background processes optimize storage and indexes
1515

@@ -113,7 +113,7 @@ Forgetting behavior is controlled entirely through server-side environment varia
113113
# Enable/disable automatic forgetting
114114
FORGETTING_ENABLED=true
115115

116-
# How often to run the forgetting process (in minutes)
116+
# How often to run the forgetting process (in minutes)
117117
FORGETTING_EVERY_MINUTES=60
118118

119119
# Maximum age before memories are eligible for deletion
@@ -133,7 +133,7 @@ The system supports these automated forgetting strategies:
133133
#### 1. Age-Based Deletion
134134
Memories older than `FORGETTING_MAX_AGE_DAYS` are eligible for deletion.
135135

136-
#### 2. Inactivity-Based Deletion
136+
#### 2. Inactivity-Based Deletion
137137
Memories not accessed within `FORGETTING_MAX_INACTIVE_DAYS` are eligible for deletion.
138138

139139
#### 3. Combined Age + Inactivity
@@ -153,7 +153,7 @@ from agent_memory_client import MemoryAPIClient
153153
client = MemoryAPIClient(base_url="http://localhost:8000")
154154

155155
# Delete specific long-term memories by ID
156-
memory_ids = ["memory-id-1", "memory-id-2"]
156+
memory_ids = ["memory-id-1", "memory-id-2"]
157157
await client.delete_long_term_memories(memory_ids)
158158

159159
# Delete working memory for a session
@@ -165,7 +165,7 @@ await client.delete_working_memory("session-id")
165165
# Find memories to potentially clean up
166166
old_memories = await client.search_long_term_memory(
167167
text="",
168-
user_id="user-123",
168+
user_id="user-123",
169169
created_before=datetime.now() - timedelta(days=90),
170170
limit=100
171171
)
@@ -182,7 +182,7 @@ await client.delete_long_term_memories(memory_ids)
182182
The server uses **Docket** (a Redis-based task queue) to manage background operations including:
183183

184184
- **Periodic Forgetting**: `periodic_forget_long_term_memories` task runs based on `FORGETTING_EVERY_MINUTES`
185-
- **Memory Compaction**: Optimization and deduplication processes
185+
- **Memory Compaction**: Optimization and deduplication processes
186186
- **Index Rebuilding**: Maintaining search index performance
187187

188188
### Task Worker Setup
@@ -213,7 +213,7 @@ async def monitor_memory_usage():
213213

214214
**Note**: Background forgetting processes operate independently to maintain consistent server resource management.
215215

216-
## Client-Side Memory Management
216+
## Client-Side Memory Management
217217

218218
Clients can perform manual memory management operations alongside automatic background processes:
219219

@@ -223,7 +223,7 @@ Clients can perform manual memory management operations alongside automatic back
223223
```python
224224
async def cleanup_old_sessions(client: MemoryAPIClient, days_old: int = 30):
225225
"""Delete all memories from old sessions"""
226-
226+
227227
cutoff_date = datetime.now() - timedelta(days=days_old)
228228

229229
# Find old memories
@@ -233,7 +233,7 @@ async def cleanup_old_sessions(client: MemoryAPIClient, days_old: int = 30):
233233
limit=5000 # Process in batches
234234
)
235235

236-
# Delete in batches of 100
236+
# Delete in batches of 100
237237
memory_ids = [mem.id for mem in old_memories.memories]
238238
batch_size = 100
239239

@@ -283,7 +283,7 @@ await client.delete_working_memory("session-123")
283283
The system automatically runs compaction tasks as background processes. These are server-controlled and include:
284284

285285
- Memory deduplication and merging
286-
- Search index optimization
286+
- Search index optimization
287287
- Storage cleanup
288288

289289
Compaction frequency is controlled by the server configuration:
@@ -306,7 +306,7 @@ Complete server configuration for memory lifecycle management:
306306
FORGETTING_ENABLED=false # Disabled by default
307307
FORGETTING_EVERY_MINUTES=60 # Check every hour
308308
FORGETTING_MAX_AGE_DAYS=90.0 # Age threshold (days)
309-
FORGETTING_MAX_INACTIVE_DAYS=30.0 # Inactivity threshold (days)
309+
FORGETTING_MAX_INACTIVE_DAYS=30.0 # Inactivity threshold (days)
310310
FORGETTING_BUDGET_KEEP_TOP_N=10000 # Budget-based limit
311311

312312
# Compaction Configuration
@@ -369,12 +369,12 @@ async def get_user_preference(client, user_id: str, preference_key: str):
369369
user_id=user_id,
370370
limit=1
371371
)
372-
372+
373373
if memories.memories:
374374
return parse_preference(memories.memories[0].text)
375375
else:
376376
return get_default_preference(preference_key)
377-
377+
378378
# Bad: Assuming specific memories will always exist
379379
# Hypothetical: get_memory_by_id() does not exist in the real API
380380
```
@@ -384,18 +384,18 @@ async def get_user_preference(client, user_id: str, preference_key: str):
384384
# Good: Explicit cleanup when needed
385385
async def handle_user_data_deletion(client: MemoryAPIClient, user_id: str):
386386
"""Handle user's right to be forgotten request"""
387-
387+
388388
# Find all user memories
389389
all_memories = await client.search_long_term_memory(
390390
text="",
391391
user_id=user_id,
392392
limit=10000 # Large limit to get all
393393
)
394-
394+
395395
# Delete in batches
396396
memory_ids = [mem.id for mem in all_memories.memories]
397397
batch_size = 100
398-
398+
399399
for i in range(0, len(memory_ids), batch_size):
400400
batch = memory_ids[i:i + batch_size]
401401
await client.delete_long_term_memories(batch)

0 commit comments

Comments
 (0)