This file captures the work performed during the Codex CLI session so it can be shared with other assistants (e.g., ChatGPT) for continuity.
- Build a Raspberry Pi–friendly FastAPI microservice named “hippocampus.”
- Provide REST endpoints to store/query/summarize long-term memories backed by Mem0 (with an in-memory fallback).
- Ship code, docs, tests, and simple ops scaffolding (systemd service + dev script).
- Structure the repo with
brain/hippocampus/modules plus tests/docs/config.
-
Core service scaffolding
- FastAPI app with
/health,/memories(POST/GET),/summaries, and later/memories/{memory_id}DELETE. - Config loader (
brain/hippocampus/config.py) reading TOML + env overrides. - Logging setup (
brain/hippocampus/logging_config.py). - Mem0 adapter with auto fallback to an in-memory backend, including summary helper.
- Pydantic models for all request/response contracts.
- FastAPI app with
-
Project structure & tooling
.gitignore,pyproject.toml,requirements.txt, and README quickstart.- Example config (
config/hippocampus.toml). - Ops helpers:
ops/scripts/dev_run.shand sample systemd unit.
-
Tests
- Adapter tests for add/query/summarize/delete.
- API tests covering create/query/summarize/delete endpoints via FastAPI TestClient.
pytestruns clean inside.venv(6 tests passing).
-
Docs
docs/ARCHITECTURE.md(component overview).docs/API.mddescribing each HTTP endpoint and payload.- README updated with delete capability and Mem0 install guidance.
-
Persistence fallback
- Added a SQLite-backed storage backend (with configurable path) that is now the default when Mem0 cloud access is unavailable.
- Extended adapter tests to cover persistence, retrieval, and deletion flows to ensure offline durability.
-
Self-hosted Mem0 integration
- Added configuration flags for
mem0.enabledandmem0.backend_url, plus aMem0RemoteClientwrapper for a LAN-accessible Mem0 deployment. Mem0Adapternow routes through the remote backend when enabled and automatically falls back to the in-memory store if the SDK/import fails or runtime calls error out.- Expanded tests and docs to describe the self-hosted expectation, fallback strategy, and optional SQLite mode.
- Added configuration flags for
-
Code Quality & Refactoring
- Introduced
ruffandmypyfor linting and type checking (configured inpyproject.toml). - Refactored
matrix_respondlogic into a dedicatedBotRouterclass (brain/hippocampus/bot_router.py), simplifyingapp.py. - Enhanced
Mem0Adaptererror handling to distinguish between configuration errors (missing SDK) and connection issues. - Added comprehensive tests for
BotRoutercovering Sam, Agno, and fallback summarization strategies.
- Introduced
- Implemented memory deletion flow (
DELETE /memories/{memory_id}) and updated docs/tests to keep the API complete.
- Integrate with the official Mem0 SDK when available and adapt delete/query semantics to match the live API.
- Consider authentication/authorization for multi-tenant deployments.
- Add persistence beyond the in-memory fallback (e.g., file or database) if Mem0 cloud is unavailable.
- Enhance summarisation by delegating to an LLM-backed service once defined.
python3 -m venv .venv
source .venv/bin/activate
pip install -r requirements.txt
export HIPPOCAMPUS_CONFIG=config/hippocampus.toml
uvicorn brain.hippocampus.app:app --reloadRun tests:
source .venv/bin/activate
pytestThis log can be shared verbatim with other assistants to give them full context on what has been built so far and what potential follow-up tasks exist.