RunScoreBased performs score-based compaction (no LLM needed).
()
| 185 | |
| 186 | // RunScoreBased performs score-based compaction (no LLM needed). |
| 187 | func (c *Compactor) RunScoreBased() error { |
| 188 | c.logger.Info("Starting score-based memory compaction") |
| 189 | |
| 190 | // Archive facts with very low scores |
| 191 | threshold := 0.1 |
| 192 | candidates := c.facts.GetArchiveCandidates(threshold) |
| 193 | |
| 194 | if len(candidates) > 0 { |
| 195 | archivePath := filepath.Join(c.memDir, "memory_archive.json") |
| 196 | if err := c.facts.ArchiveFacts(candidates, archivePath); err != nil { |
| 197 | c.logger.Warn("Failed to archive facts", zap.Error(err)) |
| 198 | } else { |
| 199 | c.logger.Info("Archived low-score facts", |
| 200 | zap.Int("count", len(candidates))) |
| 201 | } |
| 202 | } |
| 203 | |
| 204 | c.markCompacted() |
| 205 | c.writeMemoryMD() |
| 206 | |
| 207 | return nil |
| 208 | } |
| 209 | |
| 210 | // CleanupDailyNotes removes old daily notes. |
| 211 | func (c *Compactor) CleanupDailyNotes() (int, error) { |