Expand description
Pluggable memory architecture for newt’s chat REPL.
Modelled on hermes-agent’s MemoryProvider ABC + MemoryManager
orchestrator, adapted for Rust and newt’s local-first constraints.
§Design principles (from hermes-agent)
- Fault isolation — one provider’s panic/error never blocks others.
- Frozen system prompt —
system_prompt_block()is captured once at session start and never rebuilt mid-session (preserves the model’s prefix cache / KV cache across turns). - Non-blocking sync —
sync_turnshould queue writes; the chat loop never waits on memory backends. - Single integration point —
MemoryManageris the only thing the chat loop interacts with; it fans out to all registered providers.
§Built-in providers (shipped in order)
| Provider | Issue |
|---|---|
RollingWindow | #105 — keep last N turns (ships here) |
TokenBudget | #106 — prune by context-window % |
Summarizing | #107 — LLM summarization of old turns |
NoteStore | #108 — persistent NOTES.md the agent writes to |
Re-exports§
pub use crate::notes::NoteStore;
Structs§
- MemMessage
- A single message in a conversation.
- Memory
Index - A budgeted, frozen INDEX of memory the model can navigate (#319).
- Memory
Manager - Orchestrates all registered
MemoryProviders. - Notes
Unsupported - Error returned by the default
MemoryProvider::add_notefor providers that don’t persist notes. - Rolling
Window - Keep the last
max_turnsconversation turns; discard older ones. - Session
Context - Context provided to each
MemoryProvider::initializecall. - Soul
Provider - Loads an agent identity from a Markdown soul file and injects it as a frozen system-prompt block.
- Summarizing
- LLM-powered summarisation of old turns when context fills.
- Token
Budget - Keep turns up to
threshold_pctof the model’s context window.
Enums§
- Role
- Soul
Source - Where the soul was loaded from.
Constants§
- COACH_
SOUL - FR-5 (#999): the ADVISE-first identity installed when a persona’s altitude is
crate::Altitude::Coach(front-matteraltitude = "coach"). It REPLACESDEFAULT_SOULrather than layering over it — the doer soul (“never describe a change, make it”) directly contradicts a coach, so appending a coach overlay onto the doer soul would ship two opposing identities in one prompt. This IS the whole base identity for a coaching turn; the persona’s own markdown body still overlays on top, now without self-contradiction. - DEFAULT_
CONTEXT_ TOKENS - Static context-token budget used only when neither an explicit
[memory] context_tokensoverride nor empirical capability data exists (a fresh model with no probe history — Step 18.2, #247). - DEFAULT_
SOUL - Default agent identity injected when no soul file is found.
- MEMORY_
INDEX_ BUDGET - The memory index budget: the maximum number of items the frozen memory
INDEX may list, pinned by CI (the modulex
DEFAULT_TOOL_BUDGET = 12pattern — progressive-disclosure memory design §2.3/§3.3). The index is the cheap layer that rides in every request; the verbatim bodies are pulled on demand viamemory_fetch. Growing this is a deliberate edit to this constant with its own justification, asserted by a test — never a side effect of a feature. Starts small (≈ theDEFAULT_TOOL_BUDGETorder of magnitude); tune empirically against probe data, never down silently.
Traits§
- Memory
Provider - Contract for all memory backends.