Skip to content

feat(agent-memory): Phase 1 — remember() write path#248

Open
jamby77 wants to merge 1 commit into
feature/agent-memory-phase0-scaffoldfrom
feature/agent-memory-phase1-remember
Open

feat(agent-memory): Phase 1 — remember() write path#248
jamby77 wants to merge 1 commit into
feature/agent-memory-phase0-scaffoldfrom
feature/agent-memory-phase1-remember

Conversation

@jamby77

@jamby77 jamby77 commented Jun 16, 2026

Copy link
Copy Markdown
Collaborator

Agent Memory — Phase 1: remember() write path

Stacked 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 with content, encoded vector, scope fields (threadId/agentId/namespace), importance (default 0.5), tags (CSV), source, created_at/last_accessed_at, access_count=0; returns the id.
  • Dimension validation on first write — a later embedding with a mismatched length throws (mirrors semantic-cache).
  • Pure buildMemoryRecord() extracted and unit-tested standalone.
  • Memory types exported: EmbedFn, MemoryScope, RememberOptions, MemoryStoreOptions.

Tests

9 unit tests (mocked client + deterministic fakeEmbed); tsc --noEmit + prettier clean.

Review-driven changes

  • Reject commas in tags — tags are stored CSV and indexed as TAG fields (separator ,), so a comma inside a tag would silently break Phase 2 filtering.
  • Omit tags when empty (consistent with the other optional fields) rather than writing ''.
  • Trimmed RememberOptions to only implemented fields — removed ttl/metadata so the API doesn't advertise options Phase 1 doesn't honor (they return with their phases: ttl → Phase 5).

Deferred

  • Concurrent first-write dims race — low-likelihood (needs a non-deterministic embed dim) and superseded in Phase 2 once the FT index's dimension becomes authoritative.

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.

MemoryStore is wired with client, name, and embedFn. Each remember call embeds once, builds the hash fields through buildMemoryRecord(), 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, and access_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.

@jamby77 jamby77 force-pushed the feature/agent-memory-phase0-scaffold branch from ffc0fd3 to cecbb45 Compare June 18, 2026 06:53
- 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)
@jamby77 jamby77 force-pushed the feature/agent-memory-phase1-remember branch from fe9da3d to b433d60 Compare June 18, 2026 06:57
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant