惯性聚合 高效追踪和阅读你感兴趣的博客、新闻、科技资讯
阅读原文 在惯性聚合中打开

推荐订阅源

D
Docker
I
InfoQ
L
LangChain Blog
阮一峰的网络日志
阮一峰的网络日志
Y
Y Combinator Blog
博客园_首页
Martin Fowler
Martin Fowler
宝玉的分享
宝玉的分享
A
About on SuperTechFans
Apple Machine Learning Research
Apple Machine Learning Research
Vercel News
Vercel News
T
The Blog of Author Tim Ferriss
C
Check Point Blog
B
Blog RSS Feed
Cyber Security Advisories - MS-ISAC
Cyber Security Advisories - MS-ISAC
Engineering at Meta
Engineering at Meta
B
Blog
爱范儿
爱范儿
Stack Overflow Blog
Stack Overflow Blog
aimingoo的专栏
aimingoo的专栏
WordPress大学
WordPress大学
F
Fortinet All Blogs
月光博客
月光博客
GbyAI
GbyAI

Recent Commits to openclaw:main

test: merge chat side-result checks · openclaw/openclaw@ddd2c2a test: merge cron history checks · openclaw/openclaw@f7eb746 test: merge responsive navigation shell checks · openclaw/openclaw@c2e4b47 docs(changelog): add codex oauth fixes · openclaw/openclaw@628e6cd test: merge navigation routing cases · openclaw/openclaw@5d8cecb Tests: mock channel registry bundled fallback · openclaw/openclaw@2b08233 Secrets: avoid broad web search discovery for single plugin config · openclaw/openclaw@a464f59 test: merge config view browser checks · openclaw/openclaw@20cf511 fix(status): align oauth health with runtime · openclaw/openclaw@eed7116 feat: add macOS screen snapshots for monitor preview (#67954) thanks … · openclaw/openclaw@f377db1 fix: report shared auth scopes in hello-ok (#67810) thanks @BunsDev · openclaw/openclaw@0b6c39b Auto-reply: avoid eager bundled route fallback · openclaw/openclaw@3ea1bf4 Tests: narrow session binding contract setup · openclaw/openclaw@54e4e16 fix(macOS): enable undo/redo in webchat composer text input (#34962) · openclaw/openclaw@00951dc Tests: speed up channel setup promotion · openclaw/openclaw@82b529a Docs: refresh agent instructions · openclaw/openclaw@5775fe2 fix(auth): serialize OAuth refresh across agents to fix #26322 (#67876) · openclaw/openclaw@8e79080 test: allow ollama public surface boundary test · openclaw/openclaw@7d4f1a6 Docs: add test performance guardrails · openclaw/openclaw@89706d3 Tests: restore context-engine usage proof · openclaw/openclaw@e4c4f95 Tests: slim context engine runtime coverage · openclaw/openclaw@74c198f ci: retry failed custom checkouts · openclaw/openclaw@0ee5baf test: trim duplicate provider auth onboarding cases · openclaw/openclaw@1ffc02e matrix: fix sessions_spawn --thread subagent session spawning (#67643) · openclaw/openclaw@1ce2596 test: reduce auth choice fixture churn · openclaw/openclaw@857b9cd test: mock health status config boundaries · openclaw/openclaw@9d5ab4a test: mock onboard config io boundary · openclaw/openclaw@299694d test: mock legacy state plugin boundaries · openclaw/openclaw@2713089 test: mock channel install boundaries · openclaw/openclaw@b945248 test: mock doctor preview channel boundaries · openclaw/openclaw@b1a3ad4
perf: lazy load memory embedding runtime · openclaw/openc...
steipete · 2026-05-08 · via Recent Commits to openclaw:main

@@ -9,13 +9,8 @@

99

import { Buffer } from "node:buffer";

1010

import { randomUUID } from "node:crypto";

1111

import type * as LanceDB from "@lancedb/lancedb";

12-

import OpenAI from "openai";

1312

import type { OpenClawConfig } from "openclaw/plugin-sdk/config-types";

14-

import {

15-

getMemoryEmbeddingProvider,

16-

type MemoryEmbeddingProvider,

17-

} from "openclaw/plugin-sdk/memory-core-host-engine-embeddings";

18-

import { resolveDefaultAgentId } from "openclaw/plugin-sdk/memory-host-core";

13+

import type { MemoryEmbeddingProvider } from "openclaw/plugin-sdk/memory-core-host-engine-embeddings";

1914

import { resolveLivePluginConfigObject } from "openclaw/plugin-sdk/plugin-config-runtime";

2015

import { ensureGlobalUndiciEnvProxyDispatcher } from "openclaw/plugin-sdk/runtime-env";

2116

import {

@@ -64,6 +59,40 @@ type AutoCaptureCursor = {

6459

lastMessageFingerprint?: string;

6560

};

666162+

type OpenAiEmbeddingClient = {

63+

post<T>(

64+

path: string,

65+

options: { body: unknown; timeout?: number; maxRetries?: number },

66+

): Promise<T>;

67+

};

68+69+

let openAiModulePromise: Promise<typeof import("openai")> | undefined;

70+

function loadOpenAiModule(): Promise<typeof import("openai")> {

71+

openAiModulePromise ??= import("openai");

72+

return openAiModulePromise;

73+

}

74+75+

let memoryEmbeddingProviderModulePromise:

76+

| Promise<typeof import("openclaw/plugin-sdk/memory-core-host-engine-embeddings")>

77+

| undefined;

78+

function loadMemoryEmbeddingProviderModule(): Promise<

79+

typeof import("openclaw/plugin-sdk/memory-core-host-engine-embeddings")

80+

> {

81+

memoryEmbeddingProviderModulePromise ??=

82+

import("openclaw/plugin-sdk/memory-core-host-engine-embeddings");

83+

return memoryEmbeddingProviderModulePromise;

84+

}

85+86+

let memoryHostCoreModulePromise:

87+

| Promise<typeof import("openclaw/plugin-sdk/memory-host-core")>

88+

| undefined;

89+

function loadMemoryHostCoreModule(): Promise<

90+

typeof import("openclaw/plugin-sdk/memory-host-core")

91+

> {

92+

memoryHostCoreModulePromise ??= import("openclaw/plugin-sdk/memory-host-core");

93+

return memoryHostCoreModulePromise;

94+

}

95+6796

function asRecord(value: unknown): Record<string, unknown> | undefined {

6897

return value && typeof value === "object" && !Array.isArray(value)

6998

? (value as Record<string, unknown>)

@@ -314,19 +343,21 @@ type Embeddings = {

314343

};

315344316345

class OpenAiCompatibleEmbeddings implements Embeddings {

317-

private client: OpenAI;

346+

private clientPromise: Promise<OpenAiEmbeddingClient>;

318347319348

constructor(

320349

apiKey: string,

321350

private model: string,

322351

baseUrl?: string,

323352

private dimensions?: number,

324353

) {

325-

this.client = new OpenAI({ apiKey, baseURL: baseUrl });

354+

this.clientPromise = loadOpenAiModule().then(

355+

({ default: OpenAI }) => new OpenAI({ apiKey, baseURL: baseUrl }) as OpenAiEmbeddingClient,

356+

);

326357

}

327358328359

async embed(text: string, options?: { timeoutMs?: number }): Promise<number[]> {

329-

const params: OpenAI.EmbeddingCreateParams = {

360+

const params: Record<string, unknown> = {

330361

model: this.model,

331362

input: text,

332363

};

@@ -338,7 +369,9 @@ class OpenAiCompatibleEmbeddings implements Embeddings {

338369

// omitted, then decodes the response. Several compatible providers either

339370

// reject encoding_format or always return float arrays, so use the generic

340371

// transport and normalize the response ourselves.

341-

const response = await this.client.post<EmbeddingCreateResponse>("/embeddings", {

372+

const response = await (

373+

await this.clientPromise

374+

).post<EmbeddingCreateResponse>("/embeddings", {

342375

body: params,

343376

...(options?.timeoutMs ? { timeout: options.timeoutMs, maxRetries: 0 } : {}),

344377

});

@@ -367,10 +400,12 @@ class ProviderAdapterEmbeddings implements Embeddings {

367400

private async createProvider(): Promise<MemoryEmbeddingProvider> {

368401

const cfg = (this.api.runtime.config?.current?.() ?? this.api.config) as OpenClawConfig;

369402

const providerId = this.embedding.provider;

403+

const { getMemoryEmbeddingProvider } = await loadMemoryEmbeddingProviderModule();

370404

const adapter = getMemoryEmbeddingProvider(providerId, cfg);

371405

if (!adapter) {

372406

throw new Error(`Unknown memory embedding provider: ${providerId}`);

373407

}

408+

const { resolveDefaultAgentId } = await loadMemoryHostCoreModule();

374409

const defaultAgentId = resolveDefaultAgentId(cfg);

375410

const agentDir = this.api.runtime.agent.resolveAgentDir(cfg, defaultAgentId);

376411

const remote =