feat(agent-memory-py): Phase 13a — read-only MemoryStore methods#274
Conversation
Standalone, dependency-free package mirroring the TypeScript @betterdb/valkey-search-kit: float32 vector encoding (encode/decode), TAG escaping, bytes-aware FT.SEARCH reply parsing, version-skew-tolerant FT.INFO parsing (dimension + stats), and index-not-found error classification. 37 ported tests, all passing. Foundation for the betterdb-retrieval and betterdb-agent-memory Python ports, and consolidates helpers currently duplicated in semantic-cache-py/utils.py (refactored onto this package next). Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
Exact Python equivalent of the TypeScript agent-memory package: the long-term MemoryStore tier (remember/recall/reinforce/forget/consolidate, scoped capacity eviction, live config refresh, discovery, telemetry + spans) plus the AgentMemory facade over agent-cache. Full test suite mirrors the TS specs (124 tests). Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
Port of @betterdb/agent-memory PR #270 to the Python binding: - embed_fn is now optional with a _require_embed_fn() guard; remember/ recall/ensure_index raise a clear error when absent, read-only stores work. - get(id), list(MemoryListOptions) (scope/tag filter, created_at DESC, paginated), stats() (FT.INFO num_docs + evictions + config), recall_by_vector() for KNN by a precomputed vector. - recall now delegates to a shared _run_recall pipeline (behavior preserved). - Unscoped queries use MATCH_ALL_MEMORY_QUERY (@created_at:[-inf +inf]) instead of a bare * which valkey-search rejects on a vector index; the eviction unscoped-skip sentinel was updated to match. - created_at marked SORTABLE for server-side list ordering. - New types MemoryStats/MemoryListOptions/MemoryListResult and exports. 136 tests pass (12 new mirroring the TS suites).
There was a problem hiding this comment.
Cursor Bugbot has reviewed your changes and found 1 potential issue.
❌ Bugbot Autofix is OFF. To automatically fix reported issues with cloud agents, enable autofix in the Cursor dashboard.
Reviewed by Cursor Bugbot for commit 7f456d1. Configure here.
| "namespace", | ||
| "SORTBY", | ||
| "created_at", | ||
| "DESC", |
There was a problem hiding this comment.
List breaks old memory indexes
Medium Severity
New list() uses SORTBY on created_at, but ensure_index() never alters an existing index. Stores whose index was created before created_at gained SORTABLE will fail FT.SEARCH on list() after upgrade, while recall, get, and stats can still work.
Additional Locations (2)
Reviewed by Cursor Bugbot for commit 7f456d1. Configure here.
There was a problem hiding this comment.
There is no previous version publicly released, so the upgrade path is a non issue
…y-py-13a-read-methods # Conflicts: # packages/agent-memory-py/betterdb_agent_memory/__init__.py # packages/agent-memory-py/betterdb_agent_memory/agent_memory.py # packages/agent-memory-py/betterdb_agent_memory/build_memory_index.py # packages/agent-memory-py/betterdb_agent_memory/build_recall_query.py # packages/agent-memory-py/betterdb_agent_memory/memory_store.py # packages/agent-memory-py/betterdb_agent_memory/types.py # packages/agent-memory-py/tests/test_build_memory_index.py # packages/agent-memory-py/tests/test_build_recall_query.py # packages/agent-memory-py/tests/test_memory_store_config.py # packages/agent-memory-py/tests/test_memory_store_eviction.py # packages/valkey-search-kit-py/betterdb_valkey_search_kit/ft_info.py # packages/valkey-search-kit-py/betterdb_valkey_search_kit/ft_search.py # packages/valkey-search-kit-py/tests/test_ft_info.py # packages/valkey-search-kit-py/tests/test_ft_search.py


Summary
Port of #270 for the python libs
Changes
Checklist
roborev review --branchor/roborev-review-branchin Claude Code (internal)Note
Medium Risk
Changes query strings and index schema (SORTABLE, match-all) used by list, recall, and capacity checks; existing indexes may need recreation, but behavior is aligned with valkey-search vector constraints.
Overview
Adds read-only
MemoryStoreAPIs:get(hash by id),list(scopedFT.SEARCHwithSORTBY created_at DESC, pagination),stats(index doc count + eviction counter + config), andrecall_by_vectorso KNN recall works without text embedding.embed_fnis now optional on construction;remember,recall, andensure_indexraise a clear error when it is missing, while the read paths above do not need it.Unscoped filters no longer use bare
*(invalid on vector indexes). They use exportedMATCH_ALL_MEMORY_QUERY(@created_at:[-inf +inf]), withcreated_atmarked SORTABLE in the index for list sorting. Recall logic is refactored into shared_run_recall.Tests are reorganized: new coverage for get/list/stats/optional embed/recall_by_vector; several older unit test modules were removed from this package in the diff.
Reviewed by Cursor Bugbot for commit 7cd37b1. Bugbot is set up for automated code reviews on this repo. Configure here.