feat(agent-memory): Phase 1 — remember() write path#248
Open
jamby77 wants to merge 1 commit into
Open
Conversation
ffc0fd3 to
cecbb45
Compare
- MemoryStore.remember(): embed content, HSET {name}:mem:{id} hash with
content, encoded vector, scope fields, importance (default 0.5), tags csv,
source, created_at/last_accessed_at, access_count=0; returns the id
- Validate embedding dimension on first write; mismatch throws
- Extract pure buildMemoryRecord() and unit-test it standalone
- Export memory types (EmbedFn, MemoryScope, RememberOptions, MemoryStoreOptions)
fe9da3d to
b433d60
Compare
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.
Agent Memory — Phase 1:
remember()write pathStacked on #247 (Phase 0) — base is the Phase 0 branch.
What's new
MemoryStore.remember(content, options?)→ embeds content (once), HSETs the{name}:mem:{id}hash withcontent, encodedvector, scope fields (threadId/agentId/namespace),importance(default 0.5),tags(CSV),source,created_at/last_accessed_at,access_count=0; returns the id.buildMemoryRecord()extracted and unit-tested standalone.EmbedFn,MemoryScope,RememberOptions,MemoryStoreOptions.Tests
9 unit tests (mocked client + deterministic
fakeEmbed);tsc --noEmit+ prettier clean.Review-driven changes
,), so a comma inside a tag would silently break Phase 2 filtering.tagswhen empty (consistent with the other optional fields) rather than writing''.RememberOptionsto only implemented fields — removedttl/metadataso the API doesn't advertise options Phase 1 doesn't honor (they return with their phases:ttl→ Phase 5).Deferred
Next
Phase 2 (
recall()ranking — composite score pure-math first, then KNN) stacks on this.Note
Low Risk
New write-only API in agent-memory with validation and broad test coverage; no changes to auth or existing recall paths yet.
Overview
Implements Phase 1 of agent long-term memory:
MemoryStore.remember()persists embedded text to Valkey as{name}:mem:{id}hashes via HSET, and returns a new UUID.MemoryStoreis wired withclient,name, andembedFn. Each remember call embeds once, builds the hash fields throughbuildMemoryRecord(), and writes them. Embedding dimension is pinned on first write; later vectors with a different length throw (aligned with semantic-cache behavior).buildMemoryRecord()maps content, float32-encoded vector, scope (threadId/agentId/namespace), optional tags (comma-separated), source, importance (default 0.5), timestamps, andaccess_count=0. Empty optional fields are omitted; tags containing commas are rejected so TAG indexing stays safe for Phase 2.New
types(EmbedFn,MemoryStoreClient,RememberOptions, etc.) and package exports are added. Nine unit tests cover remember integration and record building (mock client +fakeEmbed).Reviewed by Cursor Bugbot for commit b433d60. Bugbot is set up for automated code reviews on this repo. Configure here.