engram-lite 0.1.0__tar.gz

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (38) hide show
  1. engram_lite-0.1.0/.gitignore +37 -0
  2. engram_lite-0.1.0/CHANGELOG.md +15 -0
  3. engram_lite-0.1.0/LICENSE +202 -0
  4. engram_lite-0.1.0/PKG-INFO +199 -0
  5. engram_lite-0.1.0/README.md +166 -0
  6. engram_lite-0.1.0/pyproject.toml +56 -0
  7. engram_lite-0.1.0/src/engram/__init__.py +30 -0
  8. engram_lite-0.1.0/src/engram/cli/__init__.py +5 -0
  9. engram_lite-0.1.0/src/engram/cli/demo.py +60 -0
  10. engram_lite-0.1.0/src/engram/cli/main.py +99 -0
  11. engram_lite-0.1.0/src/engram/config.py +79 -0
  12. engram_lite-0.1.0/src/engram/core/__init__.py +5 -0
  13. engram_lite-0.1.0/src/engram/core/anchors.py +101 -0
  14. engram_lite-0.1.0/src/engram/core/compaction.py +51 -0
  15. engram_lite-0.1.0/src/engram/core/consolidation.py +91 -0
  16. engram_lite-0.1.0/src/engram/core/dates.py +129 -0
  17. engram_lite-0.1.0/src/engram/core/entities.py +61 -0
  18. engram_lite-0.1.0/src/engram/core/eviction.py +36 -0
  19. engram_lite-0.1.0/src/engram/core/extraction.py +107 -0
  20. engram_lite-0.1.0/src/engram/core/memory.py +583 -0
  21. engram_lite-0.1.0/src/engram/core/promotion.py +153 -0
  22. engram_lite-0.1.0/src/engram/core/redaction.py +44 -0
  23. engram_lite-0.1.0/src/engram/core/retrieval.py +188 -0
  24. engram_lite-0.1.0/src/engram/core/rrf.py +25 -0
  25. engram_lite-0.1.0/src/engram/core/salience.py +213 -0
  26. engram_lite-0.1.0/src/engram/core/subjects.py +20 -0
  27. engram_lite-0.1.0/src/engram/core/tags.py +210 -0
  28. engram_lite-0.1.0/src/engram/embeddings/__init__.py +50 -0
  29. engram_lite-0.1.0/src/engram/embeddings/base.py +19 -0
  30. engram_lite-0.1.0/src/engram/embeddings/hashing.py +30 -0
  31. engram_lite-0.1.0/src/engram/embeddings/local.py +46 -0
  32. engram_lite-0.1.0/src/engram/integrations/__init__.py +4 -0
  33. engram_lite-0.1.0/src/engram/integrations/hermes.py +248 -0
  34. engram_lite-0.1.0/src/engram/settings.py +102 -0
  35. engram_lite-0.1.0/src/engram/storage/__init__.py +1 -0
  36. engram_lite-0.1.0/src/engram/storage/db.py +66 -0
  37. engram_lite-0.1.0/src/engram/storage/repository.py +329 -0
  38. engram_lite-0.1.0/src/engram/storage/schema.py +171 -0
@@ -0,0 +1,37 @@
1
+ # python
2
+ __pycache__/
3
+ *.py[cod]
4
+ *.egg-info/
5
+ dist/
6
+ build/
7
+ .venv/
8
+ venv/
9
+
10
+ # tooling
11
+ .pytest_cache/
12
+ .ruff_cache/
13
+ .coverage
14
+
15
+ # local memory stores (never commit a memory DB)
16
+ *.db
17
+ *.db-wal
18
+ *.db-shm
19
+ *.sqlite
20
+ *.sqlite3
21
+
22
+ # model cache (fastembed downloads here)
23
+ .fastembed_cache/
24
+ .cache/
25
+
26
+ # PyInstaller build outputs
27
+ *.spec.bak
28
+
29
+ # os
30
+ .DS_Store
31
+
32
+ # benchmark data (CC BY-NC — never redistributed) + local artifacts
33
+ benchmarks/locomo/data/
34
+ benchmarks/locomo/locomo/
35
+ benchmarks/locomo/*.jsonl
36
+ .env
37
+ *.log
@@ -0,0 +1,15 @@
1
+ # Changelog
2
+
3
+ ## 0.1.0 — first public release
4
+
5
+ - Local memory engine: SQLite + FTS5 + sqlite-vec in one file; salience gate,
6
+ ADD / UPDATE / REINFORCE consolidation, versioned facts with provenance,
7
+ expiry, and bounded size with eviction.
8
+ - **Conditioned promotion (the lane model):** register a profile per agent
9
+ (persona / domain / scope_tags) and every recall is served for that agent's
10
+ lane — IDF-weighted, relevance-floored, with honest abstention and an
11
+ explainable `why` on every served fact. Measured on our internal CAMP-Bench:
12
+ profile discrimination 0.00 → 0.90, task success 40% → 80%, hallucination
13
+ cut to a third versus a flat shared pile.
14
+ - Hermes integration: `engram.integrations.hermes.EngramMemoryProvider`
15
+ (initialize / system_prompt_block / prefetch / sync_turn / tools / shutdown).
@@ -0,0 +1,202 @@
1
+
2
+ Apache License
3
+ Version 2.0, January 2004
4
+ http://www.apache.org/licenses/
5
+
6
+ TERMS AND CONDITIONS FOR USE, REPRODUCTION, AND DISTRIBUTION
7
+
8
+ 1. Definitions.
9
+
10
+ "License" shall mean the terms and conditions for use, reproduction,
11
+ and distribution as defined by Sections 1 through 9 of this document.
12
+
13
+ "Licensor" shall mean the copyright owner or entity authorized by
14
+ the copyright owner that is granting the License.
15
+
16
+ "Legal Entity" shall mean the union of the acting entity and all
17
+ other entities that control, are controlled by, or are under common
18
+ control with that entity. For the purposes of this definition,
19
+ "control" means (i) the power, direct or indirect, to cause the
20
+ direction or management of such entity, whether by contract or
21
+ otherwise, or (ii) ownership of fifty percent (50%) or more of the
22
+ outstanding shares, or (iii) beneficial ownership of such entity.
23
+
24
+ "You" (or "Your") shall mean an individual or Legal Entity
25
+ exercising permissions granted by this License.
26
+
27
+ "Source" form shall mean the preferred form for making modifications,
28
+ including but not limited to software source code, documentation
29
+ source, and configuration files.
30
+
31
+ "Object" form shall mean any form resulting from mechanical
32
+ transformation or translation of a Source form, including but
33
+ not limited to compiled object code, generated documentation,
34
+ and conversions to other media types.
35
+
36
+ "Work" shall mean the work of authorship, whether in Source or
37
+ Object form, made available under the License, as indicated by a
38
+ copyright notice that is included in or attached to the work
39
+ (an example is provided in the Appendix below).
40
+
41
+ "Derivative Works" shall mean any work, whether in Source or Object
42
+ form, that is based on (or derived from) the Work and for which the
43
+ editorial revisions, annotations, elaborations, or other modifications
44
+ represent, as a whole, an original work of authorship. For the purposes
45
+ of this License, Derivative Works shall not include works that remain
46
+ separable from, or merely link (or bind by name) to the interfaces of,
47
+ the Work and Derivative Works thereof.
48
+
49
+ "Contribution" shall mean any work of authorship, including
50
+ the original version of the Work and any modifications or additions
51
+ to that Work or Derivative Works thereof, that is intentionally
52
+ submitted to Licensor for inclusion in the Work by the copyright owner
53
+ or by an individual or Legal Entity authorized to submit on behalf of
54
+ the copyright owner. For the purposes of this definition, "submitted"
55
+ means any form of electronic, verbal, or written communication sent
56
+ to the Licensor or its representatives, including but not limited to
57
+ communication on electronic mailing lists, source code control systems,
58
+ and issue tracking systems that are managed by, or on behalf of, the
59
+ Licensor for the purpose of discussing and improving the Work, but
60
+ excluding communication that is conspicuously marked or otherwise
61
+ designated in writing by the copyright owner as "Not a Contribution."
62
+
63
+ "Contributor" shall mean Licensor and any individual or Legal Entity
64
+ on behalf of whom a Contribution has been received by Licensor and
65
+ subsequently incorporated within the Work.
66
+
67
+ 2. Grant of Copyright License. Subject to the terms and conditions of
68
+ this License, each Contributor hereby grants to You a perpetual,
69
+ worldwide, non-exclusive, no-charge, royalty-free, irrevocable
70
+ copyright license to reproduce, prepare Derivative Works of,
71
+ publicly display, publicly perform, sublicense, and distribute the
72
+ Work and such Derivative Works in Source or Object form.
73
+
74
+ 3. Grant of Patent License. Subject to the terms and conditions of
75
+ this License, each Contributor hereby grants to You a perpetual,
76
+ worldwide, non-exclusive, no-charge, royalty-free, irrevocable
77
+ (except as stated in this section) patent license to make, have made,
78
+ use, offer to sell, sell, import, and otherwise transfer the Work,
79
+ where such license applies only to those patent claims licensable
80
+ by such Contributor that are necessarily infringed by their
81
+ Contribution(s) alone or by combination of their Contribution(s)
82
+ with the Work to which such Contribution(s) was submitted. If You
83
+ institute patent litigation against any entity (including a
84
+ cross-claim or counterclaim in a lawsuit) alleging that the Work
85
+ or a Contribution incorporated within the Work constitutes direct
86
+ or contributory patent infringement, then any patent licenses
87
+ granted to You under this License for that Work shall terminate
88
+ as of the date such litigation is filed.
89
+
90
+ 4. Redistribution. You may reproduce and distribute copies of the
91
+ Work or Derivative Works thereof in any medium, with or without
92
+ modifications, and in Source or Object form, provided that You
93
+ meet the following conditions:
94
+
95
+ (a) You must give any other recipients of the Work or
96
+ Derivative Works a copy of this License; and
97
+
98
+ (b) You must cause any modified files to carry prominent notices
99
+ stating that You changed the files; and
100
+
101
+ (c) You must retain, in the Source form of any Derivative Works
102
+ that You distribute, all copyright, patent, trademark, and
103
+ attribution notices from the Source form of the Work,
104
+ excluding those notices that do not pertain to any part of
105
+ the Derivative Works; and
106
+
107
+ (d) If the Work includes a "NOTICE" text file as part of its
108
+ distribution, then any Derivative Works that You distribute must
109
+ include a readable copy of the attribution notices contained
110
+ within such NOTICE file, excluding those notices that do not
111
+ pertain to any part of the Derivative Works, in at least one
112
+ of the following places: within a NOTICE text file distributed
113
+ as part of the Derivative Works; within the Source form or
114
+ documentation, if provided along with the Derivative Works; or,
115
+ within a display generated by the Derivative Works, if and
116
+ wherever such third-party notices normally appear. The contents
117
+ of the NOTICE file are for informational purposes only and
118
+ do not modify the License. You may add Your own attribution
119
+ notices within Derivative Works that You distribute, alongside
120
+ or as an addendum to the NOTICE text from the Work, provided
121
+ that such additional attribution notices cannot be construed
122
+ as modifying the License.
123
+
124
+ You may add Your own copyright statement to Your modifications and
125
+ may provide additional or different license terms and conditions
126
+ for use, reproduction, or distribution of Your modifications, or
127
+ for any such Derivative Works as a whole, provided Your use,
128
+ reproduction, and distribution of the Work otherwise complies with
129
+ the conditions stated in this License.
130
+
131
+ 5. Submission of Contributions. Unless You explicitly state otherwise,
132
+ any Contribution intentionally submitted for inclusion in the Work
133
+ by You to the Licensor shall be under the terms and conditions of
134
+ this License, without any additional terms or conditions.
135
+ Notwithstanding the above, nothing herein shall supersede or modify
136
+ the terms of any separate license agreement you may have executed
137
+ with Licensor regarding such Contributions.
138
+
139
+ 6. Trademarks. This License does not grant permission to use the trade
140
+ names, trademarks, service marks, or product names of the Licensor,
141
+ except as required for reasonable and customary use in describing the
142
+ origin of the Work and reproducing the content of the NOTICE file.
143
+
144
+ 7. Disclaimer of Warranty. Unless required by applicable law or
145
+ agreed to in writing, Licensor provides the Work (and each
146
+ Contributor provides its Contributions) on an "AS IS" BASIS,
147
+ WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or
148
+ implied, including, without limitation, any warranties or conditions
149
+ of TITLE, NON-INFRINGEMENT, MERCHANTABILITY, or FITNESS FOR A
150
+ PARTICULAR PURPOSE. You are solely responsible for determining the
151
+ appropriateness of using or redistributing the Work and assume any
152
+ risks associated with Your exercise of permissions under this License.
153
+
154
+ 8. Limitation of Liability. In no event and under no legal theory,
155
+ whether in tort (including negligence), contract, or otherwise,
156
+ unless required by applicable law (such as deliberate and grossly
157
+ negligent acts) or agreed to in writing, shall any Contributor be
158
+ liable to You for damages, including any direct, indirect, special,
159
+ incidental, or consequential damages of any character arising as a
160
+ result of this License or out of the use or inability to use the
161
+ Work (including but not limited to damages for loss of goodwill,
162
+ work stoppage, computer failure or malfunction, or any and all
163
+ other commercial damages or losses), even if such Contributor
164
+ has been advised of the possibility of such damages.
165
+
166
+ 9. Accepting Warranty or Additional Liability. While redistributing
167
+ the Work or Derivative Works thereof, You may choose to offer,
168
+ and charge a fee for, acceptance of support, warranty, indemnity,
169
+ or other liability obligations and/or rights consistent with this
170
+ License. However, in accepting such obligations, You may act only
171
+ on Your own behalf and on Your sole responsibility, not on behalf
172
+ of any other Contributor, and only if You agree to indemnify,
173
+ defend, and hold each Contributor harmless for any liability
174
+ incurred by, or claims asserted against, such Contributor by reason
175
+ of your accepting any such warranty or additional liability.
176
+
177
+ END OF TERMS AND CONDITIONS
178
+
179
+ APPENDIX: How to apply the Apache License to your work.
180
+
181
+ To apply the Apache License to your work, attach the following
182
+ boilerplate notice, with the fields enclosed by brackets "[]"
183
+ replaced with your own identifying information. (Don't include
184
+ the brackets!) The text should be enclosed in the appropriate
185
+ comment syntax for the file format. We also recommend that a
186
+ file or class name and description of purpose be included on the
187
+ same "printed page" as the copyright notice for easier
188
+ identification within third-party archives.
189
+
190
+ Copyright [yyyy] [name of copyright owner]
191
+
192
+ Licensed under the Apache License, Version 2.0 (the "License");
193
+ you may not use this file except in compliance with the License.
194
+ You may obtain a copy of the License at
195
+
196
+ http://www.apache.org/licenses/LICENSE-2.0
197
+
198
+ Unless required by applicable law or agreed to in writing, software
199
+ distributed under the License is distributed on an "AS IS" BASIS,
200
+ WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
201
+ See the License for the specific language governing permissions and
202
+ limitations under the License.
@@ -0,0 +1,199 @@
1
+ Metadata-Version: 2.4
2
+ Name: engram-lite
3
+ Version: 0.1.0
4
+ Summary: Local memory for AI agents — served by persona, domain, and task. Survives restarts. One machine, many agents.
5
+ Project-URL: Homepage, https://github.com/engrammemory-labs/engram-lite
6
+ Project-URL: Repository, https://github.com/engrammemory-labs/engram-lite
7
+ Project-URL: Issues, https://github.com/engrammemory-labs/engram-lite/issues
8
+ Project-URL: Changelog, https://github.com/engrammemory-labs/engram-lite/blob/main/CHANGELOG.md
9
+ Author: Novarque
10
+ License: Apache-2.0
11
+ License-File: LICENSE
12
+ Keywords: agents,ai,hermes,llm,memory
13
+ Classifier: Development Status :: 4 - Beta
14
+ Classifier: Intended Audience :: Developers
15
+ Classifier: License :: OSI Approved :: Apache Software License
16
+ Classifier: Operating System :: OS Independent
17
+ Classifier: Programming Language :: Python :: 3.10
18
+ Classifier: Programming Language :: Python :: 3.11
19
+ Classifier: Programming Language :: Python :: 3.12
20
+ Classifier: Programming Language :: Python :: 3.13
21
+ Classifier: Topic :: Scientific/Engineering :: Artificial Intelligence
22
+ Requires-Python: >=3.10
23
+ Requires-Dist: fastembed>=0.3.6
24
+ Requires-Dist: numpy>=1.26
25
+ Requires-Dist: sqlite-vec>=0.1.6
26
+ Provides-Extra: build
27
+ Requires-Dist: pyinstaller>=6; extra == 'build'
28
+ Provides-Extra: dev
29
+ Requires-Dist: anyio>=4; extra == 'dev'
30
+ Requires-Dist: pytest>=8; extra == 'dev'
31
+ Requires-Dist: ruff>=0.8; extra == 'dev'
32
+ Description-Content-Type: text/markdown
33
+
34
+ # engram-lite
35
+
36
+ **Local memory for AI agents, served by persona, domain, and task. Survives restarts. One machine, many agents.**
37
+
38
+ Most agent memory is a shared pile: every agent gets the same top-k for the same query. In our benchmark (methodology below), an agent fed flat shared memory **hallucinated more than an agent given no memory at all.** Serving each agent the memory that fits **who it is** (its persona, its domain, the task in front of it) **doubled task success (40% to 80%)** and **cut hallucination to a third.**
39
+
40
+ And the memory layer never calls an LLM. On **LoCoMo** — the long-conversation memory benchmark — engram-lite scores **J 68.3** with **zero LLM calls and $0 to build the memory**. The protocol, footnotes, and the full comparison against the leading LLM-based memory systems live in [`benchmarks/locomo/`](https://github.com/engrammemory-labs/engram-lite/blob/main/benchmarks/locomo/README.md).
41
+
42
+ engram-lite is that serving layer, small enough to run on your laptop:
43
+
44
+ - **Conditioned serving.** Register a profile per agent (persona / domain / scope). The same question serves your on-call SRE agent the alert, the trace, and the mitigation runbook, and serves your release agent the deploy, the rollback, and the freeze policy. Out-of-lane questions correctly serve nothing.
45
+ - **Restart-proof.** One SQLite file holds everything. Your agent restarts tomorrow and picks up exactly what it knew.
46
+ - **Self-cleaning.** A salience gate skips junk (code, command output, questions). New facts are de-duplicated, updates supersede old versions, stale facts expire, and the store stays bounded.
47
+ - **Zero infrastructure.** No server, no cloud, no accounts, no telemetry. SQLite plus a local embedding model. `pip install` and you are running.
48
+ - **Explainable forgetting.** Every drop, merge, truncation, and abstention is recorded with the rule that fired (`Memory.decisions()`). "Why don't you remember X?" has an answer — something an LLM-written memory can't give you, because its keep/drop decisions live inside model weights.
49
+ - **Deterministic and replayable.** Same transcript in, same memory out — byte-identical across rebuilds. Memory failures can be diffed, bisected, and regression-gated like any other bug.
50
+ - **Plugs into what you build with.** A Hermes memory provider, or three lines of Python.
51
+
52
+ > engram-lite is single-machine by design. A team/hosted edition, **engram-core**, is in development — reach out if that is what you need.
53
+
54
+ ## Install
55
+
56
+ ```bash
57
+ pip install engram-lite
58
+ ```
59
+
60
+ Or Docker (memory persists in the named volume):
61
+
62
+ ```bash
63
+ docker build -t engram-lite .
64
+ docker run -it --rm -v engram-data:/data engram-lite demo
65
+ ```
66
+
67
+ ## 60 seconds: see conditioned memory work
68
+
69
+ ```bash
70
+ python examples/restart_demo.py # two agents remember
71
+ python examples/restart_demo.py # run it AGAIN: memory survived, and the same
72
+ # question serves each agent different memory
73
+ ```
74
+
75
+ ## Use it from Python
76
+
77
+ ```python
78
+ from engram import Memory
79
+
80
+ mem = Memory("~/.engram/memory.db", origin_tool="oncall_sre")
81
+
82
+ # who is this agent? (this is what makes serving conditioned)
83
+ mem.register_profile(
84
+ "oncall_sre", persona="on-call SRE", domain="sre-devops",
85
+ scope_tags=["alert", "incident", "latency", "trace", "mitigation", "db"],
86
+ )
87
+
88
+ mem.remember("Alert PAGE-99 fired: payments p99 latency at 2.3s") # gated save
89
+ # conversational input? pass who said it and when — every extracted fragment
90
+ # keeps the anchors, and relative dates resolve to absolute ("last Friday"
91
+ # becomes "[= Friday, 5 May 2023]") with calendar math, no LLM:
92
+ mem.remember("The pool was resized last Friday. We watch it daily now.",
93
+ speaker="Raj", when="8 May, 2023")
94
+ hits = mem.search("what is going on with payments?",
95
+ agent="oncall_sre", task_tags=["incident", "latency"])
96
+ for h in hits:
97
+ print(h["value"], h["promotion"]["lane"]) # every result explains WHY it was served
98
+ ```
99
+
100
+ No profile registered? `search()` is plain hybrid retrieval (keyword + vector + RRF), so you can adopt gradually.
101
+
102
+ ## Plug into a Hermes agent
103
+
104
+ Three steps on any machine with Hermes installed:
105
+
106
+ ```bash
107
+ # 1. put the engine in Hermes's environment
108
+ pip install engram-lite
109
+ # (before the PyPI release, install straight from the repo instead:
110
+ # pip install git+https://github.com/engrammemory-labs/engram-lite.git)
111
+
112
+ # 2. install the memory plugin
113
+ hermes plugins install engrammemory-labs/engram-lite/hermes-plugin/engram
114
+
115
+ # 3. activate and configure it
116
+ hermes memory setup # choose "engram", answer one question — what is this
117
+ # agent? (e.g. "DevOps engineer") — everything else is
118
+ # derived; leave it empty for plain memory
119
+ ```
120
+
121
+ Then just `hermes chat`. From that point: every turn is auto-captured through the salience gate, the agent boots with a snapshot of what it already knows, and `memory_search` / `memory_write` / `memory_diagnose` are available as in-loop tools. Restart the agent; it remembers. Point several agents at one `db_path` (a wizard field) and the lane model keeps each one's serving scoped.
122
+
123
+ Building your own harness instead of Hermes? The same provider is a plain Python class:
124
+
125
+ ```python
126
+ from engram.integrations.hermes import EngramMemoryProvider
127
+
128
+ memory = EngramMemoryProvider(
129
+ db_path="~/.engram/memory.db",
130
+ agent="oncall_sre", persona="on-call SRE", domain="sre-devops",
131
+ scope_tags=["alert", "incident", "latency", "trace", "mitigation"],
132
+ )
133
+ # call initialize / system_prompt_block / prefetch / sync_turn / shutdown
134
+ ```
135
+
136
+ ## The numbers behind the claims
137
+
138
+ ### LoCoMo: long-conversation memory, zero LLM in the memory layer
139
+
140
+ LLM-judge score (J) on LoCoMo categories 1–4 (1,540 questions), under the evaluation protocol standard in the published literature:
141
+
142
+ | System | Overall J | Single-hop | Multi-hop | Temporal | Open-domain |
143
+ |---|---|---|---|---|---|
144
+ | Full-context baseline (no memory system) | 72.9 | — | — | — | — |
145
+ | **engram-lite** | **68.3** | **74.8** | **55.3** | **68.5** | 49.0 |
146
+
147
+ - **Zero LLM calls to build the memory.** Ingesting the 5,882-turn corpus costs $0 and takes about 2 minutes, fully local.
148
+ - On the adversarial category (trick questions where the right answer is "no information"): J 64.6. Honest abstention is a feature, not a failure mode.
149
+ - Retrieval alone (no LLM anywhere): 85.7% of questions have their evidence served in the top-30, vs 59.9% for grep over the raw transcript. Two from-scratch runs produce the identical digest.
150
+ - Answerer and judge: claude-haiku-4-5 (measured judge sensitivity: ±2 for prompt wording, ±0 for judge model). LoCoMo: Maharana et al. ([arXiv:2402.17753](https://arxiv.org/abs/2402.17753)). Full protocol notes in [`benchmarks/locomo/`](https://github.com/engrammemory-labs/engram-lite/blob/main/benchmarks/locomo/README.md).
151
+
152
+ ### What memory costs your prompt, per turn
153
+
154
+ Measured on a real 15-agent shared store (92 memories, 105 probes), same recall quality question for all three strategies:
155
+
156
+ | Strategy | Tokens injected/turn | Cross-domain leaks | Out-of-lane abstention |
157
+ |---|---|---|---|
158
+ | Whole memory file in the prompt | 2,071 | 85 per turn | 0% |
159
+ | Keyword top-10 over the file | 163 | 5.7 per turn | 0% |
160
+ | **engram-lite conditioned serving** | **29** | **0** | **100%** |
161
+
162
+ And the memory layer itself bills nothing: zero LLM calls at capture, zero at serving. (LLM-extraction pipelines spend ~2 model calls per captured turn to build memory; engram-lite spends none, and nothing leaves your machine.)
163
+
164
+ ### CAMP-Bench: conditioned serving vs the flat pile
165
+
166
+ We built a benchmark (CAMP-Bench) with human-authored gold across two engineering domains, 30 cases each: which memory should each role be served, per situation. (An internal benchmark: treat these as our numbers, not independently checkable ones. The LoCoMo results above are the externally replayable ones.) **This library, measured on its real read path** (three-signal retrieval funnel + lane promotion, offline stub embedder, k=3):
167
+
168
+ | domain | precision | recall | profile discrimination | correct abstention |
169
+ |---|---|---|---|---|
170
+ | sre-devops | 0.63 | 0.87 | 0.91 | 6/6 |
171
+ | backend-engineering | 0.56 | 0.85 | 0.92 | 3/3 |
172
+ | *flat serving (any domain)* | *~0.23* | *~0.55* | *0.00* | *0* |
173
+
174
+ Downstream, with a live agent and an independent judge on the same data, the lane model took task success from **40% (flat) to 80%** and cut hallucination from **33% to 10%**, while an agent with no memory scored 17%. Flat memory hallucinated more than no memory at all: **wrong memory is worse than no memory.**
175
+
176
+ ## How serving works (the lane model)
177
+
178
+ Each fact carries tags (extracted at write time from your profiles' vocabulary, or passed explicitly). At recall time:
179
+
180
+ ```
181
+ lane = task_tags ∩ agent.scope_tags # what this situation is about
182
+ # that THIS agent owns
183
+ empty lane -> serve nothing (honest abstention)
184
+ otherwise -> score facts by IDF-weighted overlap with the lane,
185
+ gate out other domains, apply a relevance floor,
186
+ serve at most k (fewer when little truly fits)
187
+ ```
188
+
189
+ Deterministic, microseconds, no LLM in the read path, and every served fact carries `why` (the lane tags it hit and its score).
190
+
191
+ ## Development
192
+
193
+ ```bash
194
+ pip install -e ".[dev]"
195
+ ruff check src
196
+ ```
197
+
198
+ ## License
199
+ Apache-2.0.
@@ -0,0 +1,166 @@
1
+ # engram-lite
2
+
3
+ **Local memory for AI agents, served by persona, domain, and task. Survives restarts. One machine, many agents.**
4
+
5
+ Most agent memory is a shared pile: every agent gets the same top-k for the same query. In our benchmark (methodology below), an agent fed flat shared memory **hallucinated more than an agent given no memory at all.** Serving each agent the memory that fits **who it is** (its persona, its domain, the task in front of it) **doubled task success (40% to 80%)** and **cut hallucination to a third.**
6
+
7
+ And the memory layer never calls an LLM. On **LoCoMo** — the long-conversation memory benchmark — engram-lite scores **J 68.3** with **zero LLM calls and $0 to build the memory**. The protocol, footnotes, and the full comparison against the leading LLM-based memory systems live in [`benchmarks/locomo/`](https://github.com/engrammemory-labs/engram-lite/blob/main/benchmarks/locomo/README.md).
8
+
9
+ engram-lite is that serving layer, small enough to run on your laptop:
10
+
11
+ - **Conditioned serving.** Register a profile per agent (persona / domain / scope). The same question serves your on-call SRE agent the alert, the trace, and the mitigation runbook, and serves your release agent the deploy, the rollback, and the freeze policy. Out-of-lane questions correctly serve nothing.
12
+ - **Restart-proof.** One SQLite file holds everything. Your agent restarts tomorrow and picks up exactly what it knew.
13
+ - **Self-cleaning.** A salience gate skips junk (code, command output, questions). New facts are de-duplicated, updates supersede old versions, stale facts expire, and the store stays bounded.
14
+ - **Zero infrastructure.** No server, no cloud, no accounts, no telemetry. SQLite plus a local embedding model. `pip install` and you are running.
15
+ - **Explainable forgetting.** Every drop, merge, truncation, and abstention is recorded with the rule that fired (`Memory.decisions()`). "Why don't you remember X?" has an answer — something an LLM-written memory can't give you, because its keep/drop decisions live inside model weights.
16
+ - **Deterministic and replayable.** Same transcript in, same memory out — byte-identical across rebuilds. Memory failures can be diffed, bisected, and regression-gated like any other bug.
17
+ - **Plugs into what you build with.** A Hermes memory provider, or three lines of Python.
18
+
19
+ > engram-lite is single-machine by design. A team/hosted edition, **engram-core**, is in development — reach out if that is what you need.
20
+
21
+ ## Install
22
+
23
+ ```bash
24
+ pip install engram-lite
25
+ ```
26
+
27
+ Or Docker (memory persists in the named volume):
28
+
29
+ ```bash
30
+ docker build -t engram-lite .
31
+ docker run -it --rm -v engram-data:/data engram-lite demo
32
+ ```
33
+
34
+ ## 60 seconds: see conditioned memory work
35
+
36
+ ```bash
37
+ python examples/restart_demo.py # two agents remember
38
+ python examples/restart_demo.py # run it AGAIN: memory survived, and the same
39
+ # question serves each agent different memory
40
+ ```
41
+
42
+ ## Use it from Python
43
+
44
+ ```python
45
+ from engram import Memory
46
+
47
+ mem = Memory("~/.engram/memory.db", origin_tool="oncall_sre")
48
+
49
+ # who is this agent? (this is what makes serving conditioned)
50
+ mem.register_profile(
51
+ "oncall_sre", persona="on-call SRE", domain="sre-devops",
52
+ scope_tags=["alert", "incident", "latency", "trace", "mitigation", "db"],
53
+ )
54
+
55
+ mem.remember("Alert PAGE-99 fired: payments p99 latency at 2.3s") # gated save
56
+ # conversational input? pass who said it and when — every extracted fragment
57
+ # keeps the anchors, and relative dates resolve to absolute ("last Friday"
58
+ # becomes "[= Friday, 5 May 2023]") with calendar math, no LLM:
59
+ mem.remember("The pool was resized last Friday. We watch it daily now.",
60
+ speaker="Raj", when="8 May, 2023")
61
+ hits = mem.search("what is going on with payments?",
62
+ agent="oncall_sre", task_tags=["incident", "latency"])
63
+ for h in hits:
64
+ print(h["value"], h["promotion"]["lane"]) # every result explains WHY it was served
65
+ ```
66
+
67
+ No profile registered? `search()` is plain hybrid retrieval (keyword + vector + RRF), so you can adopt gradually.
68
+
69
+ ## Plug into a Hermes agent
70
+
71
+ Three steps on any machine with Hermes installed:
72
+
73
+ ```bash
74
+ # 1. put the engine in Hermes's environment
75
+ pip install engram-lite
76
+ # (before the PyPI release, install straight from the repo instead:
77
+ # pip install git+https://github.com/engrammemory-labs/engram-lite.git)
78
+
79
+ # 2. install the memory plugin
80
+ hermes plugins install engrammemory-labs/engram-lite/hermes-plugin/engram
81
+
82
+ # 3. activate and configure it
83
+ hermes memory setup # choose "engram", answer one question — what is this
84
+ # agent? (e.g. "DevOps engineer") — everything else is
85
+ # derived; leave it empty for plain memory
86
+ ```
87
+
88
+ Then just `hermes chat`. From that point: every turn is auto-captured through the salience gate, the agent boots with a snapshot of what it already knows, and `memory_search` / `memory_write` / `memory_diagnose` are available as in-loop tools. Restart the agent; it remembers. Point several agents at one `db_path` (a wizard field) and the lane model keeps each one's serving scoped.
89
+
90
+ Building your own harness instead of Hermes? The same provider is a plain Python class:
91
+
92
+ ```python
93
+ from engram.integrations.hermes import EngramMemoryProvider
94
+
95
+ memory = EngramMemoryProvider(
96
+ db_path="~/.engram/memory.db",
97
+ agent="oncall_sre", persona="on-call SRE", domain="sre-devops",
98
+ scope_tags=["alert", "incident", "latency", "trace", "mitigation"],
99
+ )
100
+ # call initialize / system_prompt_block / prefetch / sync_turn / shutdown
101
+ ```
102
+
103
+ ## The numbers behind the claims
104
+
105
+ ### LoCoMo: long-conversation memory, zero LLM in the memory layer
106
+
107
+ LLM-judge score (J) on LoCoMo categories 1–4 (1,540 questions), under the evaluation protocol standard in the published literature:
108
+
109
+ | System | Overall J | Single-hop | Multi-hop | Temporal | Open-domain |
110
+ |---|---|---|---|---|---|
111
+ | Full-context baseline (no memory system) | 72.9 | — | — | — | — |
112
+ | **engram-lite** | **68.3** | **74.8** | **55.3** | **68.5** | 49.0 |
113
+
114
+ - **Zero LLM calls to build the memory.** Ingesting the 5,882-turn corpus costs $0 and takes about 2 minutes, fully local.
115
+ - On the adversarial category (trick questions where the right answer is "no information"): J 64.6. Honest abstention is a feature, not a failure mode.
116
+ - Retrieval alone (no LLM anywhere): 85.7% of questions have their evidence served in the top-30, vs 59.9% for grep over the raw transcript. Two from-scratch runs produce the identical digest.
117
+ - Answerer and judge: claude-haiku-4-5 (measured judge sensitivity: ±2 for prompt wording, ±0 for judge model). LoCoMo: Maharana et al. ([arXiv:2402.17753](https://arxiv.org/abs/2402.17753)). Full protocol notes in [`benchmarks/locomo/`](https://github.com/engrammemory-labs/engram-lite/blob/main/benchmarks/locomo/README.md).
118
+
119
+ ### What memory costs your prompt, per turn
120
+
121
+ Measured on a real 15-agent shared store (92 memories, 105 probes), same recall quality question for all three strategies:
122
+
123
+ | Strategy | Tokens injected/turn | Cross-domain leaks | Out-of-lane abstention |
124
+ |---|---|---|---|
125
+ | Whole memory file in the prompt | 2,071 | 85 per turn | 0% |
126
+ | Keyword top-10 over the file | 163 | 5.7 per turn | 0% |
127
+ | **engram-lite conditioned serving** | **29** | **0** | **100%** |
128
+
129
+ And the memory layer itself bills nothing: zero LLM calls at capture, zero at serving. (LLM-extraction pipelines spend ~2 model calls per captured turn to build memory; engram-lite spends none, and nothing leaves your machine.)
130
+
131
+ ### CAMP-Bench: conditioned serving vs the flat pile
132
+
133
+ We built a benchmark (CAMP-Bench) with human-authored gold across two engineering domains, 30 cases each: which memory should each role be served, per situation. (An internal benchmark: treat these as our numbers, not independently checkable ones. The LoCoMo results above are the externally replayable ones.) **This library, measured on its real read path** (three-signal retrieval funnel + lane promotion, offline stub embedder, k=3):
134
+
135
+ | domain | precision | recall | profile discrimination | correct abstention |
136
+ |---|---|---|---|---|
137
+ | sre-devops | 0.63 | 0.87 | 0.91 | 6/6 |
138
+ | backend-engineering | 0.56 | 0.85 | 0.92 | 3/3 |
139
+ | *flat serving (any domain)* | *~0.23* | *~0.55* | *0.00* | *0* |
140
+
141
+ Downstream, with a live agent and an independent judge on the same data, the lane model took task success from **40% (flat) to 80%** and cut hallucination from **33% to 10%**, while an agent with no memory scored 17%. Flat memory hallucinated more than no memory at all: **wrong memory is worse than no memory.**
142
+
143
+ ## How serving works (the lane model)
144
+
145
+ Each fact carries tags (extracted at write time from your profiles' vocabulary, or passed explicitly). At recall time:
146
+
147
+ ```
148
+ lane = task_tags ∩ agent.scope_tags # what this situation is about
149
+ # that THIS agent owns
150
+ empty lane -> serve nothing (honest abstention)
151
+ otherwise -> score facts by IDF-weighted overlap with the lane,
152
+ gate out other domains, apply a relevance floor,
153
+ serve at most k (fewer when little truly fits)
154
+ ```
155
+
156
+ Deterministic, microseconds, no LLM in the read path, and every served fact carries `why` (the lane tags it hit and its score).
157
+
158
+ ## Development
159
+
160
+ ```bash
161
+ pip install -e ".[dev]"
162
+ ruff check src
163
+ ```
164
+
165
+ ## License
166
+ Apache-2.0.