

























@@ -3,11 +3,11 @@ import { afterEach, beforeEach, describe, expect, it, vi } from "vitest";
33import type { VoiceCallRealtimeFastContextConfig } from "./config.js";
4455const mocks = vi.hoisted(() => ({
6-getActiveMemorySearchManager: vi.fn(),
6+resolveRealtimeVoiceFastContextConsult: vi.fn(),
77}));
889-vi.mock("../../../src/plugins/memory-runtime.js", () => ({
10-getActiveMemorySearchManager: mocks.getActiveMemorySearchManager,
9+vi.mock("openclaw/plugin-sdk/realtime-voice", () => ({
10+resolveRealtimeVoiceFastContextConsult: mocks.resolveRealtimeVoiceFastContextConsult,
1111}));
12121313import { resolveRealtimeFastContextConsult } from "./realtime-fast-context.js";
@@ -36,16 +36,16 @@ function createLogger() {
36363737describe("resolveRealtimeFastContextConsult", () => {
3838beforeEach(() => {
39-mocks.getActiveMemorySearchManager.mockReset();
39+mocks.resolveRealtimeVoiceFastContextConsult.mockReset();
4040});
41414242afterEach(() => {
4343vi.useRealTimers();
4444});
454546-it("falls back to the full consult when memory manager setup fails", async () => {
46+it("passes voice-call labels into the SDK fast context resolver", async () => {
4747const logger = createLogger();
48-mocks.getActiveMemorySearchManager.mockRejectedValue(new Error("memory misconfigured"));
48+mocks.resolveRealtimeVoiceFastContextConsult.mockResolvedValue({ handled: false });
49495050await expect(
5151resolveRealtimeFastContextConsult({
@@ -58,31 +58,17 @@ describe("resolveRealtimeFastContextConsult", () => {
5858}),
5959).resolves.toEqual({ handled: false });
606061-expect(logger.debug).toHaveBeenCalledWith(expect.stringContaining("memory misconfigured"));
62-});
63-64-it("returns a bounded miss when memory manager setup exceeds the fast context timeout", async () => {
65-vi.useFakeTimers();
66-const logger = createLogger();
67-mocks.getActiveMemorySearchManager.mockReturnValue(new Promise(() => {}));
68-69-const resultPromise = resolveRealtimeFastContextConsult({
61+expect(mocks.resolveRealtimeVoiceFastContextConsult).toHaveBeenCalledWith({
7062 cfg,
7163agentId: "main",
7264sessionKey: "voice:15550001234",
73-config: createFastContextConfig({ fallbackToConsult: false, timeoutMs: 25 }),
65+config: createFastContextConfig({ fallbackToConsult: true }),
7466args: { question: "What do you remember?" },
7567 logger,
76-});
77-78-await vi.advanceTimersByTimeAsync(25);
79-80-await expect(resultPromise).resolves.toEqual({
81-handled: true,
82-result: {
83-text: expect.stringContaining("No relevant OpenClaw memory or session context"),
68+labels: {
69+audienceLabel: "caller",
70+contextName: "OpenClaw memory or session context",
8471},
8572});
86-expect(logger.debug).toHaveBeenCalledWith(expect.stringContaining("timed out after 25ms"));
8773});
8874});
此内容由惯性聚合(RSS阅读器)自动聚合整理,仅供阅读参考。 原文来自 — 版权归原作者所有。