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:

Entries are separated by \n§\n delimiter. Writes are atomic (temp file + rename).

Types

pub opaque type MemoryStore
pub type Target {
  Memory
  User
}

Constructors

  • Memory
  • User

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() -> MemoryStore

Create a new MemoryStore, loading existing entries from disk.

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”.

Search Document