Index
memory
¶
Native persistent long-term memory for OpenJarvis.
This package provides the automatic memory service that extracts durable facts
from conversations in the background and persists them across sessions. It is
started and stopped as part of the jarvis serve / jarvis chat lifecycle
and configured via the [memory] section of config.toml.
Classes¶
FactExtractor
¶
FactExtractor(engine: Any, model: str, *, temperature: float = 0.0, max_tokens: int = 512, max_facts_per_turn: int = 10, max_fact_chars: int = 200, system_prompt: Optional[str] = None)
Extract memory-worthy facts from a conversation turn via an engine.
Source code in src/openjarvis/memory/extractor.py
Functions¶
extract
¶
Return durable facts from the exchange. Never raises.
Source code in src/openjarvis/memory/extractor.py
MemoryService
¶
MemoryService(store: FactStore, extractor: FactExtractor, *, max_queue: int = 256)
Background long-term-memory extraction and persistence service.
Source code in src/openjarvis/memory/service.py
Functions¶
start
¶
Start the background worker thread (idempotent).
Source code in src/openjarvis/memory/service.py
stop
¶
Signal the worker to drain and stop, then join it (idempotent).
Source code in src/openjarvis/memory/service.py
submit
¶
Queue an exchange for extraction. Non-blocking; never raises.
Returns True if the job was enqueued, False if the service is not running or the queue is full (in which case the exchange is dropped rather than blocking the caller — extraction is best-effort).
Source code in src/openjarvis/memory/service.py
Fact
dataclass
¶
A single durable memory entry.
FactStore
¶
LocalFactStore
¶
Bases: FactStore
Append-only JSONL fact store on the local filesystem.
Facts are kept human-readable (one JSON object per line) so they can be
inspected or edited by hand. Writes are atomic (temp file + rename) and
guarded by a lock, so concurrent add calls from the extraction worker
and list/clear from the CLI never corrupt the file.
Source code in src/openjarvis/memory/store.py
Functions¶
build_memory_service
¶
build_memory_service(config: Any, engine: Any, default_model: str = '') -> Optional[MemoryService]
Build a :class:MemoryService from config, or None if disabled.
Reads the [memory] section (config.memory / config.tools.storage)
for enabled, backend, extraction_model, max_facts and
facts_path. Returns None when memory is disabled or no engine /
extraction model is available, so callers can simply do::
svc = build_memory_service(config, engine, model)
if svc is not None:
svc.start()
Source code in src/openjarvis/memory/service.py
create_fact_store
¶
create_fact_store(backend: str = 'local', *, path: str | Path = '~/.openjarvis/memory_facts.jsonl', max_facts: int = 1000) -> FactStore
Construct a fact store for the configured backend.
Only the "local" (on-disk JSONL) backend is supported today; the
factory exists so additional backends can be added without changing the
service or CLI wiring.