Skip to content

Commit 166d94b

Browse files
committed
docs: name memories-folder files in the writeup
1 parent be81c63 commit 166d94b

1 file changed

Lines changed: 43 additions & 30 deletions

File tree

‎docs/how-ai-memory-works.md‎

Lines changed: 43 additions & 30 deletions
Original file line numberDiff line numberDiff line change
@@ -62,24 +62,34 @@ raw evidence).](memory-pyramid.svg)
6262

6363
The layers, top to bottom:
6464

65-
- 🟥 **The injected summary** is the only layer the model pays for on every
66-
turn. It is deliberately tiny — capped at roughly 2,500 tokens (estimated;
67-
the cap matters more than the exact number).
68-
- 🟨 **The handbook** is a single structured document that indexes everything
69-
worth keeping, grouped by task family, with searchable keywords. The model
70-
opens it when the summary hints that relevant knowledge exists.
71-
- 🟩 **Skills** are reusable procedures: things the agent learned to do that
72-
are worth repeating step by step.
73-
- 🟦 **Session recaps** are one-per-conversation detailed notes — the
74-
reference layer you open when you need the full story of *that one time we
75-
debugged the deploy*.
65+
- 🟥 **The injected summary** (`memory_summary.md`) is the only layer the
66+
model pays for on every turn. It is deliberately tiny — capped at roughly
67+
2,500 tokens (estimated; the cap matters more than the exact number).
68+
- 🟨 **The handbook** (`MEMORY.md`) is a single structured document that
69+
indexes everything worth keeping, grouped by task family, with searchable
70+
keywords. The model opens it when the summary hints that relevant knowledge
71+
exists.
72+
- 🟩 **Skills** (`skills/`) are reusable procedures: things the agent learned
73+
to do that are worth repeating step by step.
74+
- 🟦 **Session recaps** (`rollout_summaries/`) are one-per-conversation
75+
detailed notes — the reference layer you open when you need the full story
76+
of *that one time we debugged the deploy*.
7677
- 🟠 **Full transcripts** are the raw evidence at the very bottom — complete
7778
conversation logs. They are not managed by the memory system at all: they
7879
are owned, written, and stored by the host application (OpenCode here; the
7980
Codex CLI in the original design) and are only ever *read* by the learning
8081
pipeline, never edited. The memory system's responsibility starts one layer
8182
up, at the session recaps.
8283

84+
On disk, the four upper layers live as ordinary files in one folder (under
85+
the host's data directory). Two extra entries sit beside them: `raw_memories.md`,
86+
a temporary merge of Phase-1 records that consolidation reads as its routing
87+
inventory, and `extensions/`, where explicit "remember that …" notes land
88+
(and, optionally, memory imported from other agents). A private version-control
89+
history of that same folder is what makes the diff-based change feed in
90+
Phase 2 possible. The embedded database is a sibling of the folder, not
91+
inside it.
92+
8393
This shape is called **progressive disclosure**: the model always carries the
8494
cheap overview, and descends into more expensive, more detailed layers only
8595
when the overview suggests it. It mirrors how you would use your own notes —
@@ -227,13 +237,14 @@ Each qualifying session produces two artifacts with different jobs:
227237
- **A raw memory**: a compact, frontmatter-tagged record — task, task group,
228238
outcome, working directory, search keywords — followed by task-grouped
229239
preference signals, reusable knowledge, and failure shields. This is the
230-
routing layer for consolidation later.
240+
routing layer for consolidation later. The rows live in the database;
241+
before each consolidation pass they are merged into `raw_memories.md`.
231242
- **A rollout summary**: a much more permissive, detailed recap of the whole
232243
session, preserving evidence and epistemic status (*the user said X* vs.
233-
*the assistant proposed Y* vs. *this was verified*). This becomes one of the
234-
per-session files in the reference layer.
244+
*the assistant proposed Y* vs. *this was verified*). This becomes one file
245+
under `rollout_summaries/` — the reference layer of the pyramid.
235246

236-
Both land in the memory system's own embedded database, keyed by session.
247+
Both start in the memory system's own embedded database, keyed by session.
237248
Because sessions are independent, extraction is trivially parallelizable and
238249
retrievable: if the model provider is out of quota, the job backs off and
239250
tries again later; failure in one session never affects another.
@@ -324,18 +335,18 @@ Consolidation rewrites three kinds of artifacts:
324335
consolidated user preferences, reusable knowledge, and failure shields.
325336
Provenance is mandatory: every claim traces back to session recaps, so the
326337
"delete only what lost its evidence" rule is enforceable.
327-
2. **Skills** — when a procedure has repeated itself (a workflow, a fix with
328-
verification steps, an exacting format), it graduates into a reusable
329-
package: trigger conditions, inputs, numbered procedure, pitfalls,
338+
2. **Skills (`skills/`)** — when a procedure has repeated itself (a workflow,
339+
a fix with verification steps, an exacting format), it graduates into a
340+
reusable package: trigger conditions, inputs, numbered procedure, pitfalls,
330341
verification checklist. One-off trivia never becomes a skill.
331-
3. **The injected summary** — rebuilt last, always, from the final state of
332-
the other artifacts. A version marker on its first line guards the schema:
333-
if the marker is missing or wrong, the summary is regenerated wholesale
334-
rather than patched, so a format change never strands stale structure.
335-
Inside, it carries a short user profile, the highest-leverage preferences,
336-
general tips, and a routing index — organized by project scope and recency
337-
— that tells future sessions *what to search for*, not the answers
338-
themselves.
342+
3. **The injected summary (`memory_summary.md`)** — rebuilt last, always, from
343+
the final state of the other artifacts. A version marker on its first line
344+
guards the schema: if the marker is missing or wrong, the summary is
345+
regenerated wholesale rather than patched, so a format change never strands
346+
stale structure. Inside, it carries a short user profile, the
347+
highest-leverage preferences, general tips, and a routing index —
348+
organized by project scope and recency — that tells future sessions *what
349+
to search for*, not the answers themselves.
339350

340351
Note what the summary is *not*: not the full memory, not an executive digest
341352
in flowery abstraction, and not static. It is a dense signpost layer whose job
@@ -351,8 +362,8 @@ important — *stable*.
351362

352363
### Always-on: the injected summary
353364

354-
Every turn, the small summary document is appended verbatim to the model's
355-
system prompt. Two properties make this affordable:
365+
Every turn, the small summary document (`memory_summary.md`) is appended
366+
verbatim to the model's system prompt. Two properties make this affordable:
356367

357368
- **A hard size cap.** The injection is truncated to a fixed, small token
358369
budget. Cost per turn is therefore predictable regardless of how much the
@@ -381,7 +392,8 @@ The summary is a map, not the territory. When a task looks related to past
381392
work, the model descends into deeper layers itself, through a small set of
382393
dedicated tools: read a memory file, search the memory folder by keywords,
383394
list its contents, and append an explicit note. The layout it navigates is
384-
exactly the pyramid from earlier: summary → handbook → recaps and skills.
395+
exactly the pyramid from earlier: `memory_summary.md` → `MEMORY.md` →
396+
`rollout_summaries/` and `skills/`.
385397

386398
This is the retrieval-augmentation pattern in its most literal form, with a
387399
deliberate twist: **the store is plain text and the search is keywords**. No
@@ -399,7 +411,8 @@ thing stays local, inspectable, and dependency-free.
399411

400412
There is one deliberate write door during conversations: the user can say
401413
outright *"remember that …"*, and the agent appends the note as a small file
402-
that the next consolidation picks up through the normal diff channel. The
414+
under `extensions/ad_hoc/notes/` that the next consolidation picks up through
415+
the normal diff channel. The
403416
authority to *integrate* knowledge stays with the consolidator; the
404417
read path's writes are suggestions, not edits. This keeps the shared store
405418
single-writer while still letting users pin facts in real time.

0 commit comments

Comments
 (0)