Skip to content

fix(startup): accept the ONNX backend in the dependency check (#1930) - #1932

Merged
doobidoo merged 2 commits into
doobidoo:mainfrom
dodoshell:fix/1930-onnx-dependency-check
Nov 9, 2026
Merged

doobidoo merged 2 commits into
doobidoo:mainfrom
dodoshell:fix/1930-onnx-dependency-check

Conversation

@dodoshell

@dodoshell dodoshell commented Nov 9, 2026 •

Copy link
Copy Markdown
Contributor

What this changes

The startup dependency check passes when either embedding backend is usable, onnxruntime + tokenizers or torch + sentence-transformers, and warns only when neither is. The install hint is now pip install "mcp-memory-service[sqlite]", and is_first_run() also looks in the ONNX model cache.

Why

Fixes #1930. check_critical_dependencies() probed only torch and sentence_transformers, so every start of a [sqlite] install printed [MISSING] Missing dependencies detected: torch, sentence-transformers, get_recommended_timeout() doubled the base timeout, and the hint was python install.py, which pip, uv tool and uvx installs don't have.

  • check_onnx_installed() probes onnxruntime + tokenizers, next to the existing torch / sentence-transformers helpers. If ONNX is there, torch isn't imported at all.
  • With no backend, one entry is reported: onnxruntime + tokenizers (or torch + sentence-transformers). The other critical packages (sqlite-vec, mcp, ...) are checked as before.
  • suggest_installation_command() returns the [sqlite] command; the Windows branch returned the same string as the other one, so it's gone.
  • is_first_run(): the issue suggested checking the ONNX cache. Without it a [sqlite] user with a cached model is still a "first run" on every start, so the timeout keeps doubling. It now also scans ~/.cache/mcp_memory/onnx_models (Hub exports keep tokenizer.json in <model>/) and .../all-MiniLM-L6-v2 (the bundled model unpacks into onnx/). The existing name indicator 'miniml' never matches "MiniLM", which is why the default model's folder is listed itself.

How it was verified

# src/ from main (git checkout HEAD~1 -- src/)
pytest tests/unit/test_dependency_check.py -q
7 failed, 14 passed, 1 warning

# on this branch
pytest tests/unit/test_dependency_check.py -q
21 passed, 1 warning

The tests don't depend on what the venv has installed. They put fake onnxruntime/tokenizers/torch/sentence_transformers modules (or None, which makes the import fail) into sys.modules, so the real helpers and check_critical_dependencies() run. Covered: ONNX only, torch only, neither, torch without sentence-transformers, the run_dependency_check() output, the hint, the timeout (not doubled with either backend, still doubled with none), and is_first_run() with the default model cached, a Hub model cached, and an empty model directory (still a first run, since ONNXEmbeddingModel creates the directory before downloading).

By hand, in a fresh venv with pip install -e ".[sqlite]" (onnxruntime 1.31.1, no torch), after letting ONNXEmbeddingModel download its model, with LM_STUDIO=1 so the 5s cap doesn't hide the number:

# main
[MISSING] Missing dependencies detected: torch, sentence-transformers
   python install.py
check: False  first_run: True  timeout: 120.0

# this branch
[OK] All dependencies are installed
check: True  first_run: False  timeout: 30.0

pre_pr_check.sh (Windows): the quality gate was skipped (no LLM backend). The test suite step is red only because of tests/ci/test_auto_assign_claim.py, which fails the same 20 tests on main. Handler coverage and import validation failed on the cp1252 console encoding and pass with PYTHONUTF8=1.

Changelog fragment

changelog.d/1930.fixed.md

Notes for the reviewer

Agent Disclosure

I used Claude Code to help with this change, and I went through the diff, the tests and the description myself before opening this.

RetriggerView in GreptileConfidence Score: 5/5

The PR appears safe to merge.

Summary

The PR accepts either ONNX or PyTorch dependencies and replaces the installation hint with pip install "mcp-memory-service[sqlite]".

  • Startup accepts ONNX or PyTorch as the embedding backend.
  • Complete ONNX model caches count as a finished first run.

Reviews (2) · Last reviewed commit: "fix(startup): count an ONNX model as cac..." · Reviewed by Greptile

…oo#1930)

check_critical_dependencies() only knew torch + sentence-transformers, so
every start of a [sqlite] install (onnxruntime + tokenizers, no torch)
printed [MISSING] and timeout warnings, doubled the init timeout, and
pointed at `python install.py`, which pip, uv tool and uvx installs do
not ship.

Either backend now satisfies the check, and only an install with neither
is reported. The hint is `pip install "mcp-memory-service[sqlite]"`.
is_first_run() also scans ~/.cache/mcp_memory/onnx_models, so a cached
ONNX model no longer counts as a first run.
… tokenizer

ONNXEmbeddingModel creates the model directory before downloading, so a
directory name alone does not mean the model is there.
@doobidoo
doobidoo merged commit f003273 into doobidoo:main Nov 9, 2026
24 checks passed
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.

Startup dependency check reports torch/sentence-transformers as missing on the ONNX install

2 participants