Memory: byte-budgeted index, memory_search (BM25), auto extraction on compaction/exit

This commit is contained in:
hermes committed 2026-11-30 12:46:16 +00:00
1 parent 59bf45f41d
commit 8705b128ea
8 files changed
+311 -39

No files matched your search

-14
View File
@@ -1,14 +0,0 @@
# Memory index is capped and write fails when full
Status: accepted
## Context
The `MEMORY.md` index goes into every system prompt.
## Decision
A per-scope cap on index size makes `write` fail when full, so the agent must consolidate or forget entries instead of growing the prompt.
## Consequences
Upserts of existing lines still work when full.
Code: crates/hx-core/src/memory.rs (index cap, `write`)
@@ -0,0 +1,14 @@
# Memory: byte-budgeted index, BM25 search, automatic extraction
Status: accepted (supersedes 0013)
## Context
The 50-entry cap made `write` fail instead of letting memory grow, and the agent rarely wrote memory at all, so project decisions were lost between sessions.
## Decision
No entry cap. The prompt index shows the most recently used hooks up to 2 KB per scope; `memory_search` (BM25 over slug, hook and body, no dependency) reaches the rest and bumps recency (topic file mtime). The prompt lists concrete write triggers and defaults to project scope. Compaction and session exit run one extraction call (max 5 entries, written without asking).
## Consequences
Prompt cost stays flat as memory grows. Search scans all topic files per query. Embeddings can replace the ranking later without changing the tools.
Code: crates/hx-core/src/memory.rs