Memory (Implementation): backend selection, fallback, healing, scope guard
Memory (Implementation): backend selection, fallback, healing, scope guard
This page complements the concept-level Memory system with implementation boundaries.
Code entry points (optional)
src/memory/backend-config.tssrc/memory/search-manager.tssrc/memory/qmd-manager.tssrc/agents/tools/memory-tool.tssrc/gateway/server-startup-memory.ts
The three-layer split (recommended)
- config parsing (backend/citations/limits/scope)
- manager acquisition (primary qmd → fallback builtin)
- tools (
memory_search/memory_get) with safe degradation
The key self-healing point: evict cached primary on failure
On primary failures:
- mark primary failed
- close primary
- evict the cache entry so a future request can recreate qmd
Scope guard: policy boundary, not backend failure
When the scope denies a search, return empty results (or disabled) without crashing the run.
Failure modes and troubleshooting
- Missing qmd binary/deps: verify automatic fallback to builtin and inspect Logging.
- Memory leaking into group contexts: audit scope rules and how session keys are matched (see Sessions).
Acceptance checks
- primary failures fall back without breaking the main run.
- cache eviction enables recreating primary later.
- scope-denied searches return empty results (no errors).
- tools degrade safely (disabled), not fatal throws.