Skip to content

feat(agent-memory-py): Phase 13a — read-only MemoryStore methods#274

Merged
KIvanow merged 4 commits into
masterfrom
feature/agent-memory-py-13a-read-methods
Jun 25, 2026
Merged

feat(agent-memory-py): Phase 13a — read-only MemoryStore methods#274
KIvanow merged 4 commits into
masterfrom
feature/agent-memory-py-13a-read-methods

Conversation

@KIvanow

@KIvanow KIvanow commented Jun 24, 2026

Copy link
Copy Markdown
Member

Summary

Port of #270 for the python libs

Changes

Checklist

  • Unit / integration tests added
  • Docs added / updated
  • Roborev review passed — run roborev review --branch or /roborev-review-branch in Claude Code (internal)
  • Competitive analysis done / discussed (internal)
  • Blog post about it discussed (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 MemoryStore APIs: get (hash by id), list (scoped FT.SEARCH with SORTBY created_at DESC, pagination), stats (index doc count + eviction counter + config), and recall_by_vector so KNN recall works without text embedding.

embed_fn is now optional on construction; remember, recall, and ensure_index raise 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 exported MATCH_ALL_MEMORY_QUERY (@created_at:[-inf +inf]), with created_at marked 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.

KIvanow and others added 3 commits June 23, 2026 10:53
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).
@KIvanow KIvanow requested a review from jamby77 June 24, 2026 08:07
@KIvanow KIvanow marked this pull request as ready for review June 24, 2026 08:07

@cursor cursor Bot left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Cursor Bugbot has reviewed your changes and found 1 potential issue.

Fix All in Cursor

❌ 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",

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

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)
Fix in Cursor Fix in Web

Reviewed by Cursor Bugbot for commit 7f456d1. Configure here.

Copy link
Copy Markdown
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

There is no previous version publicly released, so the upgrade path is a non issue

@jamby77 jamby77 left a comment

Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

lgtm

Base automatically changed from feat/agent-memory-py to master June 25, 2026 06:51
…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
@KIvanow KIvanow merged commit 4295ea7 into master Jun 25, 2026
2 of 3 checks passed
@KIvanow KIvanow deleted the feature/agent-memory-py-13a-read-methods branch June 25, 2026 07:46
@github-actions github-actions Bot locked and limited conversation to collaborators Jun 25, 2026
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants