service
service
¶
Persistent memory service: async fact extraction integrated into core.
MemoryService runs fact extraction on a dedicated background thread so it
never blocks jarvis serve request handling or the jarvis chat REPL.
Callers hand off an exchange via :meth:submit, which enqueues the work and
returns immediately — the slow model call and disk write happen out of band.
The worker swallows every per-job error (including BrokenPipeError when a
client disconnects mid-extraction), so a flaky extraction model can never take
down the host process.
The service is started and stopped as part of the OpenJarvis lifecycle (see
cli/serve.py and cli/chat_cmd.py) and is configured through the
[memory] section of config.toml.
Classes¶
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
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()