Repository navigation
Description
Original Request
Enable the native ONNX Runtime backend (and optionally CUDA GPU acceleration) for semantic search embeddings. Also add a way to disable semantic search entirely.
Summary
The semantic search embedder forces the WASM fallback (onnxruntime-web) even though the native ONNX Runtime binaries — including CUDA GPU support — are already installed as a transitive dependency. This wastes 513 MB of native binaries that ship but are never used, and leaves performance on the table. There is also no way to disable semantic search or configure its hardware backend.
Current Behavior
packages/semantic-search/src/embedder.tshardcodesdevice: "cpu"and actively suppresses native ONNX Runtime warnings, forcing WASM execution viaonnxruntime-web.onnxruntime-node(513 MB) is already installed as a dependency of@huggingface/transformers, including:- Native CPU backend:
libonnxruntime.so.1(34 MB) - CUDA GPU backend:
libonnxruntime_providers_cuda.so(302 MB) - TensorRT backend:
libonnxruntime_providers_tensorrt.so(835 KB)
- Native CPU backend:
onnxruntime-web(127 MB) is also installed for the WASM fallback.- Semantic search is always registered on Node 22+ with no way to disable it (no settings key, no CLI flag, no env var).
Proposed Behavior
A. Use native ONNX Runtime when available
Remove the warning suppression and let @huggingface/transformers use onnxruntime-node when it can load the native addon. The native CPU backend should be faster than WASM with no configuration needed.
B. Make the device configurable
Add a setting (e.g. in ~/.dreb/agent/settings.json) to choose between "cpu", "cuda", or "auto". Default to "cpu" for safety, but allow users with CUDA-capable GPUs to opt in to GPU-accelerated embedding.
C. Add a disable toggle
Add a setting to disable semantic search entirely (e.g. search.enabled: false in settings.json). When disabled, the search tool should not register.
D. Consider making onnxruntime-node optional
If the native backend is enabled by default, the WASM fallback could potentially be dropped (saving 127 MB). Conversely, users who don't want native binaries could skip onnxruntime-node (saving 513 MB). This is a packaging/dependency decision worth exploring.
Acceptance Criteria
- The native
onnxruntime-nodebackend is used by default when it loads successfully, with WASM as fallback - A
search.devicesetting in~/.dreb/agent/settings.jsonallows choosing"cpu","cuda", or"auto" - A
search.enabledsetting in~/.dreb/agent/settings.jsoncan disable semantic search (tool does not register whenfalse) - Existing behavior is preserved when no settings are configured (no breaking change)
Technical Notes
- The key file is
packages/semantic-search/src/embedder.ts, specifically theinitialize()method around line 90. - The
pipeline()call from@huggingface/transformersacceptsdevice: "cuda"whenonnxruntime-nodeis loaded and CUDA drivers are available. - Settings would need to flow from
~/.dreb/agent/settings.jsonthroughSearchEngineOptionsintoEmbedderOptions. The settings infrastructure already exists inpackages/coding-agent/src/core/config.ts. - The warning suppression (lines 82-86 of
embedder.ts) was added because the native addon warning confused users. If native loading is supported properly, the suppression can be removed or refined to only suppress on intentional WASM fallback.
Drafted by mach6
Activity
aebrer commentedon Sep 27, 2026
This does seem like a good idea, in some form. There's also this past issue: #407
Definitely there is a gap in how search is handled compared to the other built-in tools, which I'm not sure how to address. I think a special toggle for it specifically might worsen the problem rather than just baking it into dreb properly rather than as a "shipped first class extension".