1. Executive Summary
Mem++ is AIDAChip's organizational memory engine for LLM agents, published as a self-contained replica of an internal production engine. It keeps every record whole, with its event date and contributor, in one PostgreSQL table, and writes through its main path with no model call. A question is answered by a scope and date filter, three ranked legs fused by weighted reciprocal rank, and three slots reserved for the latest-dated matches.
Notable: the event-time bound sits in the base query of every read, so a question can be asked of the record as it stood on a date. Automatic consolidation picks a conflict's winner by event time rather than ingest order. The scope boundary is tested against populated neighbours, and the dated evaluation records state their protocol, cost and confidence intervals.
Weak: automatic supersession writes valid_to and a
pointer and leaves the loser active, and recall reads neither column, so
the old value is delivered unmarked beside its replacement. Scope keys
come from an environment variable or the OS login. Comments in the
configuration and the store describe ranking constants the defaults do
not use, and no CI runs the suite.
Three marks are present and four are withheld (section 9).
Licence. The grant covers a copy, not the system the
paper measured. pyproject.toml calls the package a
"faithful replica" of the AIDAChip engine, that engine is not
in the tree, and the README says the entity-graph variant
Memg++ in the paper's tables is not packaged. The licence is
Apache-2.0 in LICENSE, whose appendix is left as the
template, so the tree carries no copyright line, and
pyproject.toml declares no licence.
eval/judge.py reproduces Mem0's Apache-2.0 judge prompt and
LongMemEval's MIT prompts with their notices. SECURITY.md
describes a local research tool with no authentication or tenant
isolation and names no private reporting channel.
2. Mental Model
A record is a document, not a fact. The verbatim write stores the
text as given, dated by the caller, and never asks a model what it means
(memory/recall.py:313-324). Interpretation happens at read
time, by ranking and, on the opt-in path, by one listwise model
call.
Two sets of columns decide what a reader can see and what is on
record. is_active is the filter every read applies.
valid_to and superseded_by_id record that a
value was replaced (memory/models.py:154-165). They are
separate on purpose: automatic conflict supersession sets the second
pair and leaves is_active true, which the code calls the
"queryable-A property"
(memory/consolidation.py:274-296). A manual retire from the
Memory tab sets all three (memory/mutate.py:100-132).
The consequence is that an automatically superseded value reaches a
reader as any other row does. Recall returns summary, date, hit count
and contributor (memory/recall.py:102-116), so the
answering model sees two dated claims and must choose. That is the
design's thesis; the paper's abstract puts it as leaving "the choice
to the answering model".
Diagram source
%% caption: only is_active decides what recall can return; automatic supersession leaves it true, so the replaced value is delivered unmarked
flowchart TD
V["store_facts_verbatim<br/>no model call"] --> ROW
G["demo post-turn hook<br/>one Haiku call"] --> ROW
ROW["agent_memory row<br/>occurred_at, valid_from,<br/>created_at, is_active"]
ROW --> SC{"own scope or team pool,<br/>is_active, and<br/>occurred_at before θ?"}
SC -- "no" --> OUT["not a candidate"]
SC -- "yes" --> LEGS["lexical, tag, vector<br/>weighted RRF<br/>+ 3 latest-dated slots"]
LEGS --> EV["rows to the reader:<br/>text, date, author"]
ROW --> CON["consolidate(persona)<br/>cosine at least 0.85"]
CON --> CL{"Haiku: conflict,<br/>restatement, distinct?"}
CL -- "conflict" --> SUP["losers get valid_to<br/>and superseded_by_id;<br/>is_active stays true"]
CL -- "restatement" --> ARC["new root row;<br/>children inactive"]
SUP --> SC
ARC --> SC
HUM["Memory tab retire"] --> RET["valid_to set,<br/>is_active false"]
RET --> SC3. Architecture
memory/ is the engine. store.py holds the
write and the ranked read, recall.py the persona-level API
and scope derivation, consolidation.py the merge and
supersession pass, mutate.py the manual retire, merge and
reset, and browse.py the read-only views the demo uses.
turn_context/ is a separate, opt-in read pipeline behind
ports. aml_api.py and memoryarena_api.py are
WSGI services for external benchmark harnesses.
snapshots.py, snapshot_pages.py,
snapshot_merge.py and object_store.py are an
alternative backend: each session loads one published SQLite snapshot
into memory and a writer publishes changed chunks with a conditional put
(memory/snapshots.py:1-5).
chat/ is a Gradio demo that replays the production hook
loop: recall before the reply, extraction and storage after it
(chat/engine.py:1-20). eval/ is the benchmark
harness, and integrations/ packages adapters for
MemoryBench, LongMemEval v2, benchd and MemoryArena.
Deployment and ergonomics
One PostgreSQL 16 or 17 with pgvector, migrated by Alembic, and
Python 3.13. Embeddings default to an ONNX export of MiniLM-L6 run in
process, so the core write and read paths need no API key; OpenAI
embeddings need their own database because the column is fixed at 384
dimensions (memory/config.py:91-103). The demo listens on
loopback only and refuses any other host
(chat/app.py:401-409). The object-store backend needs a
store with conditional writes and searches differently, and the README
says its published scores do not describe that backend.
4. Essential Implementation Paths
- Scope.
_scopederives the user fromMEMORY_USERor the OS login and the project and customer from fixed names, overridden by theproject_scopecontext manager (memory/recall.py:52-88). - Verbatim write.
store_facts_verbatim→_persist_facts: skip a summary that is active in the same scope, thenstore.writeper fact (memory/recall.py:160-221,:313-324). - Row write.
PostgresMemoryStore.write: idempotent onsource_message_id,valid_fromfromoccurred_at, full-text vector and embedding in process, tags reconciled against the scope's registry, commit (memory/store.py:158-237). - Recall.
recall_facts→recall_project_sections: a team pass capped at eight, then the caller's own scope, own rows first (memory/recall.py:119-157,memory/store.py:527-585). - Rank.
_recall_scoped: recency pool, lexical, tag and vector legs, weighted RRF, then the reserve (memory/store.py:341-525). - Hit writeback.
record_recall_hits: oneUPDATEsettinglast_used_atandsalienceon every returned row andhit_counton relevance matches (memory/store.py:587-632). - Consolidate.
consolidate→_consolidate_pool: group, classify, then supersede, merge or skip; upsert the ledger row (memory/consolidation.py:363-446,:503-544). - HTTP add and search.
AMLService.addwrites one row per message with a receipt in the same transaction;searchrecalls with no hit writeback (memory/aml_api.py:89-167).
5. Memory Data Model
agent_memory: id;created_at,last_used_at,occurred_at;hit_count,last_hit_by,salience;memory_tier; scope columnsuser_id,customer_id,project_id,agent_type, withsession_idas provenance only;disciplineandauthority;is_active;valid_from,valid_to,superseded_by_id;content,context_summary,agent_summary,content_tsv,embedding;source_message_id;parent_id(memory/models.py:118-200).memory_tagandmemory_tag_link: a canonical label registry keyed onuser|persona|project, unique per label (memory/models.py:226-254).memory_consolidation_run: one row per scope key, overwritten on each run with the latest counts (memory/models.py:273-291,memory/consolidation.py:473-500).memory_api_request: a receipt per HTTP add, keyed on a hash of scope and request id, with the payload digest to refuse a reused id (memory/models.py:257-270).
Times: created_at is the server's clock.
occurred_at is the caller's event date, or the model's on
the extraction path. valid_from copies
occurred_at when one is given and is otherwise the record
time (memory/store.py:220-221). authority is
written only from an argument no caller passes, and the Memory tab
labels it "Authority / trust level"
(chat/memory_tab.py:225).
6. Retrieval Mechanics
The scope list is the first filter on every leg: user, persona,
project with NULL matching NULL,
is_active, and occurred_at bounds when given
(memory/store.py:324-333). An undated row fails any bound
(memory/recall.py:133-134).
Four candidate lists are drawn from that base. The recency slice is a
pool, not a ranking signal. The lexical leg ORs the stop-word-stripped
query terms into a to_tsquery and ranks by
ts_rank_cd, after a comment recording that the conjunctive
form returned zero rows for 70% of 60 LoCoMo questions
(memory/store.py:378-407). The tag leg matches normalised
query terms against the scope's tag labels. The vector leg orders by
cosine distance on the HNSW index. Each leg takes up to 200 rows.
Fusion is weighted reciprocal rank with k = 60 and
weights 1.0, 1.0 and 2.0 for lexical, tag and vector
(memory/config.py:54-80). Rows sort by fused score, then
log hit count, then a seven-day recency decay. The top
k − 3 are taken by rank and three more by latest event date
among the remaining relevance matches
(memory/store.py:487-509).
Hits feed back. Every relevance-matched row returned by
recall_facts increments hit_count, which
breaks ties in later rankings; the HTTP search and snapshot readers skip
the writeback (memory/aml_api.py:152-155,
memory/store.py:601).
The opt-in turn-context path runs the default recall, a
conversation-aware vector lane and a salient-term keyword lane in
parallel under the same scope predicate
(memory/turn_context/adapters.py:88-104). One listwise call
to a configured model, claude-opus-5-5 by default, keeps a
subset; a failed or timed-out call injects up to 24 rows with no model
(memory/config.py:140-151).
What reaches the reader is text and a date. The demo prefixes each
row with its date (chat/engine.py:118-131). The harness
passes the stored text alone (eval/harness.py:160-162), and
its stored text carries the date and speaker inline
(eval/adapters/base.py:25-28). Nothing on either path says
a row was superseded.
7. Write Mechanics
The verbatim path blocks for one embedding computed in process and
one commit; a record is retrievable when the call returns
(memory/store.py:223-237). An exact summary that is active
in the same scope is skipped, and a source_message_id makes
a retried write return the existing row
(memory/recall.py:191-203,
memory/store.py:184-196).
The demo's post-turn hook calls store_facts in
auto mode, which resolves to the gated path: one Haiku call
decides whether the turn is worth storing and returns a summary, tags,
an event date and an agent-stated section
(memory/recall.py:224-273,
memory/extraction.py:1-13). With no model available the
turn is not stored and the result says why. Atomic fact fan-out exists
behind MEMORY_ATOMIC_FACTS, off by default
(memory/config.py:35).
The HTTP add endpoint writes each message as
role: content with its timestamp, refuses the whole request
if any embedding is missing, and commits the rows and the receipt
together (memory/aml_api.py:111-137).
No background pass rewrites the store. Consolidation runs when a
person presses the demo's button or the harness calls it, over one
scope's active, current, embedded rows; rows tagged
confidential or pinned are excluded
(memory/consolidation.py:363-396,
:129-132).
Operational cost
The main write and read paths cost no model calls. The demo's write costs one Haiku call per turn. Consolidation costs one classification call per near-duplicate group and one merge call per restatement. The turn-context path costs one selector call per read, which the committed evaluation records at about $0.035 a question on LoCoMo and $0.16 on LongMemEvalS.
8. Agent Integration
There is no MCP server or tool registry. An agent reaches memory
through the Python API, through the demo's hook replay, or through the
HTTP services built for external evaluation harnesses. The AML service
accepts only /add and /search behind a bearer
token of at least 32 characters, compared in constant time
(memory/aml_api.py:83-87, :185-187). The
MemoryArena facade adds initialize, add and
wrap_user_prompt on the same base
(memory/memoryarena_api.py:35-60).
The demo's Memory tab gives a person browse, inspect, retire, merge,
reset and consolidate, each behind a confirm box or a one-click button
(chat/memory_tab.py:346-439, :586-614). The
model in the demo has no tool that writes memory; its post-turn write is
the hook's.
9. Reliability, Safety, and Trust
Supersession that recall does not read
supersede_conflict closes each loser's interval at the
winner's event date and points it at the winner, leaving
is_active true
(memory/consolidation.py:285-296). The recall path filters
is_active and reads neither valid_to nor
superseded_by_id; the only reads of valid_to
in memory/ are the consolidation pool, the browse view and
a model property (memory/consolidation.py:383,
memory/browse.py:162, memory/models.py:205).
The old value competes for the same slots and arrives with no mark. That
is the stated design, and it means the supersession is on record for a
person browsing and invisible to the reader.
Scope is a selector
The user id is a hash of MEMORY_USER or the OS login,
and project_scope says of itself that it is "a scope
selector, not authentication"
(memory/recall.py:52-88). Team recall spans every persona
and user in the project. The Memory tab gates its actions on the project
pool only, so one persona's rows can be retired from another's view
(memory/mutate.py:83-97). SECURITY.md states
the boundary: single user, loopback, no tenant isolation.
What the comments say and the code does
memory/config.py:13-16 lists vector weight 4.0 and a
candidate cap of 50; the defaults are 2.0 and 200 (:73,
:80). The degraded-path warning comment in
memory/store.py:105 repeats 4.0 of 6.0.
memory/config.py:40-42 says no ported code reads
MEMORY_SUPERSESSION;
memory/consolidation.py:403 reads it. The configuration's
own note says the OrgMemBench numbers were measured under 4.0 and 50 and
fall at the default (memory/config.py:66-72).
Deletion
The one hard delete empties all three memory tables
(memory/mutate.py:199-220). No path erases one record.
Marks
bitemporal— present.valid_fromfrom the event date beside the server'screated_at, and automatic supersession closesvalid_toin event time and picks the winner by it. No read filters on the interval, and manual retires write wall-clock time into it.scope_enforced— present. User, persona and exact project on every recall, with a team pass on customer and project, applied on the default and turn-context paths; the keys are selectors, not identities.negative_eval— present. Populated cases keep another project, another customer, an inactive row, and later or undated rows out of default recall and each lane.trust_state— withheld.is_activeis a lifecycle flag that automatic supersession leaves true, andauthorityhas no writer.tombstone— withheld. A retired value is a row withis_activefalse, and the duplicate check counts active rows only (memory/recall.py:191-201), so the same text stored again is a new active record.audit_log— withheld. The consolidation ledger is one overwritten row per scope and the HTTP receipt records requests; a retire's reason is logged and never stored (memory/mutate.py:123-124).human_review— withheld. Every write takes effect at once; the Memory tab edits after the fact.
10. Tests, Evals, and Benchmarks
581 pytest functions in 53 files: 152 engine tests, 151 harness
tests, 135 for the turn-context pipeline, 76 for the demo, 30 end-to-end
and 37 in the benchmark adapters. The engine and end-to-end suites skip
their PostgreSQL cases when MEMORY_DATABASE_URL is unset or
unreachable (tests_engine/conftest.py:39-50), and several
mutation, consolidation and scope tests run on SQLite instead. No CI
workflow is committed. I ran none of them.
The scope cases are the strongest.
test_org_sharing_survives_and_other_examples_are_excluded
requires recall in one example's scope to return exactly its two facts
while another example holds a matching one, on SQLite and on PostgreSQL
(eval/tests/test_project_scope.py:55-69). The lane tests
build a world of own, teammate, other-project, other-customer and
inactive rows on one topic, and an as-of case with a dated-before, a
dated-after and an undated row
(tests_engine/test_turn_context_lanes.py:83-176).
Two cases are weaker than their names. The manual-retire test seeds
one row, retires it, and asserts no returned summary mentions it over a
recall with nothing left to return
(tests_engine/test_mutate.py:66-82). The conflict test
dates its two rows in ingest order, so it cannot fail if the winner were
picked by record time
(tests_engine/test_consolidation.py:205-231).
A paper describes the system: Mem++: Non-Destructive Memory for
Long-Term Organizational LLM Agents, listed in the README as arXiv:2610.02002, with the
anonymous ICLR 2027 submission committed as
paper/mempp_iclr2027_submission.pdf. Its abstract matches
the code's write and read paths; its entity-graph variant is not in the
tree. Dated evaluations under docs/evaluations/ commit
protocols and summary JSON; the per-question run files are gitignored,
so run means recompute and confidence intervals do not.
11. For Your Own Build
Steal
- Put the as-of bound in the base filter. Every leg and the reserve slots see only rows dated before θ, so a past question cannot be answered from a later document.
- Pick a conflict's winner by event time. A document ingested late about an old decision does not overwrite the more recent one.
- Reserve slots for the latest-dated matches. Three
of
kkept for recency among relevance matches puts the current version beside the most similar one. - Test scope against a populated neighbour. An exact expected set beside a matching row in another scope fails the way a leak does.
Avoid
- Do not record a supersession the reader cannot see.
If
valid_tois written, either filter on it or render it beside the row. - Do not derive identity from the OS login. A shared service needs a key that the caller cannot choose.
- Do not leave tuning constants in comments. Two comments state weights the defaults abandoned.
Fit
Fits a team evaluating organizational memory as a research question, or a single user who wants verbatim, dated recall with no model on the write path and a date bound on every read. Whatever you build, the dated evaluation records show how to report a memory result: protocol, cost, latency and a paired interval beside every delta.
Walk away if several people share a deployment and must not read each other's projects, if a replaced value must stop reaching the agent, or if one record must be erasable.
12. Open Questions
- Whether recall is meant to render
valid_toor the superseding row, since consolidation computes both. - Which RRF weights and candidate cap the paper's OrgMemBench tables used, given the configuration note that they do not reproduce at the defaults.
- Whether the production engine this replicates filters
is_activethe same way on the automatic path. - Whether
authorityhas a producer in the production engine.
Appendix: File Index
- Engine:
memory/store.py,memory/recall.py,memory/models.py,memory/config.py - Consolidation and edits:
memory/consolidation.py,memory/mutate.py,memory/browse.py - Extraction and model calls:
memory/extraction.py,memory/llm.py - Turn-context path:
memory/turn_context/ - HTTP services:
memory/aml_api.py,memory/memoryarena_api.py - Object-store backend:
memory/snapshots.py,memory/snapshot_pages.py,memory/snapshot_merge.py,memory/object_store.py,docs/object-store.md - Schema:
alembic/versions/0001_initial_schema.py,alembic/versions/0002_memory_consolidation_run.py,alembic/versions/0003_memory_api_request.py - Demo:
chat/engine.py,chat/memory_tab.py,chat/app.py - Harness:
eval/harness.py,eval/memory_client.py,eval/adapters/ - Tests:
tests_engine/,tests/,eval/tests/,chat/test_*.py - Paper and results:
paper/mempp_iclr2027_submission.pdf,docs/evaluations/
Recorded searches
Run from the repository root at the pinned commit with
/usr/bin/git grep.
- Recall reads no validity column.
git grep -n -E 'valid_to|valid_from' -- memoryreturns writers inmemory/store.py:221,memory/aml_api.py:130,memory/mutate.py:119andmemory/consolidation.py:285-353, reads atmemory/consolidation.py:383,memory/browse.py:161-162andmemory/models.py:205, and docstrings; nothing in the read path ofmemory/store.py, inmemory/recall.pyor inmemory/turn_context/. authorityhas no producer.git grep -n -E 'authority *=' -- '*.py'returnsmemory/store.py:208only, the pass-through of thewriteargument.- No append-only mutation record.
git grep -n -E '__tablename__|op.create_table\(' -- memory alembicreturns five tables;git grep -n -i -E 'audit|event_log|changelog|history' -- memory alembicreturns docstrings and comments only. - No single-record delete.
git grep -n -E '\.delete\(|DELETE FROM' -- memory chatreturnsmemory/mutate.py:214-216, the full reset, andmemory/snapshot_merge.py:62, which replays a writer's row diff. - No tombstone.
git grep -n -i -E 'tombstone' -- .returns nothing;git grep -n -i -E 'tombstone|blocklist|denylist|reject' -- memoryreturns embedding size checks, a merge-conflict docstring and a word list inmemory/turn_context/_render.py:28. - No MCP server.
git grep -n -i -l 'mcp' -- .returns an SVG and the paper PDF. - No CI.
git ls-files .githubreturns nothing. - The paper.
CITATION.cffis absent;git grep -n -i -E 'arxiv|doi\.org|bibtex' -- README.md llms.txtreturns the paper links atREADME.md:10,:36,:538, the BibTeX block atREADME.md:838-846andllms.txt:32.
History
2026-12-04 — c145d119….
First reading, from the 2026-12-03 triage shortlist, at the head of
main reached on 2026-12-04; the shortlist had assessed
c224b619fca1. Screened: no auto-run surface; four
build-time execution points (eval/tests/conftest.py,
tests/conftest.py,
tests/turn_context/conftest.py,
tests_engine/conftest.py); two dependency surfaces inside
the cooldown (pyproject.toml, uv.lock), a
count the depth-1 clone inflates; no unpinned surface;
AGENTS.md and CLAUDE.md read as data. Nothing
was installed, built or run, and none of the 581 test functions was run.
Three marks (section
9).