Skip to content

Enable native ONNX Runtime backend and add semantic search configuration options #526

Open

Description

@tobiasploetz

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.ts hardcodes device: "cpu" and actively suppresses native ONNX Runtime warnings, forcing WASM execution via onnxruntime-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)
  • 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-node backend is used by default when it loads successfully, with WASM as fallback
  • A search.device setting in ~/.dreb/agent/settings.json allows choosing "cpu", "cuda", or "auto"
  • A search.enabled setting in ~/.dreb/agent/settings.json can disable semantic search (tool does not register when false)
  • 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 the initialize() method around line 90.
  • The pipeline() call from @huggingface/transformers accepts device: "cuda" when onnxruntime-node is loaded and CUDA drivers are available.
  • Settings would need to flow from ~/.dreb/agent/settings.json through SearchEngineOptions into EmbedderOptions. The settings infrastructure already exists in packages/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

  1. aebrer commented on Sep 27, 2026

    @aebrer
    Owner

    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".

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions