Skip to content

Commit 8206bf1

Browse files
committed
Merge pull request #117971 from openclaw/test/qa-live-voice-talkback-20260802
test(qa): validate live inbound voice talkback
2 parents e9b25aa + 54cb021 commit 8206bf1

9 files changed

Lines changed: 439 additions & 177 deletions

‎extensions/qa-lab/src/live-transports/matrix/scenarios/scenario-media-fixtures.ts‎

Lines changed: 0 additions & 6 deletions
Large diffs are not rendered by default.

‎extensions/qa-lab/src/live-transports/matrix/scenarios/scenario-runtime-media.ts‎

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,10 +1,10 @@
1+
import { createQaVoicePreflightWav } from "../../../voice-preflight.fixture.js";
12
// QA Lab Matrix plugin module implements scenario runtime media behavior.
23
import type { MatrixQaObservedEvent } from "../substrate/events.js";
34
import { MATRIX_QA_MEDIA_ROOM_KEY, resolveMatrixQaScenarioRoomId } from "./scenario-contract.js";
45
import {
56
buildMatrixQaImageGenerationPrompt,
67
buildMatrixQaImageUnderstandingPrompt,
7-
createMatrixQaVoicePreflightWav,
88
createMatrixQaSplitColorImagePng,
99
hasMatrixQaExpectedColorReply,
1010
MATRIX_QA_IMAGE_ATTACHMENT_FILENAME,
@@ -248,7 +248,7 @@ export async function runVoicePreflightMentionScenario(context: MatrixQaScenario
248248
const roomId = resolveMatrixQaScenarioRoomId(context, MATRIX_QA_MEDIA_ROOM_KEY);
249249
const { client, startSince } = await primeMatrixQaDriverMediaClient(context);
250250
const driverEventId = await client.sendMediaMessage({
251-
buffer: createMatrixQaVoicePreflightWav(),
251+
buffer: createQaVoicePreflightWav(),
252252
contentType: "audio/wav",
253253
fileName: MATRIX_QA_VOICE_PREFLIGHT_FILENAME,
254254
kind: "audio",

‎extensions/qa-lab/src/scenario-catalog.openai-live.test.ts‎

Lines changed: 37 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -60,6 +60,43 @@ describe("qa scenario catalog", () => {
6060
]);
6161
});
6262

63+
it("includes the live inbound voice talkback scenario", () => {
64+
const scenario = readQaScenarioById("inbound-voice-talkback-live");
65+
const config = readQaScenarioExecutionConfig("inbound-voice-talkback-live") as
66+
| {
67+
requiredProviderMode?: string;
68+
requiredProvider?: string;
69+
requiredModel?: string;
70+
expectedMarker?: string;
71+
}
72+
| undefined;
73+
74+
expect(scenario.sourcePath).toBe("qa/scenarios/media/inbound-voice-talkback-live.yaml");
75+
expect(scenario.coverage?.primary).toEqual(["media.inbound-media-store"]);
76+
expect(scenario.execution.channel).toBe("qa-channel");
77+
expect(scenario.gatewayConfigPatch?.tools).toEqual({
78+
media: {
79+
models: [
80+
{
81+
provider: "openai",
82+
model: "gpt-4o-transcribe",
83+
capabilities: ["audio"],
84+
},
85+
],
86+
audio: {
87+
enabled: true,
88+
echoTranscript: false,
89+
},
90+
},
91+
});
92+
expect(config?.requiredProviderMode).toBe("live-frontier");
93+
expect(config?.requiredProvider).toBe("openai");
94+
expect(config?.requiredModel).toBe("gpt-5.4");
95+
expect(config?.expectedMarker).toBe("MATRIX QA VOICE PREFLIGHT OK");
96+
expect(JSON.stringify(scenario.execution.flow)).toContain("./voice-preflight.fixture.js");
97+
expect(JSON.stringify(scenario.execution.flow)).not.toContain("./live-transports/matrix/");
98+
});
99+
63100
it("includes the Kitchen Sink live OpenAI plugin gauntlet", () => {
64101
const scenario = readQaScenarioById("kitchen-sink-live-openai");
65102
const config = readQaScenarioExecutionConfig("kitchen-sink-live-openai") as
Lines changed: 172 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,172 @@
1+
import { createQaBusState } from "./bus-state.js";
2+
import { readQaScenarioById, type QaScenarioFlow } from "./scenario-catalog.js";
3+
import { runScenarioFlow } from "./scenario-flow-runner.js";
4+
5+
type QaFlowStep = {
6+
name: string;
7+
run: () => Promise<string | void>;
8+
};
9+
10+
function formatTestTranscript(state: ReturnType<typeof createQaBusState>) {
11+
return state
12+
.getSnapshot()
13+
.messages.map((message) => `${message.direction}:${message.conversation.id}:${message.text}`)
14+
.join("\n");
15+
}
16+
17+
export async function runLoadedScenarioFlow(
18+
scenarioId: string,
19+
params: {
20+
flow?: QaScenarioFlow;
21+
api?: Record<string, unknown>;
22+
state?: ReturnType<typeof createQaBusState>;
23+
omitOutboundSequence?: boolean;
24+
onWaitForOutboundMessage?: (params: {
25+
waitCount: number;
26+
state: ReturnType<typeof createQaBusState>;
27+
}) => void;
28+
} = {},
29+
) {
30+
const scenario = readQaScenarioById(scenarioId);
31+
const loadedFlow = scenario.execution.flow;
32+
if (!loadedFlow) {
33+
throw new Error(`scenario has no flow: ${scenarioId}`);
34+
}
35+
36+
const state = params.state ?? createQaBusState();
37+
let waitCount = 0;
38+
const transport = {
39+
accountId: "qa-channel",
40+
state,
41+
reset: async () => {
42+
state.reset();
43+
},
44+
sendInbound: async (input: Parameters<typeof state.addInboundMessage>[0]) =>
45+
state.addInboundMessage(input),
46+
sendNativeCommand: async (
47+
input: Omit<Parameters<typeof state.addInboundMessage>[0], "nativeCommand" | "text"> & {
48+
command: string;
49+
},
50+
) => {
51+
const { command, ...message } = input;
52+
state.addInboundMessage({
53+
...message,
54+
text: `/${command}`,
55+
nativeCommand: { name: command },
56+
});
57+
},
58+
waitForNoOutbound: async () => undefined,
59+
waitForOutbound: async (input: {
60+
conversation?: { id: string; kind: string };
61+
sinceIndex?: number;
62+
textIncludes?: string;
63+
timeoutMs?: number;
64+
}) => {
65+
waitCount += 1;
66+
params.onWaitForOutboundMessage?.({ waitCount, state });
67+
const match = state
68+
.getSnapshot()
69+
.messages.filter((candidate) => candidate.direction === "outbound")
70+
.slice(input.sinceIndex ?? 0)
71+
.find(
72+
(candidate) =>
73+
(!input.conversation || candidate.conversation.id === input.conversation.id) &&
74+
(!input.conversation || candidate.conversation.kind === input.conversation.kind) &&
75+
(!input.textIncludes || candidate.text.includes(input.textIncludes)),
76+
);
77+
if (match) {
78+
state.resolvePollCursor({
79+
accountId: "qa-channel",
80+
cursor: state.getSnapshot().cursor,
81+
});
82+
return match;
83+
}
84+
throw new Error(`timed out after ${input.timeoutMs}ms waiting for outbound marker`);
85+
},
86+
...(params.omitOutboundSequence
87+
? {}
88+
: {
89+
waitForOutboundSequence: async () => {
90+
throw new Error("outbound sequence not configured for this fixture");
91+
},
92+
}),
93+
};
94+
const api = {
95+
env: {
96+
providerMode: "mock-openai",
97+
gateway: {
98+
restartAfterStateMutation: async (mutate: (context: unknown) => Promise<void>) => {
99+
await mutate({});
100+
},
101+
},
102+
},
103+
transport,
104+
state,
105+
scenario,
106+
config: scenario.execution.config ?? {},
107+
randomUUID: () => "00000000-0000-4000-8000-000000000000",
108+
liveTurnTimeoutMs: (_env: unknown, timeoutMs: number) => timeoutMs,
109+
waitForGatewayHealthy: async () => undefined,
110+
waitForTransportReady: async () => undefined,
111+
waitForQaChannelReady: async () => undefined,
112+
waitForNoOutbound: async () => undefined,
113+
waitForCondition: async <T>(check: () => T | Promise<T | undefined>) => {
114+
for (let attempt = 0; attempt < 10; attempt += 1) {
115+
const value = await check();
116+
if (value !== undefined) {
117+
return value;
118+
}
119+
}
120+
throw new Error("test condition was not met");
121+
},
122+
sleep: async () => undefined,
123+
reset: async () => {
124+
state.reset();
125+
},
126+
resetBus: async () => {
127+
state.reset();
128+
},
129+
runAgentPrompt: async () => undefined,
130+
formatTransportTranscript: formatTestTranscript,
131+
waitForOutboundMessage: async (
132+
stateLocal: ReturnType<typeof createQaBusState>,
133+
predicate: (candidate: unknown) => boolean,
134+
timeoutMs: number,
135+
options?: { sinceIndex?: number },
136+
) => {
137+
waitCount += 1;
138+
params.onWaitForOutboundMessage?.({ waitCount, state: stateLocal });
139+
const match = stateLocal
140+
.getSnapshot()
141+
.messages.slice(options?.sinceIndex ?? 0)
142+
.find((candidate) => predicate(candidate));
143+
if (match) {
144+
return match;
145+
}
146+
throw new Error(`timed out after ${timeoutMs}ms waiting for outbound marker`);
147+
},
148+
runScenario: async (_name: string, steps: QaFlowStep[]) => {
149+
const stepResults = [];
150+
for (const step of steps) {
151+
const details = await step.run();
152+
stepResults.push({
153+
name: step.name,
154+
status: "pass" as const,
155+
...(details !== undefined ? { details } : {}),
156+
});
157+
}
158+
return {
159+
name: scenario.title,
160+
status: "pass" as const,
161+
steps: stepResults,
162+
};
163+
},
164+
...params.api,
165+
};
166+
167+
return await runScenarioFlow({
168+
api,
169+
scenarioTitle: scenario.title,
170+
flow: params.flow ?? loadedFlow,
171+
});
172+
}

0 commit comments

Comments
 (0)