Skip to content

Self-evolving Context Database for AI Agents. Unify Agent Memory, Knowledge RAG and Skills.

fix(openclaw): honor auto-recall timeout config (#2743)

Mingjian Quee4c98c6031c2
diff --git a/examples/openclaw-plugin/auto-recall.ts b/examples/openclaw-plugin/auto-recall.ts
index 1fe88fa6a..1538945cc 100644
--- a/examples/openclaw-plugin/auto-recall.ts
+++ b/examples/openclaw-plugin/auto-recall.ts
@@ -19,7 +19,6 @@ import {
import { sanitizeUserTextForCapture } from "./text-utils.js";
import { estimateTextTokens } from "./token-estimator.js";
-const AUTO_RECALL_TIMEOUT_MS = 5_000;
const RECALL_QUERY_MAX_CHARS = 4_000;
export const AUTO_RECALL_SOURCE_MARKER = "Source: openviking-auto-recall";
@@ -512,7 +511,7 @@ export async function buildAutoRecallContext(params: {
await recordTrace(memories.slice(0, memoryLines.length), memoryLines.length, estimatedTokens);
return { block, memoryCount: memoryLines.length, estimatedTokens };
})(),
- AUTO_RECALL_TIMEOUT_MS,
+ cfg.autoRecallTimeoutMs,
"openviking: auto-recall search timeout",
);
}
diff --git a/examples/openclaw-plugin/tests/ut/build-memory-lines.test.ts b/examples/openclaw-plugin/tests/ut/build-memory-lines.test.ts
index bbc1ebf22..9c19c86b7 100644
--- a/examples/openclaw-plugin/tests/ut/build-memory-lines.test.ts
+++ b/examples/openclaw-plugin/tests/ut/build-memory-lines.test.ts
@@ -370,6 +370,46 @@ describe("buildAutoRecallContext trace", () => {
expect(recorded.searches.map((search) => search.resourceType)).toEqual(["user"]);
});
+ it("uses configured autoRecallTimeoutMs as the outer timeout budget", async () => {
+ vi.useFakeTimers();
+ try {
+ const cfg = makeCfg({ autoRecallTimeoutMs: 30000, recallTargetTypes: ["user"] });
+ const client = {
+ healthCheck: vi.fn().mockResolvedValue(undefined),
+ find: vi.fn().mockImplementation(() =>
+ new Promise((resolve) => {
+ setTimeout(() => resolve({
+ memories: [makeMemory({
+ uri: "viking://user/memories/slow-backend",
+ abstract: "Slow local backend recall still completes within the configured budget.",
+ score: 0.9,
+ })],
+ total: 1,
+ }), 10000);
+ })
+ ),
+ read: vi.fn().mockResolvedValue("unused"),
+ };
+
+ const resultPromise = buildAutoRecallContext({
+ cfg,
+ client: client as any,
+ agentId: "agent-1",
+ queryText: "which slow backend memory should be recalled?",
+ logger: { info: vi.fn(), warn: vi.fn() },
+ });
+
+ await vi.advanceTimersByTimeAsync(10000);
+ await expect(resultPromise).resolves.toMatchObject({
+ memoryCount: 1,
+ });
+ const result = await resultPromise;
+ expect(result.block).toContain("Slow local backend recall still completes within the configured budget.");
+ } finally {
+ vi.useRealTimers();
+ }
+ });
+
it("records search errors while still injecting successful recall hits", async () => {
const cfg = makeCfg({ recallTargetTypes: ["resource", "user"] });
const client = {