The author developed a memory system for AI agents using PostgreSQL and the pgvector extension to manage knowledge graphs. The system separates current context, short-term memory, session history, and a shared knowledge graph to prevent agents from relying on outdated information or irrelevant facts.
As of November 8, 2026, the database contained 10,079 nodes and 13,127 edges. The system uses a capture process to extract entities and relationships from user messages in Telegram, verifying them against original quotes to ensure accuracy. Each event is processed within a database transaction to prevent duplicate entries.
The search mechanism combines lexical analysis, graph traversal, and vector similarity. PostgreSQL performs vector searches using 384-dimension embeddings with a cosine distance threshold of 0.80. A specific gap of 0.02 is applied to differentiate between top candidates, preventing ambiguous results.
The system manages context limits by providing a specific character budget to the agent, such as 2,800 characters for the Hermes agent. The reader ensures that facts are truncated by full lines to maintain coherence. A small test conducted on August 4, 2026, showed that the lexical search mode retrieved expected facts in 4 out of 6 cases.






