feat(memory): add openai-compatible embeddings provider#84930
feat(memory): add openai-compatible embeddings provider#84930dutifulbob wants to merge 1 commit into
Conversation
Dependency Changes DetectedThis PR changes dependency-related files. Maintainers should confirm these changes are intentional. Changed files:
Maintainer follow-up:
|
|
Codex review: needs changes before merge. Workflow note: Future ClawSweeper reviews update this same comment in place. How this review workflow works
Summary Reproducibility: yes. for the review finding by source inspection: memory-lancedb defaults an omitted model before calling the new provider, so the new missing-model check cannot fire in the documented config path. Not applicable as a bug reproduction for the feature request itself. PR rating Rank-up moves:
What the crustacean ranks mean
Shiny media proof means a screenshot, video, or linked artifact directly shows the changed behavior. Runtime, network, CSP, and security claims still need visible diagnostics. Real behavior proof Risk before merge
Maintainer options:
Next step before merge Security Review findings
Review detailsBest possible solution: Land this provider after enforcing the explicit model contract at the memory-lancedb config boundary while keeping the opt-in, no-warmup, SSRF-guarded remote path and direct HTTP coverage. Do we have a high-confidence way to reproduce the issue? Yes for the review finding by source inspection: memory-lancedb defaults an omitted model before calling the new provider, so the new missing-model check cannot fire in the documented config path. Not applicable as a bug reproduction for the feature request itself. Is this the best way to solve the issue? No, not as-is: the provider architecture is reasonable, but the explicit model requirement needs to be enforced where memory-lancedb parses or passes config. The safer fix is a provider-specific parser/test change rather than relying on the factory to distinguish defaults from user input. Label changes:
Label justifications:
Full review comments:
Overall correctness: patch is incorrect Acceptance criteria:
What I checked:
Likely related people:
Codex review notes: model gpt-5.5, reasoning high; reviewed against bde07ddb1552. |
|
ClawSweeper PR egg 🔥 Warming up: real-behavior proof passed; findings, security review, or rank-up moves are still in progress. Hatch commandComment Hatchability rules:
What is this egg doing here?
|
825ce3b to
1453ad9
Compare
1453ad9 to
b818c1d
Compare
Co-authored-by: Soham Patankar <102520430+yaanfpv@users.noreply.github.com>
b818c1d to
727c853
Compare
|
Final implementation/proof update for the maintainer pass. Original PR/author credit:
What changed after review:
Local verification on latest head
Real local provider proof:
Dependency delta:
GitHub verification:
Known proof gap:
|
|
do not merge, this was inspired by another user and is not a good architecture |
|
Closing this as superseded by #84947. The replacement PR separates the architecture work into the general |
Summary
OpenClaw did not have a clean generic provider for self-hosted OpenAI-compatible embedding servers.
This adds an explicit
openai-compatiblememory embedding provider for local or self-hosted/v1/embeddingsservers, without borrowing cloud OpenAI config or making vendor-specific warmup calls.This builds on #80479 by Soham Patankar / @yaanfpv and adds the missing direct HTTP contract coverage from the implementation plan.
What Changed
The new provider is a bundled plugin that users opt into from
memory-lancedbconfig.It uses the existing remote embedding engine, but keeps auth, base URL, model, SSRF policy, dimensions, and cache-key behavior scoped to this provider.
extensions/openai-compatible-embeddingswith provider registration, provider creation, adapter runtime metadata, manifest, package metadata, and focused tests.embedding.baseUrlandembedding.model, with optionalembedding.apiKeyused only as a bearer token for this provider.models.providers.*inheritance, and LM Studio-style preload/warmup calls.embedding.dimensionsby sending OpenAI-compatibledimensionsin request bodies and including it in cache keys.llama-server, vLLM, LocalAI, TGI-compatible servers, and llamafile responses through the same generic path.Real behavior proof
Behavior addressed: explicit OpenAI-compatible memory embeddings for self-hosted
/v1/embeddingsservers without cloud credential inheritance or vendor warmup calls.Real environment tested: local OpenClaw checkout on Linux, local HTTP fixture server, and local Ollama
0.24.0at127.0.0.1:11434with the already-installedqwen2.5:3bmodel. No model was downloaded for this PR.Exact steps or command run after this patch:
node --import tsx --input-type=modulesmoke script that importedcreateOpenAICompatibleEmbeddingProvider, configured{ model: "qwen2.5:3b", remote: { baseUrl: "http://127.0.0.1:11434/v1" } }, then calledprovider.embedQuery("hello from openclaw")andprovider.embedBatch(["first memory", "second memory"])against the local Ollama/v1/embeddingsendpoint.Evidence after fix: terminal output from the real local Ollama smoke was:
Observed result after fix: provider creation made no warmup request; the first real query and batch calls succeeded through the generic
/v1/embeddingspath, returned finite vectors, and preserved the local Ollama model's 2048-dimensional embedding shape for both query and batch calls.What was not tested: live llama.cpp, vLLM, TGI, LocalAI, and llamafile servers; those are covered by OpenAI-shaped compatibility fixtures, not live runtime instances.
Verification
node scripts/run-vitest.mjs extensions/openai-compatible-embeddingspassed: 2 files, 14 tests.node scripts/run-tsgo.mjs -p tsconfig.extensions.json --incremental --tsBuildInfoFile .artifacts/tsgo-cache/extensions.tsbuildinfopassed.node scripts/run-tsgo.mjs -p test/tsconfig/tsconfig.extensions.test.json --incremental --tsBuildInfoFile .artifacts/tsgo-cache/extensions-test.tsbuildinfopassed.node scripts/run-oxlint.mjs --tsconfig config/tsconfig/oxlint.extensions.json extensions/openai-compatible-embeddingspassed.PNPM_CONFIG_PM_ON_FAIL=ignore PNPM_CONFIG_VERIFY_DEPS_BEFORE_RUN=false pnpm plugins:sync:checkpassed../node_modules/.bin/oxfmt --check --threads=1 ...passed for touched files.node scripts/check-extension-plugin-sdk-boundary.mjs --mode=plugin-sdk-internalpassed.node scripts/check-extension-plugin-sdk-boundary.mjs --mode=src-outside-plugin-sdkpassed.node scripts/check-extension-plugin-sdk-boundary.mjs --mode=relative-outside-packagepassed.node --import tsx scripts/check-no-extension-src-imports.tspassed.node scripts/check-docs-mdx.mjs docs/plugins/memory-lancedb.mdpassed.pnpm check:changelog-attributionspassed.node scripts/check-plugin-sdk-subpath-exports.mjspassed.node scripts/check-plugin-extension-import-boundary.mjspassed.git diff --checkpassed.pnpm docs:listcompleted and confirmed the relevant docs area.codex review --base mainis being rerun after the review fixes.Known local tooling notes:
pnpm install --lockfile-onlywas blocked by the repo minimum-release-age guard for unrelatedweb-tree-sitter@0.26.9, so the new workspace importer was added directly topnpm-lock.yaml.markdownlint-cli2run expanded to the full docs tree plus historicalCHANGELOG.mdand reported hundreds of pre-existing changelog/docs lint errors, so it was not useful as changed-file proof.pnpm changed:lanes --jsonwithout a base uses this checkout's divergentorigin/main;node scripts/changed-lanes.mjs --base upstream/main --jsoncorrectly scoped this branch to extensions, docs, tooling, and all-lane CI.Risks
The provider intentionally supports the common OpenAI-compatible embeddings contract, not every vendor quirk.
If a server claims compatibility but returns a non-OpenAI response shape, the shared remote parser will fail with the provider-specific error prefix.