From 09a44530266ebf4992a38526bb1ea1fb474d2eda Mon Sep 17 00:00:00 2001 From: Neerav Makwana <261249544+neeravmakwana@users.noreply.github.com> Date: Tue, 24 Mar 2026 20:55:40 -0400 Subject: [PATCH] fix(memory): bootstrap proxy for LanceDB embeddings --- extensions/memory-lancedb/index.test.ts | 8 ++++++++ extensions/memory-lancedb/index.ts | 2 ++ 2 files changed, 10 insertions(+) diff --git a/extensions/memory-lancedb/index.test.ts b/extensions/memory-lancedb/index.test.ts index 762d6990f63..c5875a310e8 100644 --- a/extensions/memory-lancedb/index.test.ts +++ b/extensions/memory-lancedb/index.test.ts @@ -204,6 +204,7 @@ describe("memory plugin e2e", () => { const embeddingsCreate = vi.fn(async () => ({ data: [{ embedding: [0.1, 0.2, 0.3] }], })); + const ensureGlobalUndiciEnvProxyDispatcher = vi.fn(); const toArray = vi.fn(async () => []); const limit = vi.fn(() => ({ toArray })); const vectorSearch = vi.fn(() => ({ limit })); @@ -220,6 +221,9 @@ describe("memory plugin e2e", () => { })); vi.resetModules(); + vi.doMock("openclaw/plugin-sdk/infra-runtime", () => ({ + ensureGlobalUndiciEnvProxyDispatcher, + })); vi.doMock("openai", () => ({ default: class MockOpenAI { embeddings = { create: embeddingsCreate }; @@ -277,6 +281,10 @@ describe("memory plugin e2e", () => { await recallTool.execute("test-call-dims", { query: "hello dimensions" }); expect(loadLanceDbModule).toHaveBeenCalledTimes(1); + expect(ensureGlobalUndiciEnvProxyDispatcher).toHaveBeenCalledOnce(); + expect(ensureGlobalUndiciEnvProxyDispatcher.mock.invocationCallOrder[0]).toBeLessThan( + embeddingsCreate.mock.invocationCallOrder[0], + ); expect(embeddingsCreate).toHaveBeenCalledWith({ model: "text-embedding-3-small", input: "hello dimensions", diff --git a/extensions/memory-lancedb/index.ts b/extensions/memory-lancedb/index.ts index 498712b0b77..9d1e00dccce 100644 --- a/extensions/memory-lancedb/index.ts +++ b/extensions/memory-lancedb/index.ts @@ -10,6 +10,7 @@ import { randomUUID } from "node:crypto"; import type * as LanceDB from "@lancedb/lancedb"; import { Type } from "@sinclair/typebox"; import OpenAI from "openai"; +import { ensureGlobalUndiciEnvProxyDispatcher } from "openclaw/plugin-sdk/infra-runtime"; import { definePluginEntry, type OpenClawPluginApi } from "./api.js"; import { DEFAULT_CAPTURE_MAX_CHARS, @@ -168,6 +169,7 @@ class Embeddings { if (this.dimensions) { params.dimensions = this.dimensions; } + ensureGlobalUndiciEnvProxyDispatcher(); const response = await this.client.embeddings.create(params); return response.data[0].embedding; }