Public surface for Cogtrix’s hybrid memory subsystem — rolling summary, semantic recall, and three working modes.
cogtrix_core.memory.base
The abstract base for a persistence backend. Extend it to plug in a custom store (e.g. Redis-backed) in place of the default JSON files.
Key types:
BaseMemoryStore— the ABC definingload_history(session_id)andsave_history(session_id, messages).
cogtrix_core.memory.manager
The base memory manager. Coordinates the three layers — working window, rolling summary, semantic recall — behind one interface. Each mode subclasses it.
Key symbols:
BaseMemoryManager— the ABC every mode extends.prepare_context(user_input)— build theMemoryContext(working window + hybrid prefix) for the next LLM call.update(user_input, ai_response, agent_messages=None)— record a completed turn.save()/load()— persist and restore session state (save is non-blocking).set_llm(llm)/set_embeddings(...)— inject the summariser LLM and the embedding function that power the hybrid layer.
cogtrix_core.memory.factory
Constructs the right manager for a given mode.
Key symbols:
MemoryFactory.create(mode, store, ...)— build the manager forconversation,code, orreasoning.MemoryFactory.register(mode, manager_class)— register a custom mode.MemoryFactory.available_modes()— list the registered mode names.
cogtrix_core.memory.facts
Persistent distilled facts for long-lived sessions — durable entity facts extracted from the rolling summary and kept across restarts.
Key symbols:
PersistentFactsStore— load/save the distilled facts for a session.FactsSnapshot— an immutable view of the current facts.
cogtrix_core.memory.recall
The semantic-recall layer. A per-session FAISS store embeds evicted turns at write time and returns the most similar ones at recall time.
Key symbols:
SessionVectorStore— the per-session vector index.SessionVectorStore.add_messages(messages)— embed and store evicted turns.SessionVectorStore.recall(query, k=3, ...)— return the most similar stored turns.