Skip to content

fix(memory): defer resources for disabled managers 🤖🤖🤖 - #284

Open
Sampoornnagpal wants to merge 2 commits into
NVIDIA-NeMo:mainfrom
Sampoornnagpal:fix/disabled-memory-lazy-resources
Open

fix(memory): defer resources for disabled managers 🤖🤖🤖#284
Sampoornnagpal wants to merge 2 commits into
NVIDIA-NeMo:mainfrom
Sampoornnagpal:fix/disabled-memory-lazy-resources

Conversation

@Sampoornnagpal

@Sampoornnagpal Sampoornnagpal commented Sep 5, 2026

Copy link
Copy Markdown
Contributor

What does this PR do?

Installing MemoryManager with enabled=False still constructs an embedder and creates the configured SQLite database/directories before the disabled check. Defer these resources for disabled managers using cached properties, and avoid initializing the store during uninstall.

Enabled installation remains eager, preserving backend validation and hook setup. Explicit direct manager operations still work and initialize resources on demand; agent-facing tools stay disabled. Document that distinction.

Validation

New regressions reproduce directory creation and unnecessary embedder construction before the fix. Additional coverage checks explicit manager access, cached resource reuse, and uninstall.

uv run pytest -q packages/nooa-memory/tests/memory/test_memory_manager.py packages/nooa-memory/tests/memory/test_memory_owner.py packages/nooa-memory/tests/memory/test_memory_skill.py packages/nooa-memory/tests/memory/test_memory_reflection_interrupt.py — 54 passed. Targeted Pyright: 0 errors/warnings.

Windows/Python 3.12 with external import-only helpers for #84/#85 (fcntl/SIGUSR2); helpers are not included and do not validate POSIX locking/signals. No live model calls.

Related issues

No matching open issue found. Independent of the record-update fix in #277.

Checklist

  • Ruff lint and formatting pass.
  • Regression and manager/owner/skill/interrupt tests pass.
  • Memory README describes lazy disabled resources.
  • Existing SPDX headers retained.

Summary by CodeRabbit

  • Bug Fixes

    • Disabled memory managers no longer create databases or initialize embedding resources during installation.
    • Uninstalling an unused disabled manager no longer creates or opens storage.
    • Explicit memory manager operations initialize required resources on demand.
    • Agent-facing memory tools remain disabled when memory is disabled.
  • Documentation

    • Added documentation describing disabled-memory lifecycle behavior.
  • Tests

    • Added explanatory documentation to tests covering disabled installation and manager behavior.

Signed-off-by: Sampoorn Nagpal <nagpalsampoorn@gmail.com>
@coderabbitai

coderabbitai Bot commented Sep 5, 2026

Copy link
Copy Markdown

Review Change Stack

No actionable comments were generated in the recent review. 🎉

ℹ️ Recent review info
⚙️ Run configuration

Configuration used: Path: .coderabbit.yaml

Review profile: CHILL

Plan: Enterprise

Run ID: 79458fed-88d0-4b0c-998e-6ab16d50dc55

📥 Commits

Reviewing files that changed from the base of the PR and between b6a4941 and b5347af.

📒 Files selected for processing (2)
  • packages/nooa-memory/src/nooa_memory/manager.py
  • packages/nooa-memory/tests/memory/test_memory_manager.py
🚧 Files skipped from review as they are similar to previous changes (2)
  • packages/nooa-memory/tests/memory/test_memory_manager.py
  • packages/nooa-memory/src/nooa_memory/manager.py

Included review availability: Your plan provides up to 12 included reviews per hour; 11 remain after this review.


📝 Walkthrough

Walkthrough

MemoryManager now lazily initializes the embedder, store, and engines. Disabled installations avoid resource creation and agent-facing hooks until explicit manager use. Uninstalling an unused disabled manager does not create or close a store.

Changes

Memory manager lazy resources

Layer / File(s) Summary
Lazy initialization and safe uninstall
packages/nooa-memory/src/nooa_memory/manager.py
MemoryManager uses cached properties for resource initialization. Enabled configurations still validate backends eagerly. Uninstall closes the store only when it was initialized.
Disabled lifecycle validation and documentation
packages/nooa-memory/tests/memory/test_memory_manager.py, packages/nooa-memory/src/nooa_memory/README.md
Tests document deferred resource creation, explicit resource initialization and reuse, disabled hooks, and manager replacement. Documentation describes the lifecycle.

Estimated code review effort: 2 (Simple) | ~10 minutes

Merge Risk: ⚪ Minimal · up to b5347

Disabled memory installations now avoid creating embedder and SQLite resources until explicitly used, while enabled installations retain eager setup. No actionable current-head merge risk remains.

Sequence Diagram(s)

sequenceDiagram
  participant Caller
  participant MemoryManager
  participant Embedder
  participant MemoryStore
  participant RetrievalEngine
  Caller->>MemoryManager: invoke explicit memory operation
  MemoryManager->>Embedder: initialize on first access
  MemoryManager->>MemoryStore: initialize on first access
  MemoryManager->>RetrievalEngine: initialize with embedder and store
  RetrievalEngine-->>MemoryManager: return retrieval result
  MemoryManager-->>Caller: return operation result
Loading
🚥 Pre-merge checks | ✅ 5
✅ Passed checks (5 passed)
Check name Status Explanation
Description Check ✅ Passed Check skipped - CodeRabbit’s high-level summary is enabled.
Title check ✅ Passed The title clearly and concisely describes the main change: deferring resource initialization for disabled memory managers. The emojis add minor noise but do not make the title misleading.
Docstring Coverage ✅ Passed Docstring coverage is 92.86% which is sufficient. The required threshold is 80.00%. Docstring coverage is scoped to functions touched by this diff. Analyzed 14 functions across 2 files.
Linked Issues check ✅ Passed Check skipped because no linked issues were found for this pull request.
Out of Scope Changes check ✅ Passed Check skipped because no linked issues were found for this pull request.
✨ Finishing Touches
🧪 Generate unit tests (beta)
  • Create PR with unit tests

Comment @coderabbitai help to get the list of available commands.

Signed-off-by: Sampoorn Nagpal <nagpalsampoorn@gmail.com>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant