Repository navigation
Conversation
The file-path pattern also matched decimals, versions, and addresses with no letter (0.52, 127.0.0.1) and dotted abbreviations (e.g, i.e), and the acronym pattern admitted ordinary words written in capitals for emphasis or as labels (NEVER, ONLY, NOTE, FIXED). On a real store these were among the most frequent stored entities, and entity edges linked memories that shared nothing but a decimal or an emphasis word. File-path matches now need a letter and a dot-separated segment longer than one character, and the acronym stoplist gains the emphasis words while leaving out words that double as technical names (HEAD, POST, PATH). Validated with make test.
With MNEMON_EXTRACT_MODEL and MNEMON_EXTRACT_ENDPOINT set, remember and import ask a System One extraction model such as Cloudflare Clairic for the entities of a memory that arrives without any. The request runs before the write transaction, and deterministic code keeps only names that appear in the memory as whole tokens, so the model can add the multi-word names the regex misses but cannot invent or truncate one. Model entities replace only the all-caps acronym guess; the exact patterns and the known-entity index still apply, because the model splits paths and versions that those patterns match exactly. A missing or failing model prints one warning and falls back to heuristic extraction, and import stops asking after the first failure. Memories stored with entities and recall queries never call the model. Validated with make test and a live remember against Clairic on Workers AI.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Stacked on #169: the first commit is that PR. Review 47a2204.
What
An opt-in entity extraction model for
rememberandimport.internal/memory/extractis a client configured byMNEMON_EXTRACT_MODEL,MNEMON_EXTRACT_ENDPOINT(the full URL, for example Workers AI.../ai/run/@cf/cloudflare/clairic),MNEMON_EXTRACT_API_KEY, andMNEMON_EXTRACT_TIMEOUT. It sends the memory asstatewith onelistfield and accepts both the Workers AI envelope and a bare System One response.TWinzh-TW,5.1in5.1.0,w/demoin~/w/demo). Duplicates and items past 50 are dropped, matching the--entitieslimits.graph.ResolveEntitiesWithModeluses the model's entities only when resolution relies on extraction alone: merge mode with nothing provided, or auto mode. They replace the all-caps acronym guess, while CamelCase, file paths, URLs, @mentions, title marks, the dictionary, and the known-entity index still apply.importstops asking after the first failure.Why
The regex finds identifiers, paths, and acronyms but misses most names: multi-word people and organizations, and single-segment names on first mention. Agent hosts usually pass entities, but hooks, imports, and other writers often do not. An extraction model returns spans of the input in one input-only pass (about 0.5 to 0.9 s per memory with Clairic, billed only for input tokens), so it fits a write path without a generative LLM.
The exact regex paths stay because, in probes on real memories, the model split paths (
~/andw/...), cut versions, and left trailing brackets, which are the cases those patterns match exactly. Clairic's list-level confidence came back near 1e-12 on every call, so the client does not threshold on it.Effect
Live
rememberagainst Clairic on Workers AI, into a throwaway store:Privacy
Off unless
MNEMON_EXTRACT_MODELis set. When it is set, the full text of each memory stored without entities goes to the endpoint; README and SECURITY.md say so.Validation
internal/memory/extract: request shape, both response shapes, whole-token grounding, the 50-item cap, a null list, and errors that name the failure without the key or the content.internal/memory/graph: resolution per entity mode, nil versus empty model output, and provided entities bypassing the model.cmd/memory:rememberwith a working, skipped, and failing model;importasking only for drafts without entities and stopping after the first failure.gofmt -lis clean andmake test(includinggo vet ./...) passes.Relation to #161
Independent of the decision-model judge in #161. Both add rows to the same env tables and a package to the Makefile list and architecture graph, so whichever merges second needs a small rebase. The CLI tests use their own stderr helper so the two PRs do not redeclare one.
Release note
Set
MNEMON_EXTRACT_MODEL(for example Cloudflare Clairic) to haverememberandimportextract entities from memories stored without them.