File size: 1,662 Bytes
fc93158 | 1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 | import { beforeEach, describe, it } from "vitest";
import {
resetMemoryToolMockState,
setMemorySearchImpl,
} from "../../../test/helpers/memory-tool-manager-mock.js";
import {
createMemorySearchToolOrThrow,
expectUnavailableMemorySearchDetails,
} from "./memory-tool.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.",
});
});
});
|