How I Implemented Memory in my AI Agent REXA A developer implemented a long-term memory pipeline for the REXA AI agent, enabling users to explicitly save preferences via a save_memory tool. The CLI sends memory text through an authenticated HTTP API to the REXA website backend, which verifies the bearer token, generates embeddings, and stores entries in PostgreSQL with pgvector. Memory retrieval is not yet implemented; only the saving pipeline is complete. One thing I wanted REXA to eventually have was long-term memory . The idea is simple: when I explicitly tell REXA something like: “Remember that I prefer PostgreSQL for my backend projects.” REXA should be able to save that information so it can be used later. The important distinction is that REXA does not currently retrieve these memories yet . Today, the implemented part is the memory-saving pipeline . Retrieval is the next part I plan to build. I also didn't put the memory database directly inside the REXA CLI. Instead, I built the memory infrastructure behind the REXA website backend and let the CLI communicate with it through an authenticated HTTP API. The architecture looks like this: REXA CLI │ │ POST + Bearer Token │ { "text": "..." } ▼ REXA Website Backend │ ├── Verify Token ├── Identify User ├── Process Text ├── Generate Embeddings └── Store Memory │ ▼ PostgreSQL + pgvector One important design decision is that REXA does not automatically save every preference or every piece of conversation. Instead, the model uses a tool called: save memory When the user explicitly asks REXA to remember something, the model calls this tool. For example: User: Remember that I use Bun for my backend projects. REXA can decide that the appropriate action is to call: save memory ... So memory creation is currently explicit , rather than REXA silently storing everything the user says. save memory The save memory tool receives the text that the user wants to store. Before sending it to the backend, the CLI performs some basic validation. The CLI: This means extremely large documents may never leave the CLI in the first place. For normal memory entries, however, the text can then be sent to the backend. The REXA CLI does not directly access PostgreSQL or pgvector. Instead, it sends a POST request to the REXA backend: POST https://rexa-server.onrender.com/api/cli/memory Authorization: Bearer