feat(agent-memory): Phase 10 — AgentMemory facade#258
Open
jamby77 wants to merge 2 commits into
Open
Conversation
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 268b946. Configure here.
abeea66 to
339567e
Compare
268b946 to
a409ab0
Compare
339567e to
312772a
Compare
a409ab0 to
aa75783
Compare
312772a to
22b6f78
Compare
aa75783 to
7a0812f
Compare
22b6f78 to
b160dd0
Compare
7a0812f to
65a592a
Compare
b160dd0 to
b29dd7e
Compare
65a592a to
8915dfe
Compare
- AgentMemory wraps AgentCache (.llm/.tool/.session, unchanged) and a MemoryStore (.memory) behind one construct, sharing the client, the resolved name prefix, and the telemetry registry - Require embedFn for the memory tier (clear error if missing) - Map the memory sub-config (defaultThreshold, recall.weights/halfLife, maxItemsPerScope, discovery, configRefresh) onto MemoryStore - initialize() awaits discovery readiness for both tiers; close() tears down both (memory first, cache in finally so neither leak) - Discover the memory tier by default in the facade (opt-out via memory.discovery:false); add MemoryStore.ensureDiscoveryReady()
b29dd7e to
4ea754e
Compare
8915dfe to
a0accf8
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.

Stacked on #257 (Phase 9 — observability).
What
Phase 10 of
@betterdb/agent-memory: theAgentMemoryconvenience facade so a caller gets all four tiers from one construct.AgentCache(exposing.llm/.tool/.session) + aMemoryStore(.memory), sharing the client, the resolved name prefix, and the telemetry registry.embedFn— throws a clear error if missing (checked before any resource is constructed).memorysub-config ontoMemoryStore(verified end-to-end viacurrentConfig()).initialize()awaits discovery readiness for both tiers;close()tears down both (memory first,cache.shutdown()in afinally).Design / review notes (fixes applied)
options.name ?? 'betterdb_ac') and passed explicitly to both AgentCache and MemoryStore, so their key prefixes / discovery markers / stats keys can never drift even if AgentCache's internal default changes.memory.discovery: false). StandaloneMemoryStorestays opt-in. AddedMemoryStore.ensureDiscoveryReady()soinitialize()can await it.close()runscache.shutdown()in afinally, so a failingmemory.close()can't leave cache timers/heartbeats running.agent_cache_*vsagent_memory_*) are intentional; only the prom registry is shared.Tests (
AgentMemory.test.ts, 9)exposes 4 tiers · embedFn-missing throws · memory wired to shared client+prefix · custom name prefix · sub-config mapping via
currentConfig()·initialize()/close()drive both (spy) · memory marker registered by default · memory discovery opt-out · one shared prom registry (agent_cache_*+agent_memory_*).95/95 package tests green ·
tscclean · prettier clean.Note
Low Risk
New facade and lifecycle wiring with no changes to core recall/storage algorithms; risk is mainly integration (shared client/name, dual teardown) covered by tests.
Overview
Introduces
AgentMemory, a single entry point that exposes short-termllm/tool/sessiontiers (viaAgentCache) and long-termmemory(MemoryStore) from one constructor.Construction requires
embedFn, resolvesnameonce for both tiers (defaultbetterdb_ac), maps thememorysub-config (threshold, recall weights/half-life, caps, discovery, config refresh), and optionally shares one Prometheus registry across cache and memory metrics.initialize()awaits discovery readiness for cache and memory;close()shuts down memory first and always runscache.shutdown()in afinallyto avoid timer/heartbeat leaks. Memory discovery defaults on in the facade (opt out withmemory.discovery: false);MemoryStore.ensureDiscoveryReady()is added so initialization can await registration.Package exports and a new
AgentMemory.test.tssuite cover wiring, prefixes, config mapping, discovery markers ({name}:mem), and shared telemetry.Reviewed by Cursor Bugbot for commit a0accf8. Bugbot is set up for automated code reviews on this repo. Configure here.