plugins/memory/file_memory/file_memory
File-based memory provider.
Stores agent memory and user profile as markdown files under
$AGENT_HOME/memories/ (default: ~/.agent/memories/).
Two files are managed:
- MEMORY.md — agent’s notes (2200 char limit)
- USER.md — user profile (1375 char limit)
Entries are separated by \n§\n delimiter.
Writes are atomic (temp file + rename).
Types
pub opaque type MemoryStore
Values
pub fn add(
store: MemoryStore,
target: Target,
content: String,
) -> Result(MemoryStore, String)
Add an entry to the target store. Fails if the character limit would be exceeded.
pub fn format_for_system_prompt(
store: MemoryStore,
target: Target,
) -> String
Format entries for inclusion in the system prompt (frozen snapshot). Returns an empty string when there are no entries.
pub fn get_entries(
store: MemoryStore,
target: Target,
) -> List(String)
Return the live list of entries for the given target.
pub fn load_from_disk() -> MemoryStore
Re-read both memory files from disk into a fresh store.
pub fn new_in(base_dir: String) -> MemoryStore
Create a new MemoryStore at a specific base directory. For testing and custom deployment paths.
pub fn persist(store: MemoryStore) -> Result(Nil, String)
Write both memory files to disk atomically.
pub fn remove(
store: MemoryStore,
target: Target,
old_text: String,
) -> Result(MemoryStore, String)
Remove the first entry containing old_text.
pub fn replace(
store: MemoryStore,
target: Target,
old_text: String,
new_content: String,
) -> Result(MemoryStore, String)
Replace the first entry containing old_text.
pub fn usage_string(store: MemoryStore, target: Target) -> String
Return a human-readable usage string like “45% — 987/2200 chars”.