Semantic Memory Plugin
The Semantic Memory plugin gives the assistant **its own long-term memory of
working with each user**: one-line notes — decisions and their reasons,
preferences and corrections, facts about the user and their projects, lessons
from mistakes — that the assistant sees an overview of at the start of every
conversation, and can search or expand with two tools.
It is not the organizational memory, and the two are
independent. Agentic Memory curates team-owned notes a background curator
files for everyone; Semantic Memory is per-user, private to the person the
assistant talked to, and written by the assistant itself in the moment — no
curator, no review queue. It is also not Episodic
Memory, which reads the user's past conversations;
Semantic Memory holds only the distilled one-liners the assistant chose to
save. A deployment can run either plugin, both, or neither.
Design: inspired by OptMem by Victor Taelin — an append-only log of one-line
memories summarized into a binary tree of blocks, from which an age-weighted
overview is shown at session start. No code was copied; see the package
docstring (src/codumentor/plugins/semantic_memory/__init__.py) for the
deliberate differences.
How it works
- Saving costs one tool call. When something of lasting value comes up, the main agent calls
memory_notewith one self-contained line (at mostentry_bytesUTF-8 bytes, default 280). It is told not to save what is already in memory, routine steps, easily re-derivable facts, or secrets. - The overview is injected, not fetched. At the start of every turn the plugin adds a
[Semantic Memory]prefix context note: recent memories verbatim, older history as ever broader summaries, laid out greedily by size-to-age ratio. The note is rendered once per conversation and cached, so the prompt prefix stays byte-stable (and cacheable); a memory saved mid-conversation appears in the next one. A memory the user deletes invalidates the cache at once. - Summaries are background work. A housekeeping model (role
semantic_memory_compressor, "Memory summaries"; falls back to the agent model) summarizes blocks of memories bottom-up in a binary tree, children before parents, after each save and on server start (catching up on work a restart left pending). Summaries carry the date span they cover. Withcompress_enabled: falsethere are no model calls at all: the overview shows raw memories instead and drops the oldest past twice its size. - Deletion is safe by construction. Deleted memories keep their row number (text cleared), so block boundaries and later ids never shift; the summaries of exactly the affected blocks are dropped and rebuilt, guarded by a per-user revision counter so a summary of something deleted meanwhile is never kept.
The tools
| Tool | Parameters | Returns |
|---|---|---|
memory_note | text (required, one self-contained line) | Saved as #<idx>. |
memory_recall | exactly one of query (case-insensitive regex over ' #id YYYY-MM-DD text' lines) or block (a summary id like #64-127 to expand) | The newest matching memories that fit the character budget, or the contents one level under a summary |
memory_note is deliberately not a write-tier tool: it writes only the
calling user's own private memory, so it needs no approval gate. Both tools
are token-bounded (recall_max_chars, default 8000).
Neither tool reaches subagents, internal sessions, or — unless
include_scheduled_runs is set — scheduled runs. There is no
target_agents: the memory belongs to the assistant the user talks to.
What the user controls
Settings → Extensions → Semantic Memory:
| Setting | Values | Default |
|---|---|---|
| Use semantic memory | on / off | on |
| Lines shown at conversation start | 8 – max_wake_lines | default_wake_lines (64) |
Turning the first setting off hides the memory and its tools from the
assistant; nothing is deleted. The panel also hosts the memory explorer
(x-semantic-memory-explorer): the current overview with pending-summary
counts, search, adding a memory by hand, deleting one, or clearing all of
them (with confirmation).
Routes
Mounted at /ui/plugins/semantic_memory/, always scoped to the signed-in
user — there is no id to guess, and another user's data is unreachable.
| Method | Path | Purpose |
|---|---|---|
| GET | overview?lines= | What the assistant sees at conversation start, plus counts and compression status |
| GET | blocks/{block_id} | One level below a summary |
| GET | search?q= | Memories containing q (plain text), newest first |
| POST | memories | Add one memory |
| DELETE | memories/{idx} | Delete one memory |
| DELETE | memories?confirm=true | Delete every memory of the caller |
Configuration
Ships enabled in the default shipped config, which carries this block:
plugins:
- module: codumentor.plugins.semantic_memory
class: SemanticMemoryPlugin
args:
enabled: true
| Parameter | Type | Default | Description |
|---|---|---|---|
enabled | bool | true | Whether the plugin is active. |
include_scheduled_runs | bool | false | Also give scheduled runs (goal workers, timed and webhook tasks) the memory and its tools. |
default_wake_lines | int 8–400 | 64 | Overview lines injected for a user who has not chosen (about 60 tokens a line). |
max_wake_lines | int 8–400 | 160 | The most lines a user may choose. |
entry_bytes | int 80–280 | 280 | Most UTF-8 bytes in one memory or one summary. |
raw_max | int 2–64 | 16 | Blocks up to this many memories are summarized from the memories themselves; bigger ones from their two halves' summaries. Should be a power of two. |
recall_max_chars | int 1000–40000 | 8000 | Most characters one memory_recall result may return. |
compress_enabled | bool | true | Summarize blocks in the background with a model. Off: no model calls, the overview shows raw memories and trims the oldest. |
compress_model_role | string \ | null | semantic_memory_compressor |
db_path | string \ | null | null |
Notes
- Storage. One SQLite file (WAL mode) for all users, rows keyed by user:
memories(append-only, per-user numbering),summaries(keyed by block size and position, derived data), and arevisionscounter per user that guards summary writes against concurrent deletions. - Observability.
capabilities()["semantic_memory"]carries whether the plugin is enabled, its tool names, and the compressor's stats snapshot. - A broken store never breaks a turn. Overview building and settings reads are wrapped: on failure the turn proceeds without the note.
- For plugin authors: the injected note is a prefix context note with marker
[Semantic Memory]and sourcesemantic_memory, added throughadd_context_note. - Ships in Community and Full editions (per-user, no organizational data —
src/codumentor/editions.py).