mirror of
https://github.com/openclaw/openclaw.git
synced 2026-05-04 22:10:21 +00:00
refactor: add memory-core extension sources
This commit is contained in:
43
extensions/memory-core/src/tools.test.ts
Normal file
43
extensions/memory-core/src/tools.test.ts
Normal file
@@ -0,0 +1,43 @@
|
||||
import { beforeEach, describe, it } from "vitest";
|
||||
import {
|
||||
resetMemoryToolMockState,
|
||||
setMemorySearchImpl,
|
||||
} from "../../../test/helpers/memory-tool-manager-mock.js";
|
||||
import {
|
||||
createMemorySearchToolOrThrow,
|
||||
expectUnavailableMemorySearchDetails,
|
||||
} from "./tools.test-helpers.js";
|
||||
|
||||
describe("memory_search unavailable payloads", () => {
|
||||
beforeEach(() => {
|
||||
resetMemoryToolMockState({ searchImpl: async () => [] });
|
||||
});
|
||||
|
||||
it("returns explicit unavailable metadata for quota failures", async () => {
|
||||
setMemorySearchImpl(async () => {
|
||||
throw new Error("openai embeddings failed: 429 insufficient_quota");
|
||||
});
|
||||
|
||||
const tool = createMemorySearchToolOrThrow();
|
||||
const result = await tool.execute("quota", { query: "hello" });
|
||||
expectUnavailableMemorySearchDetails(result.details, {
|
||||
error: "openai embeddings failed: 429 insufficient_quota",
|
||||
warning: "Memory search is unavailable because the embedding provider quota is exhausted.",
|
||||
action: "Top up or switch embedding provider, then retry memory_search.",
|
||||
});
|
||||
});
|
||||
|
||||
it("returns explicit unavailable metadata for non-quota failures", async () => {
|
||||
setMemorySearchImpl(async () => {
|
||||
throw new Error("embedding provider timeout");
|
||||
});
|
||||
|
||||
const tool = createMemorySearchToolOrThrow();
|
||||
const result = await tool.execute("generic", { query: "hello" });
|
||||
expectUnavailableMemorySearchDetails(result.details, {
|
||||
error: "embedding provider timeout",
|
||||
warning: "Memory search is unavailable due to an embedding/provider error.",
|
||||
action: "Check embedding provider configuration and retry memory_search.",
|
||||
});
|
||||
});
|
||||
});
|
||||
Reference in New Issue
Block a user