feat(memory): add DakeraMemory for persistent cross-session agent memory - #1567
feat(memory): add DakeraMemory for persistent cross-session agent memory#1567ferhimedamine wants to merge 1 commit into
Conversation
There was a problem hiding this comment.
Code Review
This pull request introduces the DakeraMemory class, which provides persistent, vector-based memory for BeeAI agents by integrating with the Dakera REST API. The implementation includes methods for storing messages, recalling semantically relevant memories, and managing session-based memory deletion. I have reviewed the code and identified a potential type safety issue regarding the serialization of the createdAt metadata field, for which I have provided a suggested fix.
Important
The consumer version of Gemini Code Assist on GitHub is being sunset. Starting June 18, 2026, new organization installations will be blocked, and all code review activity will officially cease on July 17, 2026.
For more details on the timeline and next steps, please review the Help Documentation.
|
@Tomas2D — continuing our review from #1547 here (that PR got auto-closed after an accidental force-push dropped its shared history with Everything from your last review is addressed:
The commit is now signed off, so DCO is green. The only thing still pending is the fork I also left an open question in the description about whether a first-party |
c2c658a to
df1df3f
Compare
A BaseMemory adapter backed by a self-hosted Dakera server: persists each message and injects top-K decay-weighted recalled memories into the context window. Read-only (persist=false), API key excluded from snapshots, non-fatal outages via the framework Logger, and exposed via the beeai-framework/memory subpath. Endpoints verified against the Dakera server source (/v1/memory/store, /recall, /forget). Rebased onto main as a single clean commit (drops an earlier merge commit). Signed-off-by: Mohamed Amine Ferhi <ferhi.med.amine@gmail.com>
df1df3f to
a15bdd5
Compare
|
@Tomas2D kind reminder 🙏 thx |
Summary
Adds
DakeraMemory— aBaseMemoryimplementation that gives BeeAI agents persistent, semantically-searchable cross-session memory backed by a self-hosted Dakera server. It slots in exactly whereTokenMemory/SlidingMemorydo, so any agent can gain long-term recall by swapping itsmemoryinstance.Closes #1546
What this PR adds
typescript/src/memory/dakeraMemory.ts(440 lines) — fullBaseMemoryimplementation:add(message)→ persists the message to Dakera and enriches the context window with the top-K decay-weighted recalled memoriesdelete(message)→ removes from the in-session listreset()→ clears the in-session window (the Dakera store is unaffected)recall(query, topK?)/forgetSession()→ explicit recall + per-session cleanup helperscreateSnapshot/loadSnapshot— BeeAI serializer support (the API key is never serialized)static { this.register() }— enrolled with the framework serializer, matching theTokenMemory/SlidingMemorypatterntypescript/src/memory/dakeraMemory.test.ts(243 lines) — 10 Vitest unit tests, all HTTP-mocked (no live server required).How it works
Run Dakera locally with the public
dakera-ai/dakera-deploydocker-compose (the server needs the object store the compose provisions — a baredocker runof the image is not enough):API mapping
add()(persist=true)POST /v1/memory/storeadd()recall injection /recall()POST /v1/memory/recallforgetSession()POST /v1/memory/forgetEndpoints were verified against the Dakera server source.
Design decisions
persist: false— read-only mode (recalls but never writes). Useful for replaying prior conversations without polluting the store.createSnapshot()omitsapiKey; on deserialization it is dropped and must be re-supplied for write access.Logger(warn) and the agent continues; the in-session window always retains the current turn.meta: { __dakera_injected: true }so it can be filtered; prior injections are purged before fresh ones (prevents unbounded growth), including on a no-hit recall.Testing
TypeScript-only change (no Python).
yarn vitest run src/memory/dakeraMemory.test.ts)yarn tsc --noEmit,yarn eslint,yarn prettier --checkall cleanyarn tsupbuild emitsdist/memory/dakeraMemory.{js,cjs,d.ts}— importable via thebeeai-framework/memory/*subpath export, like every built-in memoryserialize()→fromSerialized()round-trip verified withverifyDeserialization; a secret-leak regression test asserts the API key never appears in the checkpointSigned-off-by) — DCO check greenReview follow-ups (addressed)
Incorporates @Tomas2D's review from the prior revision:
verifyDeserializationfrom@tests/e2e/utils.js; dropped@jest/globals.apiKeyremoved fromcreateSnapshot()/loadSnapshot(); added a regression test.console.warn→ frameworkLogger; the class builds todist/and is importable via the standardmemory/*subpath.POST /v1/memory/recall(the decay-weighted agent recall endpoint) instead of/v1/memory/search.:3000and pointed setup atdakera-deploy; clarified the change is TypeScript-only.Also folded in the Gemini review findings (read-only injection, purge-on-no-hit,
createdAttype guard, test placeholders).Open question for maintainers
This adds a first-party adapter under core
src/memory/. If the team would prefer community/third-party adapters to live in a contrib location instead, I'm happy to relocate it — just let me know.Continues #1547 (same branch, same two files). The original was auto-closed after an accidental branch force-push dropped its shared history with
main; history is restored and the commit is signed off here. #1547 is not reopenable because GitHub pins a closed PR to its recorded head.