oats.memory

Memory management for persistent preferences, project context, and references.

oats.memory.models

Memory data models.

class oats.memory.models.MemoryType(*values)[source]

Bases: str, Enum

Types of persistent memories.

USER = 'user'
FEEDBACK = 'feedback'
PROJECT = 'project'
REFERENCE = 'reference'
class oats.memory.models.Memory(**data)[source]

Bases: BaseModel

A persistent memory entry.

id: str
type: MemoryType
title: str
content: str
tags: list[str]
created_at: datetime
updated_at: datetime
source: str | None
to_frontmatter()[source]

Serialize to markdown with YAML frontmatter.

Return type:

str

classmethod from_frontmatter(text)[source]

Parse from markdown with YAML frontmatter.

Return type:

Optional[Memory]

model_config: ClassVar[ConfigDict] = {}

Configuration for the model, should be a dictionary conforming to [ConfigDict][pydantic.config.ConfigDict].

oats.memory.manager

Memory manager — load, save, search, and build system prompt sections.

class oats.memory.manager.MemoryManager(user_dir=None, project_dir=None)[source]

Bases: object

Manages persistent memories across sessions.

Memories stored as markdown files with YAML frontmatter in: - user_dir: ~/.coder/memory/ (user-global) - project_dir: <project>/.coder/memory/ (project-local)

__init__(user_dir=None, project_dir=None)[source]

Initialize the memory manager with user and project directories.

Parameters:
  • user_dir – Directory for user-global memories (default: ~/.coder/memory).

  • project_dir – Directory for project-local memories (default: <project>/.coder/memory).

async load_all()[source]

Load all memories from both directories.

Return type:

list[Memory]

async save(memory, scope='project')[source]

Save a memory to the appropriate directory.

Return type:

Memory

async delete(memory_id)[source]

Delete a memory by ID.

Return type:

bool

async search(query)[source]

Simple keyword search across memories.

Return type:

list[Memory]

async build_system_prompt_section()[source]

Build the memory section for the system prompt.

Loads MEMORY.md index and referenced files, truncated to MAX_PROMPT_CHARS.

Return type:

str