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

推荐订阅源

V
Visual Studio Blog
Engineering at Meta
Engineering at Meta
月光博客
月光博客
钛媒体:引领未来商业与生活新知
钛媒体:引领未来商业与生活新知
T
Tailwind CSS Blog
博客园 - Franky
The GitHub Blog
The GitHub Blog
大猫的无限游戏
大猫的无限游戏
The Cloudflare Blog
B
Blog RSS Feed
云风的 BLOG
云风的 BLOG
小众软件
小众软件
罗磊的独立博客
Microsoft Azure Blog
Microsoft Azure Blog
I
InfoQ
美团技术团队
H
Hackread – Cybersecurity News, Data Breaches, AI and More
OSCHINA 社区最新新闻
OSCHINA 社区最新新闻
V
V2EX
C
Check Point Blog
WordPress大学
WordPress大学
博客园 - 【当耐特】
博客园 - 司徒正美
D
Docker

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
fix(plugins): bound prompt memory recall latency · opencl...
vincentkoc · 2026-04-28 · via Recent Commits to openclaw:main

@@ -149,6 +149,7 @@ function resolveAutoCaptureStartIndex(

149149

// ============================================================================

150150151151

const TABLE_NAME = "memories";

152+

const DEFAULT_AUTO_RECALL_TIMEOUT_MS = 15_000;

152153153154

class MemoryDB {

154155

private db: LanceDB.Connection | null = null;

@@ -262,7 +263,7 @@ class MemoryDB {

262263

// ============================================================================

263264264265

type Embeddings = {

265-

embed(text: string): Promise<number[]>;

266+

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

266267

};

267268268269

class OpenAiCompatibleEmbeddings implements Embeddings {

@@ -277,7 +278,7 @@ class OpenAiCompatibleEmbeddings implements Embeddings {

277278

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

278279

}

279280280-

async embed(text: string): Promise<number[]> {

281+

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

281282

const params: OpenAI.EmbeddingCreateParams = {

282283

model: this.model,

283284

input: text,

@@ -292,6 +293,7 @@ class OpenAiCompatibleEmbeddings implements Embeddings {

292293

// transport and normalize the response ourselves.

293294

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

294295

body: params,

296+

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

295297

});

296298

return normalizeEmbeddingVector(response.data?.[0]?.embedding);

297299

}

@@ -353,6 +355,32 @@ class ProviderAdapterEmbeddings implements Embeddings {

353355

}

354356

}

355357358+

async function runWithTimeout<T>(params: {

359+

timeoutMs: number;

360+

task: () => Promise<T>;

361+

}): Promise<{ status: "ok"; value: T } | { status: "timeout" }> {

362+

let timeout: ReturnType<typeof setTimeout> | undefined;

363+

const TIMEOUT = Symbol("timeout");

364+

const timeoutPromise = new Promise<typeof TIMEOUT>((resolve) => {

365+

timeout = setTimeout(() => resolve(TIMEOUT), params.timeoutMs);

366+

timeout.unref?.();

367+

});

368+

const taskPromise = params.task();

369+

taskPromise.catch(() => undefined);

370+371+

try {

372+

const result = await Promise.race([taskPromise, timeoutPromise]);

373+

if (result === TIMEOUT) {

374+

return { status: "timeout" };

375+

}

376+

return { status: "ok", value: result };

377+

} finally {

378+

if (timeout) {

379+

clearTimeout(timeout);

380+

}

381+

}

382+

}

383+356384

function createEmbeddings(api: OpenClawPluginApi, cfg: MemoryConfig): Embeddings {

357385

const { provider, model, dimensions, apiKey, baseUrl } = cfg.embedding;

358386

if (provider === "openai" && apiKey) {

@@ -818,8 +846,22 @@ export default definePluginEntry({

818846

event.prompt,

819847

currentCfg.recallMaxChars,

820848

);

821-

const vector = await embeddings.embed(recallQuery);

822-

const results = await db.search(vector, 3, 0.3);

849+

const recall = await runWithTimeout({

850+

timeoutMs: DEFAULT_AUTO_RECALL_TIMEOUT_MS,

851+

task: async () => {

852+

const vector = await embeddings.embed(recallQuery, {

853+

timeoutMs: DEFAULT_AUTO_RECALL_TIMEOUT_MS,

854+

});

855+

return await db.search(vector, 3, 0.3);

856+

},

857+

});

858+

if (recall.status === "timeout") {

859+

api.logger.warn?.(

860+

`memory-lancedb: auto-recall timed out after ${DEFAULT_AUTO_RECALL_TIMEOUT_MS}ms; skipping memory injection to avoid stalling agent startup`,

861+

);

862+

return undefined;

863+

}

864+

const results = recall.value;

823865824866

if (results.length === 0) {

825867

return undefined;