File tree Expand file tree Collapse file tree 4 files changed +25
-3
lines changed
Expand file tree Collapse file tree 4 files changed +25
-3
lines changed Original file line number Diff line number Diff line change @@ -158,6 +158,9 @@ class Settings(BaseSettings):
158158 # Keep only top N most recent (by recency score) when budget is set
159159 forgetting_budget_keep_top_n : int | None = None
160160
161+ # Compaction settings
162+ compaction_every_minutes : int = 10
163+
161164 class Config :
162165 env_file = ".env"
163166 env_file_encoding = "utf-8"
Original file line number Diff line number Diff line change @@ -428,7 +428,9 @@ async def compact_long_term_memories(
428428 vector_distance_threshold : float = 0.12 ,
429429 compact_hash_duplicates : bool = True ,
430430 compact_semantic_duplicates : bool = True ,
431- perpetual : Perpetual = Perpetual (every = timedelta (minutes = 10 ), automatic = True ),
431+ perpetual : Perpetual = Perpetual (
432+ every = timedelta (minutes = settings .compaction_every_minutes ), automatic = True
433+ ),
432434) -> int :
433435 """
434436 Compact long-term memories by merging duplicates and semantically similar memories.
Original file line number Diff line number Diff line change @@ -114,13 +114,17 @@ QUERY_OPTIMIZATION_PROMPT_TEMPLATE="Transform this query for semantic search..."
114114
115115## Memory Lifecycle
116116
117- ### Forgetting Configuration
117+ ### Memory Management Configuration
118118``` bash
119+ # Forgetting settings
119120FORGETTING_ENABLED=false # Enable automatic forgetting (default: false)
120121FORGETTING_EVERY_MINUTES=60 # Run forgetting every N minutes (default: 60)
121122FORGETTING_MAX_AGE_DAYS=30 # Delete memories older than N days
122123FORGETTING_MAX_INACTIVE_DAYS=7 # Delete memories inactive for N days
123124FORGETTING_BUDGET_KEEP_TOP_N=1000 # Keep only top N most recent memories
125+
126+ # Compaction settings
127+ COMPACTION_EVERY_MINUTES=10 # Run memory compaction every N minutes (default: 10)
124128```
125129
126130## Background Tasks
@@ -209,6 +213,7 @@ enable_topic_extraction: true
209213enable_ner : true
210214forgetting_enabled : true
211215forgetting_max_age_days : 90
216+ compaction_every_minutes : 15
212217` ` `
213218
214219### High-Performance Setup
Original file line number Diff line number Diff line change @@ -357,7 +357,7 @@ async def cleanup_working_memory(client: MemoryAPIClient):
357357
358358### Background Compaction
359359
360- The system automatically runs compaction tasks every 10 minutes to:
360+ The system automatically runs compaction tasks (configurable, default every 10 minutes) to:
361361
362362- Merge similar memories
363363- Update embeddings for improved accuracy
@@ -378,6 +378,18 @@ await client.schedule_compaction(
378378)
379379```
380380
381+ #### Configuring Compaction Schedule
382+
383+ The frequency of automatic compaction can be configured:
384+
385+ ``` bash
386+ # Environment variable (minutes)
387+ COMPACTION_EVERY_MINUTES=15
388+
389+ # Or in configuration file
390+ compaction_every_minutes: 15
391+ ```
392+
381393### Compaction Strategies
382394
383395#### Similarity-Based Merging
You can’t perform that action at this time.
0 commit comments