memory

package
v0.4.0 Latest Latest
Warning

This package is not in the latest version of its module.

Go to latest
Published: Sep 30, 2026 License: Apache-2.0 Imports: 16 Imported by: 0 modules, 0 packages

The first number is the count of modules that contain a package that imports this one. The module count is a better indicator of popularity than the package count. A module with 100 importing packages is counted only once instead of 100 times, reflecting the fact that the choice to use the package was likely made only once, not 100 times.
A '?' means that the value hasn't been computed yet.

Documentation

Overview

Package memory is the assistant's own durable memory: a per-workspace folder of Markdown files whose index (MEMORY.md) is folded into every system prompt, with the detail files loaded on demand. It is the counterpart to internal/skill — skills shape HOW the model works, memory holds WHAT it knows about its user.

The folder is a sibling of the file tools' mount, not inside it (ADR-10): file_write can never reach it, so a prompt injection cannot rewrite the assistant's memory through a generic file tool. The only writer is memory_write, and that asks the human through the gate. Reading is ungated — pre-installed text is context ingestion, zero authority, exactly like skill_read.

Index

Constants

View Source
const IndexBudget = maxIndexBytes

IndexBudget is how many bytes of catalog reach the system prompt. Exported because it is a ceiling a PERSON has to be able to see: it is enforced, not requested, so a workspace that has quietly grown past it is dropping notes from every prompt with nothing on screen to say so.

View Source
const Kind = "memory"

Kind is the gate Kind a memory MUTATION checks; the Target is the memory-relative, forward-slashed path, so a grant can be widened to a directory ("people/*"). Reads carry no Kind at all — they are not gated. The matcher lives here with the tool that owns it, like FileKind's in internal/tools.

Variables

This section is empty.

Functions

This section is empty.

Types

type Store

type Store struct {
	// contains filtered or unexported fields
}

Store is one workspace's memory folder. A missing folder is not an error: the index is empty and the first write creates it.

func New

func New(dir string, scanner *secret.Scanner) *Store

New builds the Store over dir (a workspace's memory/ folder). It touches no disk: Index reads on every call so an edit in a text editor lands in the next turn, and the tools open the folder per operation.

func (*Store) Index

func (s *Store) Index() string

Index renders the catalog folded into the system prompt: one line per note, "path — summary", sorted by path. It is DERIVED from the notes on disk, never a file of its own — so it can never drift from what is actually stored, the model has one thing to write instead of two, and the prompt budget below is enforced rather than politely requested.

An empty folder yields "" — a fresh workspace pays no tokens at all, and the model still learns it can remember things from memory_write's description.

It walks fresh on every call rather than caching: the tree is small, the model may have just written to it, and the human may have corrected a note in an editor between two turns.

func (*Store) SetLogger

func (s *Store) SetLogger(l *slog.Logger)

SetLogger installs the logger Index reports an unreadable index through. Optional; without it the store is silent.

func (*Store) Tools

func (s *Store) Tools() ([]agentkit.Tool, error)

Tools returns memory_read and memory_write. They are base tools like the file tools, so an agent reaches them only if its declared cage keeps them.

Jump to

Keyboard shortcuts

? : This menu
/ : Search site
f or F : Jump to
y or Y : Canonical URL